diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index cb9c483..d9aff64 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -27,7 +27,7 @@ jobs: run: .github/workflows/install_deps.sh - name: Create packages - run: make + run: make vendor && make - name: Extract changes shell: bash diff --git a/.gitignore b/.gitignore index e84052f..578792f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ - __pycache__/ +__pycache__/ *.egg-info/ venv/ .mypy_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 51872fd..1cb7739 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,9 +9,6 @@ repos: - id: end-of-file-fixer - id: check-json exclude: ".vscode(.dist)?/.*" - - id: pretty-format-json - args: ["--autofix", "--indent", "4", "--no-ensure-ascii"] - exclude: ".vscode.dist/launch.json" - id: check-yaml - id: check-builtin-literals - id: check-case-conflict diff --git a/Makefile b/Makefile index f499f5e..60f3ae7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all zip ankiweb vendor fix mypy pylint test clean +.PHONY: all zip ankiweb vendor fix mypy pylint test sourcedist clean all: zip ankiweb @@ -24,5 +24,8 @@ pylint: test: python -m pytest --cov=src --cov-config=.coveragerc +sourcedist: + python -m ankiscripts.sourcedist + clean: rm -rf build/ diff --git a/requirements/base.txt b/requirements/base.txt index 9b79149..96b4f94 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,4 +1,4 @@ -build==1.0.0 +build==1.0.3 # via pip-tools click==8.1.7 # via pip-tools @@ -21,11 +21,11 @@ tomli==2.0.1 # pyproject-hooks wheel==0.41.2 # via pip-tools -zipp==3.16.2 +zipp==3.17.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: pip==23.2.1 # via pip-tools -setuptools==68.1.2 +setuptools==68.2.2 # via pip-tools diff --git a/requirements/bundle.in b/requirements/bundle.in index e69de29..b2e3711 100644 --- a/requirements/bundle.in +++ b/requirements/bundle.in @@ -0,0 +1 @@ +ankiutils @ git+https://github.com/abdnh/ankiutils@c699f193f35dcd5d8995ddc78b22d03642927018 diff --git a/requirements/bundle.txt b/requirements/bundle.txt index e69de29..9b91a8e 100644 --- a/requirements/bundle.txt +++ b/requirements/bundle.txt @@ -0,0 +1,2 @@ +ankiutils @ git+https://github.com/abdnh/ankiutils@c699f193f35dcd5d8995ddc78b22d03642927018 + # via -r requirements/bundle.in diff --git a/requirements/dev.in b/requirements/dev.in index 3026ed3..43a1911 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -12,5 +12,5 @@ pyupgrade pytest pytest-cov pre-commit -ankiscripts[forms] @ https://github.com/abdnh/ankiscripts/archive/ec166df11d726172e6e633a6bd0ddeb4f624e63d.zip +ankiscripts[forms] @ git+https://github.com/abdnh/ankiscripts@1523f27088ff88cd0bca9cfb2ec9617eddc5e1e2 types-requests diff --git a/requirements/dev.txt b/requirements/dev.txt index e949b59..80c5cd8 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,7 +1,9 @@ anki==2.1.66 # via aqt -ankiscripts @ https://github.com/abdnh/ankiscripts/archive/ec166df11d726172e6e633a6bd0ddeb4f624e63d.zip +ankiscripts @ git+https://github.com/abdnh/ankiscripts@1523f27088ff88cd0bca9cfb2ec9617eddc5e1e2 # via -r requirements/dev.in +ankiutils @ git+https://github.com/abdnh/ankiutils@c699f193f35dcd5d8995ddc78b22d03642927018 + # via -r requirements\bundle.in aqt==2.1.66 # via -r requirements/dev.in astroid==2.15.6 @@ -14,11 +16,11 @@ beautifulsoup4==4.12.2 # via # anki # aqt -black==23.7.0 +black==23.9.1 # via -r requirements/dev.in blinker==1.6.2 # via flask -build==1.0.0 +build==1.0.3 # via pip-tools certifi==2023.7.22 # via requests @@ -37,7 +39,7 @@ colorama==0.4.6 # click # pylint # pytest -coverage==7.3.0 +coverage==7.3.1 # via pytest-cov decorator==5.1.1 # via anki @@ -47,7 +49,7 @@ distlib==0.3.7 # via virtualenv exceptiongroup==1.1.3 # via pytest -filelock==3.12.3 +filelock==3.12.4 # via virtualenv flask==2.3.3 # via @@ -55,7 +57,7 @@ flask==2.3.3 # flask-cors flask-cors==4.0.0 # via aqt -identify==2.5.27 +identify==2.5.29 # via pre-commit idna==3.4 # via requests @@ -74,7 +76,7 @@ itsdangerous==2.1.2 # via flask jinja2==3.1.2 # via flask -jsonschema==4.19.0 +jsonschema==4.19.1 # via # ankiscripts # aqt @@ -98,7 +100,7 @@ mypy-extensions==1.0.0 # mypy nodeenv==1.8.0 # via pre-commit -orjson==3.9.5 +orjson==3.9.7 # via anki packaging==23.1 # via @@ -120,7 +122,7 @@ pre-commit==3.4.0 # via -r requirements/dev.in prompt-toolkit==3.0.36 # via questionary -protobuf==4.24.2 +protobuf==4.24.3 # via anki psutil==5.9.5 ; sys_platform == "win32" # via @@ -148,13 +150,13 @@ pyqt6-webengine-qt6==6.5.2 # via pyqt6-webengine pysocks==1.7.1 # via requests -pytest==7.4.1 +pytest==7.4.2 # via # -r requirements/dev.in # pytest-cov pytest-cov==4.1.0 # via -r requirements/dev.in -pyupgrade==3.10.1 +pyupgrade==3.11.2 # via -r requirements/dev.in pywin32==306 ; sys_platform == "win32" # via @@ -162,7 +164,7 @@ pywin32==306 ; sys_platform == "win32" # aqt pyyaml==6.0.1 # via pre-commit -questionary==2.0.0 +questionary==2.0.1 # via ankiscripts referencing==0.30.2 # via @@ -172,7 +174,7 @@ requests==2.31.0 # via # anki # aqt -rpds-py==0.10.0 +rpds-py==0.10.3 # via # jsonschema # referencing @@ -194,20 +196,19 @@ tomli==2.0.1 # pytest tomlkit==0.12.1 # via pylint -types-requests==2.31.0.2 +types-requests==2.31.0.3 # via -r requirements/dev.in types-urllib3==1.26.25.14 # via types-requests -typing-extensions==4.7.1 +typing-extensions==4.8.0 # via # astroid # black - # filelock # mypy # pylint -urllib3==2.0.4 +urllib3==2.0.5 # via requests -virtualenv==20.24.4 +virtualenv==20.24.5 # via pre-commit waitress==2.1.2 # via aqt @@ -219,13 +220,13 @@ wheel==0.41.2 # via pip-tools wrapt==1.15.0 # via astroid -zipp==3.16.2 +zipp==3.17.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: pip==23.2.1 # via pip-tools -setuptools==68.1.2 +setuptools==68.2.2 # via # nodeenv # pip-tools diff --git a/src/__init__.py b/src/__init__.py index 3fe4b84..f7785d5 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,3 +1,5 @@ +import os +import sys from concurrent.futures import Future from textwrap import dedent from typing import Optional @@ -7,11 +9,14 @@ from aqt.qt import QAction, qconnect from aqt.utils import getFile, showText, showWarning, tooltip +sys.path.append(os.path.join(os.path.dirname(__file__), "vendor")) + from .ankiapp_importer import ( AnkiAppImporter, AnkiAppImporterCanceledException, AnkiAppImporterException, ) +from .consts import consts def import_from_ankiapp(filename: str) -> None: @@ -19,7 +24,7 @@ def import_from_ankiapp(filename: str) -> None: label="Extracting collection from AnkiApp database...", immediate=True, ) - mw.progress.set_title("AnkiApp Importer") + mw.progress.set_title(consts.name) def start_importing() -> Optional[tuple[int, set[str]]]: importer = AnkiAppImporter(mw, filename) @@ -39,7 +44,7 @@ def on_done(fut: Future) -> None: """ ), parent=mw, - title="AnkiApp Importer", + title=consts.name, textFormat="rich", ) return @@ -50,13 +55,13 @@ def on_done(fut: Future) -> None: if warnings: showText( "The following issues were found:\n" + "\n".join(warnings), - title="AnkiApp Importer", + title=consts.name, ) mw.reset() except AnkiAppImporterCanceledException: tooltip("Canceled") except AnkiAppImporterException as exc: - showWarning(str(exc), parent=mw, title="AnkiApp Importer") + showWarning(str(exc), parent=mw, title=consts.name) mw.taskman.run_in_background(start_importing, on_done) diff --git a/src/config.py b/src/config.py new file mode 100644 index 0000000..b67eae6 --- /dev/null +++ b/src/config.py @@ -0,0 +1,3 @@ +from ankiutils.config import Config + +config = Config(__name__) diff --git a/src/consts.py b/src/consts.py new file mode 100644 index 0000000..3f39436 --- /dev/null +++ b/src/consts.py @@ -0,0 +1,3 @@ +from ankiutils.consts import get_consts + +consts = get_consts(__name__)