Skip to content

Commit

Permalink
BGL: rename reader modules and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 31, 2024
1 parent dd2b6cf commit b0936a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions pyglossary/plugins/babylon_bgl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
# with this program. Or on Debian systems, from /usr/share/common-licenses/GPL
# If not, see <http://www.gnu.org/licenses/gpl.txt>.

from .bgl_reader import BglReader as Reader
from .bgl_reader import optionsProp
from .reader import Reader, optionsProp

__all__ = [
"Reader",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/babylon_bgl/bgl_internal_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from pyglossary.plugins.babylon_bgl.bgl_reader_debug import isASCII
from pyglossary.plugins.babylon_bgl.reader_debug import isASCII


class BglInternalTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

from pyglossary.glossary_types import EntryType, ReaderGlossaryType

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


file = io.BufferedReader
Expand Down Expand Up @@ -293,7 +293,7 @@ def __init__(self) -> None:
self.b_field_13 = None # bytes


class BglReader:
class Reader:
_default_encoding_overwrite: str = ""
_source_encoding_overwrite: str = ""
_target_encoding_overwrite: str = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
uintFromBytes,
)

from .bgl_reader import BGLGzipFile, BglReader, Block, FileOffS, tmpDir
from .reader import BGLGzipFile, Block, FileOffS, Reader, tmpDir


def isASCII(data: str) -> bool:
Expand Down Expand Up @@ -109,7 +109,7 @@ def __init__(
fileobj - gzip file - archive
unpackedPath - path of a file containing original data, for testing.
reader - reference to BglReader class instance, used for logging.
reader - reference to BGL Reader class instance, used for logging.
"""
self.file = BGLGzipFile(
fileobj=fileobj,
Expand Down Expand Up @@ -172,7 +172,7 @@ def flush(self):
self.unpackedFile.flush()


class DebugBglReader(BglReader):
class DebugReader(Reader):
_collect_metadata2: bool = False
_search_char_samples: bool = False
_write_gz: bool = False
Expand All @@ -185,7 +185,7 @@ def open(
self,
filename,
):
if not BglReader.open(self, filename):
if not Reader.open(self, filename):
return

self.metadata2 = MetaData2() if self._collect_metadata2 else None
Expand Down Expand Up @@ -255,7 +255,7 @@ def openGzip(self):
return None

def close(self) -> None:
BglReader.close(self)
Reader.close(self)
if self.rawDumpFile:
self.rawDumpFile.close()
self.rawDumpFile = None
Expand All @@ -267,17 +267,17 @@ def close(self) -> None:
self.samplesDumpFile = None

def __del__(self) -> None:
BglReader.__del__(self)
Reader.__del__(self)

def readEntryWord(self, block, pos):
succeed, pos, _u_word, b_word = BglReader.readEntryWord(self, block, pos)
succeed, pos, _u_word, b_word = Reader.readEntryWord(self, block, pos)
if not succeed:
return
self.rawDumpFileWriteText(f"\n\nblock type = {block.type}\nkey = ")
self.rawDumpFileWriteData(b_word)

def readEntryDefi(self, block, pos, b_key):
succeed, pos, _u_defi, b_defi = BglReader.readEntryDefi(self, block, pos, b_key)
succeed, pos, _u_defi, b_defi = Reader.readEntryDefi(self, block, pos, b_key)
if not succeed:
return
self.rawDumpFileWriteText("\ndefi = ")
Expand All @@ -286,7 +286,7 @@ def readEntryDefi(self, block, pos, b_key):
"""
def readEntryAlts(self, block, pos, b_key, key):
succeed, pos, alts, b_alts = \
BglReader.readEntryAlts(self, block, pos, b_key, key)
Reader.readEntryAlts(self, block, pos, b_key, key)
if not succeed:
return
for b_alt in b_alts:
Expand Down Expand Up @@ -433,7 +433,7 @@ def dumpMetadata2(self, dumpPath):
pickle.dump(self.metadata2, f)

def processDefiStat(self, fields, defi, b_key): # noqa: PLR0912
BglReader.processDefiStat(self, fields, defi, b_key)
Reader.processDefiStat(self, fields, defi, b_key)

if fields.b_title:
self.rawDumpFileWriteText("\ndefi title: ")
Expand Down

0 comments on commit b0936a0

Please sign in to comment.