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

Commit eec9586

Browse files
refactor: restructure source code
1 parent 01d4d90 commit eec9586

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+226
-216
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959

6060
- name: Set up Python Dependencies
6161
run: |
62-
python -m pip install --upgrade pip setuptools
63-
python -m pip install -r requirements-dev.txt --no-warn-script-location
62+
python -m pip install --upgrade pip setuptools wheel
63+
python -m pip install -r requirements-dev.txt
6464
6565
- name: Compile Locale Translations
6666
run: |
@@ -108,7 +108,7 @@ jobs:
108108
--tb=native \
109109
--verbose \
110110
--color=yes \
111-
--cov=pyra \
111+
--cov=src \
112112
tests
113113
114114
- name: Upload coverage

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ cython_debug/
155155
node_modules/
156156
*package-lock.json
157157

158-
# RetroArcher directories
158+
# project files and directories
159159
logs/
160-
161-
# RetroArcher files
162160
*config.ini

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ RUN groupadd -g 1000 retroarcher && \
6262
RUN mkdir -p /config
6363
VOLUME /config
6464

65-
CMD ["python", "retroarcher.py"]
65+
CMD ["python", "./src/retroarcher.py"]
6666

6767
EXPOSE 9696
6868
HEALTHCHECK --start-period=90s CMD python retroarcher.py --docker_healthcheck || exit 1

docs/source/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
script_dir = os.path.dirname(os.path.abspath(__file__)) # the directory of this file
2020
source_dir = os.path.dirname(script_dir) # the source folder directory
2121
root_dir = os.path.dirname(source_dir) # the root folder directory
22+
src_dir = os.path.join(root_dir, 'src') # the src folder directory
2223

2324
try:
24-
sys.path.insert(0, root_dir)
25-
from pyra import definitions # put this in a try/except to prevent flake8 warning
26-
except Exception:
25+
sys.path.insert(0, src_dir)
26+
from common import definitions # put this in a try/except to prevent flake8 warning
27+
except Exception as e:
28+
print(f"Unable to import definitions from {root_dir}: {e}")
2729
sys.exit(1)
2830

2931
# -- Project information -----------------------------------------------------

docs/source/contributing/localization.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ situations. For example the system tray icon is user interfacing and therefore s
4343
- In order for strings to be extracted from python code, the following lines must be added.
4444
.. code-block:: python
4545
46-
from pyra import locales
46+
from common import locales
4747
_ = locales.get_text()
4848
4949
- Wrap the string to be extracted in a function as shown.
@@ -76,8 +76,7 @@ any of the following paths are modified.
7676

7777
.. code-block:: yaml
7878
79-
- 'retroarcher.py'
80-
- 'pyra/**.py'
79+
- 'src/**.py'
8180
- 'web/templates/**'
8281
8382
When testing locally it may be desirable to manually extract, initialize, update, and compile strings.

docs/source/pyra_docs/config.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/hardware.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/helpers.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/locales.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/logger.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/threads.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/webapp.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/src/common/common.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. include:: ../global.rst
2+
3+
:modname:`common.__init__`
4+
--------------------------
5+
.. automodule:: common
6+
:members:
7+
:show-inheritance:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. include:: ../global.rst
22

3-
:modname:`pyra.__init__`
3+
:modname:`common.config`
44
------------------------
5-
.. automodule:: pyra
5+
.. automodule:: common.config
66
:members:
77
:show-inheritance:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. include:: ../global.rst
2+
3+
:modname:`common.definitions`
4+
-----------------------------
5+
.. automodule:: common.definitions
6+
:members:
7+
:show-inheritance:

docs/source/src/common/hardware.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. include:: ../global.rst
2+
3+
:modname:`common.hardware`
4+
--------------------------
5+
.. automodule:: common.hardware
6+
:members:
7+
:show-inheritance:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. include:: ../global.rst
22

3-
:modname:`pyra.tray_icon`
3+
:modname:`common.helpers`
44
-------------------------
5-
.. automodule:: pyra.tray_icon
5+
.. automodule:: common.helpers
66
:members:
77
:show-inheritance:

docs/source/src/common/locales.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. include:: ../global.rst
2+
3+
:modname:`common.locales`
4+
-------------------------
5+
.. automodule:: common.locales
6+
:members:
7+
:show-inheritance:

docs/source/src/common/logger.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. include:: ../global.rst
2+
3+
:modname:`common.logger`
4+
------------------------
5+
.. automodule:: common.logger
6+
:members:
7+
:show-inheritance:

docs/source/src/common/threads.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. include:: ../global.rst
2+
3+
:modname:`common.threads`
4+
-------------------------
5+
.. automodule:: common.threads
6+
:members:
7+
:show-inheritance:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. include:: ../global.rst
22

3-
:modname:`pyra.definitions`
3+
:modname:`common.tray_icon`
44
---------------------------
5-
.. automodule:: pyra.definitions
5+
.. automodule:: common.tray_icon
66
:members:
77
:show-inheritance:

docs/source/src/common/webapp.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. include:: ../global.rst
2+
3+
:modname:`common.webapp`
4+
------------------------
5+
.. automodule:: common.webapp
6+
:members:
7+
:show-inheritance:
File renamed without changes.

docs/source/toc.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
:caption: Code
2323
:titlesonly:
2424

25-
main/retroarcher
26-
pyra_docs/pyra
27-
pyra_docs/config
28-
pyra_docs/definitions
29-
pyra_docs/hardware
30-
pyra_docs/helpers
31-
pyra_docs/locales
32-
pyra_docs/logger
33-
pyra_docs/threads
34-
pyra_docs/tray_icon
35-
pyra_docs/webapp
25+
src/retroarcher
26+
src/common/common
27+
src/common/config
28+
src/common/definitions
29+
src/common/hardware
30+
src/common/helpers
31+
src/common/locales
32+
src/common/logger
33+
src/common/threads
34+
src/common/tray_icon
35+
src/common/webapp

scripts/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def build():
1515
"""Sets arguments for pyinstaller, creates spec, and builds binaries."""
1616
pyinstaller_args = [
17-
'retroarcher.py',
17+
'./src/retroarcher.py',
1818
'--onefile',
1919
'--noconfirm',
2020
'--paths=./',

src/__init__.py

Whitespace-only changes.

pyra/__init__.py renamed to src/common/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
from typing import Union
1616

1717
# local imports
18-
from pyra import config
19-
from pyra import definitions
20-
from pyra import helpers
21-
from pyra import logger
18+
from common import config
19+
from common import definitions
20+
from common import helpers
21+
from common import logger
2222

2323
# get logger
2424
log = logger.get_logger(name=__name__)
@@ -121,7 +121,7 @@ def stop(exit_code: Union[int, str] = 0, restart: bool = False):
121121
>>> stop(exit_code=0, restart=False)
122122
"""
123123
# stop the tray icon
124-
from pyra.tray_icon import tray_end
124+
from common.tray_icon import tray_end
125125
try:
126126
tray_end()
127127
except AttributeError:

pyra/config.py renamed to src/common/config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from validate import Validator, ValidateError
1414

1515
# local imports
16-
from pyra import definitions
17-
from pyra import logger
18-
from pyra import locales
16+
from common import definitions
17+
from common import logger
18+
from common import locales
1919

2020
# get log
2121
log = logger.get_logger(name=__name__)
@@ -47,14 +47,14 @@ def on_change_tray_toggle() -> bool:
4747
4848
See Also
4949
--------
50-
pyra.tray_icon.tray_toggle : ``on_change_tray_toggle`` is an alias of this function.
50+
common.tray_icon.tray_toggle : ``on_change_tray_toggle`` is an alias of this function.
5151
5252
Examples
5353
--------
5454
>>> on_change_tray_toggle()
5555
True
5656
"""
57-
from pyra import tray_icon
57+
from common import tray_icon
5858
return tray_icon.tray_toggle()
5959

6060

pyra/definitions.py renamed to src/common/definitions.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ class Paths:
124124
125125
The purpose of this class is to ensure consistency when using these paths.
126126
127-
PYRA_DIR : str
128-
The directory containing the retroarcher python files.
127+
COMMON_DIR : str
128+
The directory containing the common python files.
129+
SRC_DIR : str
130+
The directory containing the application python files
129131
ROOT_DIR : str
130132
The root directory of the application. This is where the source files exist.
131133
DATA_DIR : str
@@ -139,11 +141,12 @@ class Paths:
139141
140142
Examples
141143
--------
142-
>>> Paths.logs
144+
>>> Paths.LOG_DIR
143145
'.../logs'
144146
"""
145-
PYRA_DIR = os.path.dirname(os.path.abspath(__file__))
146-
ROOT_DIR = os.path.dirname(PYRA_DIR)
147+
COMMON_DIR = os.path.dirname(os.path.abspath(__file__))
148+
SRC_DIR = os.path.dirname(COMMON_DIR)
149+
ROOT_DIR = os.path.dirname(SRC_DIR)
147150
DATA_DIR = ROOT_DIR
148151
BINARY_PATH = os.path.abspath(os.path.join(DATA_DIR, 'retroarcher.py'))
149152

pyra/hardware.py renamed to src/common/hardware.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
import psutil
1313

1414
# local imports
15-
from pyra import definitions
16-
from pyra import helpers
17-
from pyra import locales
18-
from pyra import logger
15+
from common import definitions
16+
from common import helpers
17+
from common import locales
18+
from common import logger
1919

2020
try:
2121
cpu_name = cpuinfo.cpu.info[0]['ProcessorNameString'].strip()
@@ -335,7 +335,7 @@ def chart_data() -> dict:
335335
336336
See Also
337337
--------
338-
pyra.webapp.callback_dashboard : A callback called by javascript to get this data.
338+
common.webapp.callback_dashboard : A callback called by javascript to get this data.
339339
340340
Examples
341341
--------
File renamed without changes.

pyra/locales.py renamed to src/common/locales.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
from babel import localedata
2828

2929
# local imports
30-
from pyra import config
31-
from pyra.definitions import Paths
32-
from pyra import logger
30+
from common import config
31+
from common.definitions import Paths
32+
from common import logger
3333

3434
default_domain = 'retroarcher'
3535
default_locale = 'en'

0 commit comments

Comments
 (0)