Skip to content

Commit

Permalink
plugins: replace Glossary type annotation with new limited types
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 31, 2024
1 parent 31c4e42 commit a9b0383
Show file tree
Hide file tree
Showing 61 changed files with 125 additions and 124 deletions.
4 changes: 2 additions & 2 deletions pyglossary/plugins/aard2_slob/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections.abc import Iterator

from pyglossary import slob
from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType

from pyglossary.core import exc_note, log, pip
from pyglossary.plugins.aard2_slob.tags import (
Expand All @@ -29,7 +29,7 @@ class Reader:
"icu": "PyICU", # >=1.5
}

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._clear()
self._re_bword = re.compile(
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/aard2_slob/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections.abc import Generator

from pyglossary import slob
from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType

from pyglossary.core import cacheDir, exc_note, log, pip
from pyglossary.plugins.aard2_slob.tags import (
Expand Down Expand Up @@ -65,7 +65,7 @@ class Writer:
"mp4": "video/mp4",
}

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._filename = ""
self._resPrefix = ""
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/almaany/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import sqlite3
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType


class Reader:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._clear()

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/appledict/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import io
from collections.abc import Generator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType


sys.setrecursionlimit(10000)
Expand Down Expand Up @@ -182,7 +182,7 @@ class Writer:
_jing: bool = False
_indexes: str = "" # FIXME: rename to indexes_lang?

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._dirname = ""

Expand Down
6 changes: 3 additions & 3 deletions pyglossary/plugins/appledict_bin/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
HtmlProcessingInstruction,
)

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType
from pyglossary.lxml_types import Element

from .appledict_properties import AppleDictProperties
Expand Down Expand Up @@ -82,8 +82,8 @@ class Reader:
".strings",
}

def __init__(self, glos: GlossaryType) -> None:
self._glos: GlossaryType = glos
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos: ReaderGlossaryType = glos
self._dictDirPath = ""
self._contentsPath = ""
self._file: io.BufferedIOBase = nullBinaryIO
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/ayandict_sqlite/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import sqlite3
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType


class Reader:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._clear()

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/ayandict_sqlite/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sqlite3
from collections.abc import Generator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType
from pyglossary.xdxf.transform import XdxfTransformer

from pyglossary.core import log
Expand All @@ -18,7 +18,7 @@
class Writer:
_fuzzy: int = True

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._clear()

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/babylon_bgl/bgl_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
if TYPE_CHECKING:
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType

__all__ = ["BGLGzipFile", "BglReader", "Block", "FileOffS", "optionsProp", "tmpDir"]

Expand Down Expand Up @@ -342,7 +342,7 @@ class BglReader:
selected encoding, so the user may fix the encoding if needed.
"""

def __init__(self, glos: GlossaryType) -> None: # no more arguments
def __init__(self, glos: ReaderGlossaryType) -> None: # no more arguments
self._glos = glos
self._filename = ""
self.info = {}
Expand Down
6 changes: 3 additions & 3 deletions pyglossary/plugins/cc_kedict/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import lxml

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType

from pyglossary.core import exc_note, log, pip
from pyglossary.text_reader import TextGlossaryReader
Expand All @@ -29,7 +29,7 @@ class YamlReader(TextGlossaryReader):

def __init__( # noqa: PLR0913
self,
glos: GlossaryType,
glos: ReaderGlossaryType,
spellKey: str = "",
posKey: str = "",
synsKey: str = "",
Expand Down Expand Up @@ -272,7 +272,7 @@ class Reader:
"lxml": "lxml",
}

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._yaml = YamlReader(
glos,
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/crawler_dir/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
if TYPE_CHECKING:
from collections.abc import Generator, Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType


class Reader:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._filename = None
self._wordCount = 0
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/crawler_dir/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
)

if TYPE_CHECKING:
from pyglossary.glossary_types import GlossaryType
from pyglossary.glossary_types import WriterGlossaryType


class Writer:
_compression: str = ""

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._filename = None

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/csv_plugin/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io
from collections.abc import Iterable, Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType


class Reader:
Expand All @@ -45,7 +45,7 @@ class Reader:
_newline: str = "\n"
_delimiter: str = ","

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self.clear()

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/csv_plugin/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io
from collections.abc import Generator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType


class Writer:
Expand All @@ -48,7 +48,7 @@ class Writer:
_enable_info: bool = True
_word_title: bool = False

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._file: io.TextIOBase = nullTextIO

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dicformids/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
if TYPE_CHECKING:
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType


class Reader:
re_number = re.compile(r"\d+")

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._tabFileNames: list[str] = []
self._tabFileReader = None
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dicformids/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if TYPE_CHECKING:
from collections.abc import Generator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType


PROP_TEMPLATE = """#DictionaryForMIDs property file
Expand Down Expand Up @@ -49,7 +49,7 @@


class Writer:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self.linesPerDirectoryFile = 500 # 200
self.indexFileMaxSize = 32722 # 30000
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dict_cc/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import sqlite3
from collections.abc import Callable, Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType
from pyglossary.lxml_types import Element, T_htmlfile


from pyglossary.core import log


class Reader:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._clear()

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dict_cc_split/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import sqlite3
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType

from pyglossary.core import log


class Reader:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._clear()

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dict_org/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
if TYPE_CHECKING:
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType


class Reader:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._filename = ""
self._dictdb: DictDB | None = None
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dict_org/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if TYPE_CHECKING:
from collections.abc import Generator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType


def installToDictd(filename: str, dictzip: bool) -> None:
Expand Down Expand Up @@ -56,7 +56,7 @@ class Writer:
_dictzip: bool = False
_install: bool = True

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._filename = ""
self._dictdb: DictDB | None = None
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dict_org_source/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
if TYPE_CHECKING:
from collections.abc import Generator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType


class Writer:
_remove_html_all: bool = True

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._filename = ""

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/digitalnk/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import sqlite3
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType


class Reader:
def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._clear()

Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dikt_json/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if TYPE_CHECKING:
from collections.abc import Generator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, WriterGlossaryType


class Writer:
Expand All @@ -26,7 +26,7 @@ class Writer:

compressions = stdCompressions

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: WriterGlossaryType) -> None:
self._glos = glos
self._filename = None
glos.preventDuplicateWords()
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/dsl/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import io
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.glossary_types import EntryType, ReaderGlossaryType

htmlEntityPattern = re.compile(r"&#?\w+;")

Expand Down Expand Up @@ -92,7 +92,7 @@ class Reader:
_example_color: str = "steelblue"
_abbrev: str = "hover"

def __init__(self, glos: GlossaryType) -> None:
def __init__(self, glos: ReaderGlossaryType) -> None:
self._glos = glos
self._filename = ""
self._dirPath = ""
Expand Down
Loading

0 comments on commit a9b0383

Please sign in to comment.