Skip to content

Commit

Permalink
glossary_v2.py: some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 31, 2024
1 parent 68ae321 commit 6616ba2
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
relpath,
)
from time import perf_counter as now
from typing import (
TYPE_CHECKING,
cast,
)
from typing import TYPE_CHECKING, cast
from uuid import uuid1

from . import core
Expand Down Expand Up @@ -748,34 +745,35 @@ def _read(
formatName = formatName or format
del format

filenameAbs = os.path.abspath(filename)

self._setTmpDataDir(filename)

filename = os.path.abspath(filename)
###
inputArgs = PluginManager.detectInputFormat(filename, formatName=formatName)
origFilename = filename
filename, formatName, compression = inputArgs
filenameUC, formatName, compression = PluginManager.detectInputFormat(
filenameAbs, formatName=formatName
)
# filenameUC is the uncompressed file's absolute path

if compression:
from .compression import uncompress

uncompress(origFilename, filename, compression)
uncompress(filenameAbs, filenameUC, compression)

self._validateReadoptions(formatName, options)

filenameNoExt, ext = os.path.splitext(filename)
filenameBase, ext = os.path.splitext(filenameUC)
if ext.lower() not in self.plugins[formatName].extensions:
filenameNoExt = filename
filenameBase = filenameUC

self._filename = filenameNoExt
self._filename = filenameBase
if not self._info.get(c_name):
self._info[c_name] = os.path.split(filename)[1]
self._info[c_name] = os.path.split(filenameUC)[1]

if not self._entryFiltersAreSet:
self.updateEntryFilters()

reader = self._createReader(formatName, options)
self._openReader(reader, filename)
self._openReader(reader, filenameUC)

self._readOptions = options

Expand Down

0 comments on commit 6616ba2

Please sign in to comment.