2021-11-27 11:54:42 +00:00
|
|
|
# Copyright: Ren Tatsumoto <tatsu at autistici.org>
|
|
|
|
# License: GNU GPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2021-04-20 10:31:51 +00:00
|
|
|
import sys
|
2021-04-20 11:14:09 +00:00
|
|
|
from urllib.error import URLError
|
|
|
|
|
2021-11-27 11:54:42 +00:00
|
|
|
from .common import ANTPError
|
|
|
|
from .exporter import export_note_type
|
|
|
|
from .importer import import_note_type
|
2021-04-20 10:31:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-12-25 19:51:39 +00:00
|
|
|
if len(sys.argv) < 2:
|
|
|
|
return print(
|
|
|
|
"No action provided.\n\n"
|
|
|
|
f"import\tAdd one of the available note types to Anki.\n"
|
|
|
|
f"export\tSave your note type as a template.\n"
|
|
|
|
)
|
|
|
|
|
2021-04-20 10:31:51 +00:00
|
|
|
try:
|
2021-12-25 19:51:39 +00:00
|
|
|
match sys.argv[1]:
|
|
|
|
case 'export':
|
|
|
|
export_note_type()
|
|
|
|
case 'import':
|
|
|
|
import_note_type()
|
2021-04-20 10:31:51 +00:00
|
|
|
except URLError:
|
|
|
|
print("Couldn't connect. Make sure Anki is open and AnkiConnect is installed.")
|
2021-11-27 11:54:42 +00:00
|
|
|
except ANTPError as ex:
|
2021-04-20 10:31:51 +00:00
|
|
|
print(ex)
|
|
|
|
|
2021-04-20 09:27:48 +00:00
|
|
|
|
2021-04-20 10:31:51 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|