Skip to content

Commit

Permalink
Add ZIM file importer
Browse files Browse the repository at this point in the history
TODO: Update docs and tests
  • Loading branch information
abdnh committed Aug 22, 2022
1 parent d7c07d5 commit a2ed9f2
Show file tree
Hide file tree
Showing 23 changed files with 629 additions and 307 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ ankidata/
__pycache__/
TODO.md
samples/
src/user_files/*/
src/user_files/*/
src/vendor/
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[settings]
profile = black
skip=forms,ankidata,samples,user_files
skip=forms,ankidata,samples,user_files,vendor
5 changes: 4 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MASTER]
ignore=forms,ankidata,samples,user_files
ignore=forms,ankidata,samples,user_files,vendor
extension-pkg-whitelist=PyQt6,PyQt5

[REPORTS]
Expand All @@ -21,6 +21,9 @@ disable=
unused-wildcard-import,
too-many-arguments,
fixme,
useless-return,
too-few-public-methods,


[BASIC]
good-names =
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
.PHONY: all zip clean check check_format fix mypy pylint ankiweb test
.PHONY: all zip clean check check_format fix mypy pylint ankiweb test vendor

all: zip

zip:
python -m ankibuild --type package --install --qt all --noconsts --forms-dir forms
python -m ankibuild --type package --qt all --noconsts --forms-dir forms

ankiweb:
python -m ankibuild --type ankiweb --install --qt all --noconsts --forms-dir forms
python -m ankibuild --type ankiweb --qt all --noconsts --forms-dir forms

check: check_format mypy pylint

check_format:
python -m black --exclude="forms|ankidata|samples|user_files" --check --diff --color src tests
python -m black --exclude="forms|ankidata|samples|user_files|vendor" --check --diff --color src tests
python -m isort --check --diff --color src tests

fix:
python -m black --exclude="forms|ankidata|samples|user_files" src tests
python -m black --exclude="forms|ankidata|samples|user_files|vendor" src tests
python -m isort src tests

mypy:
Expand All @@ -27,5 +27,8 @@ pylint:
test:
python -m unittest

vendor:
./vendor.sh

clean:
rm -rf build/
46 changes: 33 additions & 13 deletions designer/form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,73 +26,93 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="2" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Word</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="4" column="1">
<widget class="QComboBox" name="wordFieldComboBox"/>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Definition</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="definitionFieldComboBox"/>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Example</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="exampleFieldComboBox"/>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Gender</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="7" column="1">
<widget class="QComboBox" name="genderFieldComboBox"/>
</item>
<item row="6" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Part of Speech</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="8" column="1">
<widget class="QComboBox" name="POSFieldComboBox"/>
</item>
<item row="7" column="1">
<item row="9" column="1">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Dictionary</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="dictionaryComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Source</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="providerComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Parser</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="parserComboBox"/>
</item>
</layout>
</item>
</layout>
Expand Down
98 changes: 51 additions & 47 deletions designer/import_dictionary.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,49 @@
<property name="windowTitle">
<string>Wiktionary - Import a dictionary</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Dictionary</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="chooseFileButton">
<property name="text">
<string>Choose file</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="dictionaryComboBox"/>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Dictionary file</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Dictionary name</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="dictionaryNameLineEdit"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="description">
<property name="text">
<string>Description</string>
Expand All @@ -27,51 +68,14 @@
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Dictionary file</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="chooseFileButton">
<property name="text">
<string>Choose file</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Dictionary name</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="dictionaryNameLineEdit"/>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="filenameLabel">
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
<item row="6" column="0">
<widget class="QLabel" name="filenameLabel">
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
Expand Down
11 changes: 9 additions & 2 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ no_strict_optional = true
show_error_codes = true
check_untyped_defs = True
disallow_untyped_defs = True
exclude = forms|ankidata|samples|user_files
exclude = forms|ankidata|samples|user_files|vendor

[mypy-src.forms.*]
ignore_errors = True
ignore_errors = True

[mypy-zimply_core.*]
ignore_missing_imports = True

[mypy-bs4.*]
ignore_missing_imports = True

3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ black==22.6.0
pylint==2.14.4
isort==5.10.1
ankibuild
git+https://github.com/abdnh/ankibuild@54a837d942859aaa9512ffe7b27b483959d75d64#egg=ankibuild[qt5,qt6]
git+https://github.com/abdnh/ankibuild@54a837d942859aaa9512ffe7b27b483959d75d64#egg=ankibuild[qt5,qt6]
zimply-core==1.0.7
3 changes: 3 additions & 0 deletions src/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
ADDON_DIR = Path(__file__).resolve().parent
ICONS_DIR = ADDON_DIR / "icons"
USER_FILES = ADDON_DIR / "user_files"
VERSION = "0.2"
ANKIWEB_ID = "2087444887"
VER_CONF_KEY = f"wiktionary_{ANKIWEB_ID}_version"
Loading

0 comments on commit a2ed9f2

Please sign in to comment.