{ "info": { "author": "Pacharapol Withayasakpunt", "author_email": "patarapolw@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# AnkiTools\n\n[](https://travis-ci.org/patarapolw/AnkiTools)\n[](https://pypi.python.org/pypi/AnkiTools/)\n[](https://pypi.python.org/pypi/AnkiTools/)\n[](https://pypi.python.org/pypi/AnkiTools/)\n\nAn 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).\n\nI also created a new sync system called AnkiDirect.\n\nThe \\*.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.\n\n## Installation\n\n```commandline\npip install AnkiTools\n```\n\n## Featured modules\n\n### Anki file conversion\n\n```pydocstring\n>>> from AnkiTools import anki_convert\n>>> anki_convert('Chinese.apkg', out_file='Chinese_anki.xlsx')\n>>> anki_convert('my_workbook.xlsx', out_format='.apkg')\n```\n\nThe supported formats are `.xlsx`, `.apkg` and `.anki2`.\n\n### AnkiDirect API\n\nYou can directly edit the Anki app data in user's Application Data path.\n\n```python\nfrom AnkiTools import AnkiDirect\nimport json\n\nwith open('payload.json') as f:\n payload = json.load(f)\nwith AnkiDirect() as api\n api.add(payload)\n```\n\nSome supported payloads include:\n\n```json\n{\n \"data\": {\n \"note_type A\": [\n {\n \"data\": {\n \"header A\": \"a\",\n \"header B\": \"b\"\n },\n \"decks\": {\n \"Forward\": \"Test Deck::Forward\",\n \"Backward\": \"Test Deck::Backward\"\n }\n }\n ]\n },\n \"definitions\": {\n \"note_type A\": {\n \"templates\": [\n {\n \"name\": \"Forward\",\n \"data\": {\n \"qfmt\": \"{{header A}}\",\n \"afmt\": \"{{FrontSide}}\\r\\n\\r\\n