diff --git a/src/cloze_overlapper/__init__.py b/src/cloze_overlapper/__init__.py index 7ce5c1b..5dc12e5 100644 --- a/src/cloze_overlapper/__init__.py +++ b/src/cloze_overlapper/__init__.py @@ -38,4 +38,24 @@ from ._version import __version__ # noqa: F401 -from . import main # noqa: F401 +from .consts import ADDON +from .libaddon.consts import setAddonProperties + +setAddonProperties(ADDON) + +from anki.hooks import addHook + +from .gui.options_global import initializeOptions +from .template import initializeModels +from .editor import initializeEditor +from .sched import initializeScheduler +from .reviewer import initializeReviewer + +def delayedInit(): + initializeModels() + initializeScheduler() + +addHook("profileLoaded", delayedInit) +initializeOptions() +initializeEditor() +initializeReviewer() diff --git a/src/cloze_overlapper/config.py b/src/cloze_overlapper/config.py index b7e2de8..37f704a 100644 --- a/src/cloze_overlapper/config.py +++ b/src/cloze_overlapper/config.py @@ -113,7 +113,7 @@ def createNoteSettings(setopts): "flds": OLC_FLDS, "sched": [True, True, False], "olmdls": [OLC_MODEL], - "version": ADDON_VERSION + "version": ADDON.VERSION } } diff --git a/src/cloze_overlapper/consts.py b/src/cloze_overlapper/consts.py index cd6b497..dbf40bd 100644 --- a/src/cloze_overlapper/consts.py +++ b/src/cloze_overlapper/consts.py @@ -38,32 +38,48 @@ from ._version import __version__ +try: + from .data.patrons import MEMBERS_CREDITED, MEMBERS_TOP +except ImportError: + MEMBERS_CREDITED = MEMBERS_TOP = () + __all__ = [ - "ADDON_NAME", "ADDON_ID", "ADDON_VERSION", "LINKS", - "LICENSE", "LIBRARIES", "AUTHORS", "CONTRIBUTORS", - "SPONSORS", + "ADDON", "OLC_MODEL", "OLC_CARD", "OLC_MAX", "OLC_FLDS", "OLC_FLDS_IDS", "OLC_FIDS_PRIV" ] -# ADD-ON - -ADDON_NAME = "Cloze Overlapper" -ADDON_ID = "969733775" -ADDON_VERSION = __version__ -LINKS = { - "help": "https://github.com/glutanimate/cloze-overlapper/wiki" -} -LICENSE = "GNU AGPLv3" -LIBRARIES = [] -AUTHORS = [ - {"name": "Aristotelis P. (Glutanimate)", "years": "2016-2019", - "contact": "https://glutanimate.com"} -] -# automatically sorted: -CONTRIBUTORS = ["zjosua"] -SPONSORS = [] +# PROPERTIES DESCRIBING ADDON +class ADDON(object): + """Class storing general add-on properties + Property names need to be all-uppercase with no leading underscores + """ + NAME = "Cloze Overlapper" + MODULE = "cloze_overlapper" + ID = "969733775" + VERSION = __version__ + LICENSE = "GNU AGPLv3" + AUTHORS = ( + {"name": "Aristotelis P. (Glutanimate)", "years": "2016-2019", + "contact": "https://glutanimate.com"}, + ) + AUTHOR_MAIL = "ankiglutanimate@gmail.com" + LIBRARIES = () + CONTRIBUTORS = ("zjosua", ) + SPONSORS = () + MEMBERS_CREDITED = MEMBERS_CREDITED + MEMBERS_TOP = MEMBERS_TOP + LINKS = { + "patreon": "https://www.patreon.com/glutanimate", + "bepatron": "https://www.patreon.com/bePatron?u=7522179", + "coffee": "http://ko-fi.com/glutanimate", + "description": "https://ankiweb.net/shared/info/{}".format(ID), + "rate": "https://ankiweb.net/shared/review/{}".format(ID), + "twitter": "https://twitter.com/glutanimate", + "youtube": "https://www.youtube.com/c/glutanimate", + "help": "https://github.com/glutanimate/review-heatmap/wiki" + } # OLC diff --git a/src/cloze_overlapper/gui/resources/__init__.py b/src/cloze_overlapper/gui/resources/__init__.py index 03533f9..a6409bb 100644 --- a/src/cloze_overlapper/gui/resources/__init__.py +++ b/src/cloze_overlapper/gui/resources/__init__.py @@ -39,5 +39,3 @@ from .anki20 import * # noqa: F401 else: from .anki21 import * # noqa: F401 - -QRC_PREFIX = "cloze_overlapper" diff --git a/src/cloze_overlapper/libaddon/gui/dialog_contrib.py b/src/cloze_overlapper/libaddon/gui/dialog_contrib.py index 1ea218c..01d4944 100644 --- a/src/cloze_overlapper/libaddon/gui/dialog_contrib.py +++ b/src/cloze_overlapper/libaddon/gui/dialog_contrib.py @@ -34,7 +34,7 @@ Uses the following addon-level constants, if defined: -ADDON_NAME, MAIL_AUTHOR, LINKS +ADDON.NAME, ADDON.AUTHOR_MAIL, ADDON.LINKS """ from __future__ import (absolute_import, division, diff --git a/src/cloze_overlapper/main.py b/src/cloze_overlapper/main.py deleted file mode 100644 index f6a7aa5..0000000 --- a/src/cloze_overlapper/main.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- - -# Cloze Overlapper Add-on for Anki -# -# Copyright (C) 2016-2019 Aristotelis P. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version, with the additions -# listed at the end of the license file that accompanied this program -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# NOTE: This program is subject to certain additional terms pursuant to -# Section 7 of the GNU Affero General Public License. You should have -# received a copy of these additional terms immediately following the -# terms and conditions of the GNU Affero General Public License that -# accompanied this program. -# -# If not, please request a copy through one of the means of contact -# listed here: . -# -# Any modifications to this file must keep this entire header intact. - -""" -Initializes add-on components. -""" - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - - -from anki.hooks import addHook - -from .gui.options_global import initializeOptions -from .template import initializeModels -from .editor import initializeEditor -from .sched import initializeScheduler -from .reviewer import initializeReviewer - - -def delayedInit(): - initializeModels() - initializeScheduler() - - -addHook("profileLoaded", delayedInit) -initializeOptions() -initializeEditor() -initializeReviewer()