diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-10 10:07:17 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-10 10:07:17 +0000 |
| commit | b9fea91226116fccbf771bc53d4e5a319367c570 (patch) | |
| tree | 80e853760ff48282801de3cc360789f4191c36ba /python-ankitools.spec | |
| parent | c1183e3e476e137acd8444ac493b605deb2f1b0d (diff) | |
automatic import of python-ankitools
Diffstat (limited to 'python-ankitools.spec')
| -rw-r--r-- | python-ankitools.spec | 411 |
1 files changed, 411 insertions, 0 deletions
diff --git a/python-ankitools.spec b/python-ankitools.spec new file mode 100644 index 0000000..0c4d7ed --- /dev/null +++ b/python-ankitools.spec @@ -0,0 +1,411 @@ +%global _empty_manifest_terminate_build 0 +Name: python-AnkiTools +Version: 0.3.7 +Release: 1 +Summary: an Anki *.apkg and collection.anki2 reader and editor +License: MIT +URL: https://github.com/patarapolw/AnkiTools +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/2d/48/b01de3fbbff3957d799598e2e882ed757e6978c48d09de739443b35885b2/AnkiTools-0.3.7.tar.gz +BuildArch: noarch + +Requires: python3-requests +Requires: python3-bs4 +Requires: python3-appdirs +Requires: python3-openpyxl +Requires: python3-psutil +Requires: python3-pyexcel-xlsx + +%description +# AnkiTools + +[](https://travis-ci.org/patarapolw/AnkiTools) +[](https://pypi.python.org/pypi/AnkiTools/) +[](https://pypi.python.org/pypi/AnkiTools/) +[](https://pypi.python.org/pypi/AnkiTools/) + +An Anki *.apkg and collection.anki2 reader and editor to work with in Python. Also included a module on [AnkiConnect](https://github.com/FooSoft/anki-connect). + +I also created a new sync system called AnkiDirect. + +The \*.apkg format specification can be viewed from [Anki decks collaboration Wiki](http://decks.wikia.com/wiki/Anki_APKG_format_documentation) and [AnkiDroid](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure). In my AnkiDirect, I tried to comply with the format specification as much as possible. + +## Installation + +```commandline +pip install AnkiTools +``` + +## Featured modules + +### Anki file conversion + +```pydocstring +>>> from AnkiTools import anki_convert +>>> anki_convert('Chinese.apkg', out_file='Chinese_anki.xlsx') +>>> anki_convert('my_workbook.xlsx', out_format='.apkg') +``` + +The supported formats are `.xlsx`, `.apkg` and `.anki2`. + +### AnkiDirect API + +You can directly edit the Anki app data in user's Application Data path. + +```python +from AnkiTools import AnkiDirect +import json + +with open('payload.json') as f: + payload = json.load(f) +with AnkiDirect() as api + api.add(payload) +``` + +Some supported payloads include: + +```json +{ + "data": { + "note_type A": [ + { + "data": { + "header A": "a", + "header B": "b" + }, + "decks": { + "Forward": "Test Deck::Forward", + "Backward": "Test Deck::Backward" + } + } + ] + }, + "definitions": { + "note_type A": { + "templates": [ + { + "name": "Forward", + "data": { + "qfmt": "{{header A}}", + "afmt": "{{FrontSide}}\r\n\r\n<hr id=answer>\r\n\r\n{{header B}}" + } + }, + { + "name": "Backward", + "data": { + "qfmt": "{{header B}}", + "afmt": "{{FrontSide}}\r\n\r\n<hr id=answer>\r\n\r\n{{header A}}" + } + } + ], + "css": ".card {\r\n font-family: arial;\r\n font-size: 20px;\r\n text-align: center;\r\n color: black;\r\n background-color: white;\r\n}\r\n" + } + } +} +``` + +### AnkiConnect + +```pydocstring +>>> from AnkiTools import AnkiConnect +>>> AnkiConnect.is_online() +True +>>> params = {'actions': [{'action': 'deckNames'}, {'action': 'browse', 'params': {'query': 'deck:current'}}]} +>>> AnkiConnect.post('multi', params=params) +{'result': [['Default', 'SpoonFed', 'Chinese Hanzi Freq', 'Chinese Vocab'], None], 'error': None} +``` +The actual addable actions and parameters can be viewed from [AnkiConnect](https://foosoft.net/projects/anki-connect/). + +## Plans + +- AnkiDirect two-way sync between Excel file and the Anki app. +- Specifying metadata (e.g. card distribution, decks) in the Excel file and make it convertible and syncable. +- Add CRUD to `AnkiDirect` ("update" and "remove" pending.) + +## Contributions + +- Testing on other OS's, e.g. Windows XP, Windows 10, Ubuntu Linux. (I tested on Mac.) +- Manual testing of whether the generated `*.apkg` can be opened without subsequent errors in the Anki app. +- Writing test cases and testing parameters. The current ones are viewable at [/tests/parameters.json](https://github.com/patarapolw/AnkiTools/blob/master/tests/parameters.json) and [/tests/files/](https://github.com/patarapolw/AnkiTools/tree/master/tests/files). +- Specifying challenging payloads for AnkiDirect. + + +%package -n python3-AnkiTools +Summary: an Anki *.apkg and collection.anki2 reader and editor +Provides: python-AnkiTools +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-AnkiTools +# AnkiTools + +[](https://travis-ci.org/patarapolw/AnkiTools) +[](https://pypi.python.org/pypi/AnkiTools/) +[](https://pypi.python.org/pypi/AnkiTools/) +[](https://pypi.python.org/pypi/AnkiTools/) + +An Anki *.apkg and collection.anki2 reader and editor to work with in Python. Also included a module on [AnkiConnect](https://github.com/FooSoft/anki-connect). + +I also created a new sync system called AnkiDirect. + +The \*.apkg format specification can be viewed from [Anki decks collaboration Wiki](http://decks.wikia.com/wiki/Anki_APKG_format_documentation) and [AnkiDroid](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure). In my AnkiDirect, I tried to comply with the format specification as much as possible. + +## Installation + +```commandline +pip install AnkiTools +``` + +## Featured modules + +### Anki file conversion + +```pydocstring +>>> from AnkiTools import anki_convert +>>> anki_convert('Chinese.apkg', out_file='Chinese_anki.xlsx') +>>> anki_convert('my_workbook.xlsx', out_format='.apkg') +``` + +The supported formats are `.xlsx`, `.apkg` and `.anki2`. + +### AnkiDirect API + +You can directly edit the Anki app data in user's Application Data path. + +```python +from AnkiTools import AnkiDirect +import json + +with open('payload.json') as f: + payload = json.load(f) +with AnkiDirect() as api + api.add(payload) +``` + +Some supported payloads include: + +```json +{ + "data": { + "note_type A": [ + { + "data": { + "header A": "a", + "header B": "b" + }, + "decks": { + "Forward": "Test Deck::Forward", + "Backward": "Test Deck::Backward" + } + } + ] + }, + "definitions": { + "note_type A": { + "templates": [ + { + "name": "Forward", + "data": { + "qfmt": "{{header A}}", + "afmt": "{{FrontSide}}\r\n\r\n<hr id=answer>\r\n\r\n{{header B}}" + } + }, + { + "name": "Backward", + "data": { + "qfmt": "{{header B}}", + "afmt": "{{FrontSide}}\r\n\r\n<hr id=answer>\r\n\r\n{{header A}}" + } + } + ], + "css": ".card {\r\n font-family: arial;\r\n font-size: 20px;\r\n text-align: center;\r\n color: black;\r\n background-color: white;\r\n}\r\n" + } + } +} +``` + +### AnkiConnect + +```pydocstring +>>> from AnkiTools import AnkiConnect +>>> AnkiConnect.is_online() +True +>>> params = {'actions': [{'action': 'deckNames'}, {'action': 'browse', 'params': {'query': 'deck:current'}}]} +>>> AnkiConnect.post('multi', params=params) +{'result': [['Default', 'SpoonFed', 'Chinese Hanzi Freq', 'Chinese Vocab'], None], 'error': None} +``` +The actual addable actions and parameters can be viewed from [AnkiConnect](https://foosoft.net/projects/anki-connect/). + +## Plans + +- AnkiDirect two-way sync between Excel file and the Anki app. +- Specifying metadata (e.g. card distribution, decks) in the Excel file and make it convertible and syncable. +- Add CRUD to `AnkiDirect` ("update" and "remove" pending.) + +## Contributions + +- Testing on other OS's, e.g. Windows XP, Windows 10, Ubuntu Linux. (I tested on Mac.) +- Manual testing of whether the generated `*.apkg` can be opened without subsequent errors in the Anki app. +- Writing test cases and testing parameters. The current ones are viewable at [/tests/parameters.json](https://github.com/patarapolw/AnkiTools/blob/master/tests/parameters.json) and [/tests/files/](https://github.com/patarapolw/AnkiTools/tree/master/tests/files). +- Specifying challenging payloads for AnkiDirect. + + +%package help +Summary: Development documents and examples for AnkiTools +Provides: python3-AnkiTools-doc +%description help +# AnkiTools + +[](https://travis-ci.org/patarapolw/AnkiTools) +[](https://pypi.python.org/pypi/AnkiTools/) +[](https://pypi.python.org/pypi/AnkiTools/) +[](https://pypi.python.org/pypi/AnkiTools/) + +An Anki *.apkg and collection.anki2 reader and editor to work with in Python. Also included a module on [AnkiConnect](https://github.com/FooSoft/anki-connect). + +I also created a new sync system called AnkiDirect. + +The \*.apkg format specification can be viewed from [Anki decks collaboration Wiki](http://decks.wikia.com/wiki/Anki_APKG_format_documentation) and [AnkiDroid](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure). In my AnkiDirect, I tried to comply with the format specification as much as possible. + +## Installation + +```commandline +pip install AnkiTools +``` + +## Featured modules + +### Anki file conversion + +```pydocstring +>>> from AnkiTools import anki_convert +>>> anki_convert('Chinese.apkg', out_file='Chinese_anki.xlsx') +>>> anki_convert('my_workbook.xlsx', out_format='.apkg') +``` + +The supported formats are `.xlsx`, `.apkg` and `.anki2`. + +### AnkiDirect API + +You can directly edit the Anki app data in user's Application Data path. + +```python +from AnkiTools import AnkiDirect +import json + +with open('payload.json') as f: + payload = json.load(f) +with AnkiDirect() as api + api.add(payload) +``` + +Some supported payloads include: + +```json +{ + "data": { + "note_type A": [ + { + "data": { + "header A": "a", + "header B": "b" + }, + "decks": { + "Forward": "Test Deck::Forward", + "Backward": "Test Deck::Backward" + } + } + ] + }, + "definitions": { + "note_type A": { + "templates": [ + { + "name": "Forward", + "data": { + "qfmt": "{{header A}}", + "afmt": "{{FrontSide}}\r\n\r\n<hr id=answer>\r\n\r\n{{header B}}" + } + }, + { + "name": "Backward", + "data": { + "qfmt": "{{header B}}", + "afmt": "{{FrontSide}}\r\n\r\n<hr id=answer>\r\n\r\n{{header A}}" + } + } + ], + "css": ".card {\r\n font-family: arial;\r\n font-size: 20px;\r\n text-align: center;\r\n color: black;\r\n background-color: white;\r\n}\r\n" + } + } +} +``` + +### AnkiConnect + +```pydocstring +>>> from AnkiTools import AnkiConnect +>>> AnkiConnect.is_online() +True +>>> params = {'actions': [{'action': 'deckNames'}, {'action': 'browse', 'params': {'query': 'deck:current'}}]} +>>> AnkiConnect.post('multi', params=params) +{'result': [['Default', 'SpoonFed', 'Chinese Hanzi Freq', 'Chinese Vocab'], None], 'error': None} +``` +The actual addable actions and parameters can be viewed from [AnkiConnect](https://foosoft.net/projects/anki-connect/). + +## Plans + +- AnkiDirect two-way sync between Excel file and the Anki app. +- Specifying metadata (e.g. card distribution, decks) in the Excel file and make it convertible and syncable. +- Add CRUD to `AnkiDirect` ("update" and "remove" pending.) + +## Contributions + +- Testing on other OS's, e.g. Windows XP, Windows 10, Ubuntu Linux. (I tested on Mac.) +- Manual testing of whether the generated `*.apkg` can be opened without subsequent errors in the Anki app. +- Writing test cases and testing parameters. The current ones are viewable at [/tests/parameters.json](https://github.com/patarapolw/AnkiTools/blob/master/tests/parameters.json) and [/tests/files/](https://github.com/patarapolw/AnkiTools/tree/master/tests/files). +- Specifying challenging payloads for AnkiDirect. + + +%prep +%autosetup -n AnkiTools-0.3.7 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-AnkiTools -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.3.7-1 +- Package Spec generated |
