diff --git a/__init__.py b/__init__.py
index 5231e4a..f5c6008 100644
--- a/__init__.py
+++ b/__init__.py
@@ -19,19 +19,18 @@
from aqt.utils import tooltip
from aqt.qt import *
-from aqt.editor import Editor
from aqt import mw
from anki.hooks import addHook
from . import reading
-from . import config
+from .config import Config
from .selection import Selection
from .utils import removeFurigana
mecab = reading.MecabController()
-config = config.Config()
+config = Config()
def setupGuiMenu():
useRubyTags = QAction("Use ruby tags", mw, checkable=True, checked=config.getUseRubyTags())
diff --git a/config.py b/config.py
index 4210267..b5a202a 100644
--- a/config.py
+++ b/config.py
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Japanese Furigana. If not, see .
+from aqt.addons import AbortAddonImport
from aqt import mw
def saveMe(func):
@@ -25,7 +26,11 @@ def wrapper(self, *args):
return wrapper
class Config:
- data = mw.addonManager.getConfig(__name__)
+ def __init__(self):
+ if mw is None:
+ raise AbortAddonImport("No Anki main window?")
+
+ self.data = mw.addonManager.getConfig(__name__)
def getUseRubyTags(self):
return self.data['useRubyTags']
diff --git a/reading.py b/reading.py
index 76ca5e1..9e33544 100644
--- a/reading.py
+++ b/reading.py
@@ -1,13 +1,19 @@
# -*- coding: utf-8 -*-
-# This file is based on the Japanese Support add-on's reading.py, which can be
-# found at .
+# This file is part of Japanese Furigana .
#
-# Copyright: Ankitects Pty Ltd and contributors
-# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
+# Japanese Furigana is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
#
-# Automatic reading generation with mecab.
+# Japanese Furigana 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 General Public License for more details.
#
+# You should have received a copy of the GNU General Public License
+# along with Japanese Furigana. If not, see .
import sys
import os
@@ -15,7 +21,7 @@
import subprocess
import platform
-from typing import Mapping, Optional, Union
+from typing import Any, Mapping, Optional, Union
mecabArgs = ['--node-format=%m[%f[7]] ', '--eos-format=\n',
'--unk-format=%m[] ']
@@ -57,7 +63,7 @@ def escapeText(text):
except:
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
else:
- si = None
+ si: Optional[Any] = None
# Syllabary utilities
UNICODE_HIRAGANA_START = 0x3041
diff --git a/support/mecab.arm b/support/mecab.arm
old mode 100644
new mode 100755
diff --git a/test/test_reading.py b/test/test_reading.py
index b09dfa6..960db4b 100644
--- a/test/test_reading.py
+++ b/test/test_reading.py
@@ -1,3 +1,20 @@
+# -*- coding: utf-8 -*-
+
+# This file is part of Japanese Furigana .
+#
+# Japanese Furigana is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Japanese Furigana 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Japanese Furigana. If not, see .
+
import unittest
import reading
diff --git a/test/test_utils.py b/test/test_utils.py
index 2a84f81..90e7d65 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -1,3 +1,20 @@
+# -*- coding: utf-8 -*-
+
+# This file is part of Japanese Furigana .
+#
+# Japanese Furigana is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Japanese Furigana 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Japanese Furigana. If not, see .
+
import unittest
import utils
diff --git a/utils.py b/utils.py
index a234da5..66f3838 100644
--- a/utils.py
+++ b/utils.py
@@ -1,5 +1,20 @@
# -*- coding: utf-8 -*-
+# This file is part of Japanese Furigana .
+#
+# Japanese Furigana is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Japanese Furigana 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Japanese Furigana. If not, see .
+
import re
def removeFurigana(text: str):