Skip to content

Commit

Permalink
Update from add-on template
Browse files Browse the repository at this point in the history
  • Loading branch information
abdnh committed Sep 21, 2023
1 parent e6d955d commit a52380c
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__pycache__/
__pycache__/
*.egg-info/
venv/
.mypy_cache/
Expand Down
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -24,5 +24,8 @@ pylint:
test:
python -m pytest --cov=src --cov-config=.coveragerc

sourcedist:
python -m ankiscripts.sourcedist

clean:
rm -rf build/
6 changes: 3 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build==1.0.0
build==1.0.3
# via pip-tools
click==8.1.7
# via pip-tools
Expand All @@ -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
1 change: 1 addition & 0 deletions requirements/bundle.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ankiutils @ git+https://github.com/abdnh/ankiutils@c699f193f35dcd5d8995ddc78b22d03642927018
2 changes: 2 additions & 0 deletions requirements/bundle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ankiutils @ git+https://github.com/abdnh/ankiutils@c699f193f35dcd5d8995ddc78b22d03642927018
# via -r requirements/bundle.in
2 changes: 1 addition & 1 deletion requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 21 additions & 20 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -47,15 +49,15 @@ 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
# aqt
# 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -148,21 +150,21 @@ 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
# -r requirements/dev.in
# aqt
pyyaml==6.0.1
# via pre-commit
questionary==2.0.0
questionary==2.0.1
# via ankiscripts
referencing==0.30.2
# via
Expand All @@ -172,7 +174,7 @@ requests==2.31.0
# via
# anki
# aqt
rpds-py==0.10.0
rpds-py==0.10.3
# via
# jsonschema
# referencing
Expand All @@ -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
Expand All @@ -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
13 changes: 9 additions & 4 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import sys
from concurrent.futures import Future
from textwrap import dedent
from typing import Optional
Expand All @@ -7,19 +9,22 @@
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:
mw.progress.start(
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)
Expand All @@ -39,7 +44,7 @@ def on_done(fut: Future) -> None:
"""
),
parent=mw,
title="AnkiApp Importer",
title=consts.name,
textFormat="rich",
)
return
Expand All @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ankiutils.config import Config

config = Config(__name__)
3 changes: 3 additions & 0 deletions src/consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ankiutils.consts import get_consts

consts = get_consts(__name__)

0 comments on commit a52380c

Please sign in to comment.