From d6e9529710b3b6d2d0ccea73342949749bd98f0e Mon Sep 17 00:00:00 2001 From: Alec Deitloff Date: Sun, 16 Oct 2022 15:23:42 -0700 Subject: [PATCH 1/3] Fix mypy errors --- __init__.py | 5 ++--- config.py | 7 ++++++- reading.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) 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..716e9ba 100644 --- a/reading.py +++ b/reading.py @@ -15,7 +15,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 +57,7 @@ def escapeText(text): except: si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW else: - si = None + si: Optional[Any] = None # Syllabary utilities UNICODE_HIRAGANA_START = 0x3041 From 7f0ce1923641778050afe49b47531b4159d1f08f Mon Sep 17 00:00:00 2001 From: Alec Deitloff Date: Fri, 14 Oct 2022 11:35:10 -0700 Subject: [PATCH 2/3] Standardize file headers --- reading.py | 16 +++++++++++----- test/test_reading.py | 17 +++++++++++++++++ test/test_utils.py | 17 +++++++++++++++++ utils.py | 15 +++++++++++++++ 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/reading.py b/reading.py index 716e9ba..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 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): From 4e095697dc88c29cea4259d84a71b38d855648ec Mon Sep 17 00:00:00 2001 From: Alec Deitloff Date: Fri, 14 Oct 2022 11:39:12 -0700 Subject: [PATCH 3/3] Commit updated mecab.arm file permissions --- support/mecab.arm | Bin 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 support/mecab.arm diff --git a/support/mecab.arm b/support/mecab.arm old mode 100644 new mode 100755