Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
refactor: restructure source code
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Aug 10, 2024
1 parent 01d4d90 commit 8f5559f
Show file tree
Hide file tree
Showing 53 changed files with 276 additions and 244 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Python 3.9
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
architecture: ${{ matrix.architecture }}

- name: Set up Python Dependencies
- name: Setup Python Dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -r requirements-dev.txt --no-warn-script-location
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements-dev.txt
- name: Compile Locale Translations
run: |
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
--tb=native \
--verbose \
--color=yes \
--cov=pyra \
--cov=src \
tests
- name: Upload coverage
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/localize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ on:
branches: [master]
paths: # prevents workflow from running unless these files change
- '.github/workflows/localize.yml'
- 'retroarcher.py'
- 'locale/retroarcher.po'
- 'pyra/**.py'
- 'src/**.py'
- 'web/templates/**'
workflow_dispatch:

Expand All @@ -21,14 +20,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Python 3.9
- name: Install Python
uses: actions/setup-python@v5 # https://github.com/actions/setup-python
with:
python-version: '3.9'
python-version: '3.12'

- name: Set up Python 3.9 Dependencies
- name: Setup Python Dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
- name: Update Strings
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ cython_debug/
node_modules/
*package-lock.json

# RetroArcher directories
# project files and directories
logs/

# RetroArcher files
*config.ini
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN groupadd -g 1000 retroarcher && \
RUN mkdir -p /config
VOLUME /config

CMD ["python", "retroarcher.py"]
CMD ["python", "./src/retroarcher.py"]

EXPOSE 9696
HEALTHCHECK --start-period=90s CMD python retroarcher.py --docker_healthcheck || exit 1
30 changes: 23 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@

# standard imports
from datetime import datetime
import os
import sys


# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys

script_dir = os.path.dirname(os.path.abspath(__file__)) # the directory of this file
source_dir = os.path.dirname(script_dir) # the source folder directory
root_dir = os.path.dirname(source_dir) # the root folder directory
src_dir = os.path.join(root_dir, 'src') # the src folder directory

try:
sys.path.insert(0, root_dir)
from pyra import definitions # put this in a try/except to prevent flake8 warning
except Exception:
sys.path.insert(0, src_dir)
from common import definitions # put this in a try/except to prevent flake8 warning
except Exception as e:
print(f"Unable to import definitions from {root_dir}: {e}")
sys.exit(1)

# -- Project information -----------------------------------------------------
Expand All @@ -42,10 +44,11 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'm2r2', # enable markdown files
'myst_parser', # enable markdown files
'numpydoc', # this automatically loads `sphinx.ext.autosummary` as well
'sphinx.ext.autodoc', # autodocument modules
'sphinx.ext.autosectionlabel',
'sphinx.ext.intersphinx', # link to other projects' documentation
'sphinx.ext.todo', # enable to-do sections
'sphinx.ext.viewcode' # add links to view source code
]
Expand All @@ -59,7 +62,10 @@
exclude_patterns = ['toc.rst']

# Extensions to include.
source_suffix = ['.rst', '.md']
source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}


# -- Options for HTML output -------------------------------------------------
Expand Down Expand Up @@ -102,3 +108,13 @@
# disable epub mimetype warnings
# https://github.com/readthedocs/readthedocs.org/blob/eadf6ac6dc6abc760a91e1cb147cc3c5f37d1ea8/docs/conf.py#L235-L236
suppress_warnings = ["epub.unknown_project_files"]

python_version = f'{sys.version_info.major}.{sys.version_info.minor}'

intersphinx_mapping = {
'python': ('https://docs.python.org/{}/'.format(python_version), None),
}

numpydoc_show_class_members = True
numpydoc_show_inherited_class_members = False
numpydoc_xref_param_type = True
5 changes: 2 additions & 3 deletions docs/source/contributing/localization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ situations. For example the system tray icon is user interfacing and therefore s
- In order for strings to be extracted from python code, the following lines must be added.
.. code-block:: python
from pyra import locales
from common import locales
_ = locales.get_text()
- Wrap the string to be extracted in a function as shown.
Expand Down Expand Up @@ -76,8 +76,7 @@ any of the following paths are modified.

.. code-block:: yaml
- 'retroarcher.py'
- 'pyra/**.py'
- 'src/**.py'
- 'web/templates/**'
When testing locally it may be desirable to manually extract, initialize, update, and compile strings.
Expand Down
7 changes: 0 additions & 7 deletions docs/source/pyra_docs/config.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/pyra_docs/hardware.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/pyra_docs/helpers.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/pyra_docs/locales.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/pyra_docs/logger.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/pyra_docs/threads.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/pyra_docs/webapp.rst

This file was deleted.

7 changes: 7 additions & 0 deletions docs/source/src/common/common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../global.rst

:modname:`common.__init__`
--------------------------
.. automodule:: common
:members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. include:: ../global.rst

:modname:`pyra.__init__`
:modname:`common.config`
------------------------
.. automodule:: pyra
.. automodule:: common.config
:members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/src/common/definitions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../global.rst

:modname:`common.definitions`
-----------------------------
.. automodule:: common.definitions
:members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/src/common/hardware.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../global.rst

:modname:`common.hardware`
--------------------------
.. automodule:: common.hardware
:members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. include:: ../global.rst

:modname:`pyra.tray_icon`
:modname:`common.helpers`
-------------------------
.. automodule:: pyra.tray_icon
.. automodule:: common.helpers
:members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/src/common/locales.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../global.rst

:modname:`common.locales`
-------------------------
.. automodule:: common.locales
:members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/src/common/logger.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../global.rst

:modname:`common.logger`
------------------------
.. automodule:: common.logger
:members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/src/common/threads.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../global.rst

:modname:`common.threads`
-------------------------
.. automodule:: common.threads
:members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. include:: ../global.rst

:modname:`pyra.definitions`
:modname:`common.tray_icon`
---------------------------
.. automodule:: pyra.definitions
.. automodule:: common.tray_icon
:members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/src/common/webapp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../global.rst

:modname:`common.webapp`
------------------------
.. automodule:: common.webapp
:members:
:show-inheritance:
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. include:: ../global.rst
.. include:: global.rst

:modname:`retroarcher`
----------------------
Expand Down
24 changes: 12 additions & 12 deletions docs/source/toc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@

.. toctree::
:maxdepth: 0
:caption: Code
:caption: Source Code
:titlesonly:

main/retroarcher
pyra_docs/pyra
pyra_docs/config
pyra_docs/definitions
pyra_docs/hardware
pyra_docs/helpers
pyra_docs/locales
pyra_docs/logger
pyra_docs/threads
pyra_docs/tray_icon
pyra_docs/webapp
src/retroarcher
src/common/common
src/common/config
src/common/definitions
src/common/hardware
src/common/helpers
src/common/locales
src/common/logger
src/common/threads
src/common/tray_icon
src/common/webapp
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Flask-Babel==4.0.0
furo==2024.7.18
GPUtil==1.4.0
IPy==1.01
m2r2==0.3.3.post2
myst-parser==4.0.0
numexpr==2.10.1
numpydoc==1.7.0
Pillow==9.5.0
Expand Down
22 changes: 13 additions & 9 deletions scripts/_locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
root_dir = os.path.dirname(script_dir)
locale_dir = os.path.join(root_dir, 'locale')

# retroarcher target locales
# target locales
target_locales = [
'de', # Deutsch
'de', # German
'en', # English
'en_GB', # English (United Kingdom)
'en_US', # English (United States)
'es', # español
'fr', # français
'it', # italiano
'ru', # русский
'es', # Spanish
'fr', # French
'it', # Italian
'ja', # Japanese
'pt', # Portuguese
'ru', # Russian
'sv', # Swedish
'tr', # Turkish
'zh', # Chinese (Simplified)
]


Expand All @@ -41,9 +46,8 @@ def babel_extract():
f'--project={project_name}',
'--version=v0',
'--add-comments=NOTE',
'./retroarcher.py',
'./pyra',
'./web'
'./src',
'./web',
]

print(commands)
Expand Down
Loading

0 comments on commit 8f5559f

Please sign in to comment.