Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor #51

Merged
merged 6 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ theme:
name: material
logo: images/logo.png
favicon: images/favicon.ico
font:
text: Arimo # Google font, replaces the default Arial
features:
- content.code.annotate
- content.code.copy # Copy button on top right of code blocks
- navigation.expand # Expand navigation menus by default
# - navigation.tabs # Enable tabs on top https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#navigation-tabs
palette:
- media: "(prefers-color-scheme: light"
scheme: default
Expand All @@ -23,19 +28,24 @@ theme:

markdown_extensions:
- abbr
- admonition
- pymdownx.details
- admonition # Info boxes
- pymdownx.details # Info boxes
- pymdownx.highlight
- pymdownx.superfences
- pymdownx.superfences # Info boxes, tabs
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji # https://emojipedia.org/twitter/
emoji_generator: !!python/name:materialx.emoji.to_svg
- tables
emoji_index: !!python/name:material.extensions.emoji.twemoji # https://emojipedia.org/twitter/
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- tables # Create tables in Markdown by using a simple syntax
- mdx_truly_sane_lists # 2-space indented nested lists
- attr_list # More functionality for images (align, lazy load, etc.)
- md_in_html # MD/HTML interop. Also helps with images (caption, center alignment)

plugins:
- search
- search # Search box at the top
- glightbox # Image lightbox (for zooming). Requires `mkdocs-glightbox` package

dev_addr: 127.0.0.1:7000
dev_addr: 127.0.0.1:7007 # Default 8000 may compete with other frameworks

site_url: https://github.com/joaonc/hd_active
repo_url: https://github.com/joaonc/hd_active
copyright: Copyright © 2024 Joao Coelho
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ target-version = ['py311']
skip-string-normalization = true
extend-exclude='''
(
app/ui/forms
src/hd_active/ui/forms
| \.venv.*
| \venv.*
)
'''

[tool.isort]
extend_skip = ['app/ui/forms']
known_first_party = 'app'
extend_skip = ['src/hd_active/ui/forms']
profile = 'black'
sections = 'FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER'
skip_glob = ['**/.venv*', '**/venv*', '/build']
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configuration for tools that don't support `pyproject.toml`.

[flake8]
exclude = .git,.github,.venv*,venv*,__pycache__,assets,app/ui/forms,docs,site
exclude = .git,.github,.venv*,venv*,__pycache__,assets,src/hd_active/ui/forms,docs,site
max-line-length = 100

# Errors being ignored:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions app/hd_active.py → src/hd_active/hd_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing import Deque, Iterable, Optional, Set, Union

from app.hd_action_state import HdActionState
from src.hd_active.hd_action_state import HdActionState

FILE_NAME = '_hd_active.txt'
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -148,7 +148,7 @@ def change_state(self) -> HdActionState:
import argparse
import sys

from app.hd_active_config import HdActiveConfig
from src.hd_active.hd_active_config import HdActiveConfig

parser = argparse.ArgumentParser(description='Keep HDs active.')
parser.add_argument(
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/main.py → src/hd_active/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from PySide6 import QtGui, QtWidgets

from app.ui.system_tray_icon import SystemTrayIcon
from app.utils import get_asset
from src.hd_active.ui.system_tray_icon import SystemTrayIcon
from src.hd_active.utils import get_asset


def main():
Expand Down
File renamed without changes.
Empty file.
11 changes: 9 additions & 2 deletions app/ui/forms/log_ui.py → src/hd_active/ui/forms/log_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
QPoint,
QRect,
QSize,
Qt,
QTime,
QUrl,
Qt,
)
from PySide6.QtGui import (
QBrush,
Expand All @@ -40,7 +40,14 @@
QRadialGradient,
QTransform,
)
from PySide6.QtWidgets import QApplication, QDialog, QPushButton, QSizePolicy, QTextBrowser, QWidget
from PySide6.QtWidgets import (
QApplication,
QDialog,
QPushButton,
QSizePolicy,
QTextBrowser,
QWidget,
)


class Ui_LogDialog(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
QPoint,
QRect,
QSize,
Qt,
QTime,
QUrl,
Qt,
)
from PySide6.QtGui import (
QBrush,
Expand Down
4 changes: 2 additions & 2 deletions app/ui/log_dialog.py → src/hd_active/ui/log_dialog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PySide6 import QtGui, QtWidgets

from app.hd_active import HdActive
from app.ui.forms.log_ui import Ui_LogDialog
from src.hd_active.hd_active import HdActive
from src.hd_active.ui.forms.log_ui import Ui_LogDialog


class LogDialog(QtWidgets.QDialog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from PySide6 import QtGui, QtWidgets

from app.hd_active import HdActive
from app.ui.forms.settings_ui import Ui_Dialog
from app.ui.log_dialog import LogDialog
from app.utils import get_asset
from src.hd_active.hd_active import HdActive
from src.hd_active.ui.forms.settings_ui import Ui_Dialog
from src.hd_active.ui.log_dialog import LogDialog
from src.hd_active.utils import get_asset


class SettingsDialog(QtWidgets.QDialog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from PySide6 import QtWidgets

from app.hd_active import HdActive
from app.hd_active_config import HdActiveConfig
from app.ui.settings_dialog import SettingsDialog
from app.utils import is_truthy
from src.hd_active.hd_active import HdActive
from src.hd_active.hd_active_config import HdActiveConfig
from src.hd_active.ui.settings_dialog import SettingsDialog
from src.hd_active.utils import is_truthy

HD_ACTION_DEBUG = is_truthy(os.getenv('HD_ACTION_DEBUG', 'True'))
"""
Expand Down
2 changes: 1 addition & 1 deletion app/utils.py → src/hd_active/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from typing import Any

PROJECT_ROOT = Path(__file__).parents[1].resolve()
PROJECT_ROOT = Path(__file__).parents[2].resolve()
ASSETS_ROOT = PROJECT_ROOT / 'assets'


Expand Down
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from invoke import Collection, Exit, task

from app.utils import get_asset
from src.hd_active.utils import get_asset

os.environ.setdefault('INVOKE_RUN_ECHO', '1') # Show commands by default

Expand Down Expand Up @@ -94,7 +94,7 @@ def ui_py(c, file=None):
f'File "{file}" not found. Available files: ", ".join(p.stem for p in UI_FILES)'
)

py_file_path = PROJECT_ROOT / 'app/ui/forms' / f'{file_stem}_ui.py'
py_file_path = PROJECT_ROOT / 'src/hd_activehd_active/ui/forms' / f'{file_stem}_ui.py'

c.run(f'pyside6-uic {ui_file_path} -o {py_file_path}')

Expand Down
6 changes: 3 additions & 3 deletions tests/test_hd_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import pytest

from app.hd_action_state import HdActionState
from app.hd_active import HdActive
from src.hd_active.hd_action_state import HdActionState
from src.hd_active.hd_active import HdActive

WAIT = 0.1
WAIT_TEST = 2 * WAIT
Expand All @@ -22,7 +22,7 @@ def __init__(self, drive_paths=None, run=False, wait=WAIT):
super().__init__(drive_paths, run, wait=wait)


@patch('app.hd_active.HdActive._write_hd', return_value=1000)
@patch('src.hd_active.hd_active.HdActive._write_hd', return_value=1000)
class TestHdActive:
def test_instantiate_not_started(self, mock_write_hd):
hd_active = HdActiveTest(drive_paths=['z'], run=False)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_hd_active_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from app.hd_active_config import HdActiveConfig
from src.hd_active.hd_active_config import HdActiveConfig


@pytest.fixture
Expand All @@ -19,7 +19,7 @@ def config_file(request, tmp_path) -> Tuple[str, List[str]]:
return str(file), request.param[1]


@patch('app.hd_active_config.configparser.ConfigParser.read')
@patch('src.hd_active.hd_active_config.configparser.ConfigParser.read')
def test_defaults(read_mock):
"""
Skip reading file (so defaults are not overwritten) and verify defaults.
Expand Down
10 changes: 9 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import pytest

from app.utils import get_asset, is_truthy
from src.hd_active.utils import get_asset, is_truthy, PROJECT_ROOT, ASSETS_ROOT


class TestGlobals:
def test_project_root(self):
assert PROJECT_ROOT.name == 'hd_active'

def test_assets_root(self):
assert ASSETS_ROOT.name == 'assets'


class TestGetAsset:
Expand Down