Skip to content

Commit

Permalink
appledict_bin.py: read DefaultStyle.css file, add as style.css, #299
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Feb 8, 2021
1 parent ecaecf1 commit 4adb83a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pyglossary/plugins/appledict_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,17 @@ def _readEntry(self, pos: int) -> "Tuple[BaseEntry, int]":
), pos

def __iter__(self):
from os.path import dirname

if self._file is None:
raise RuntimeError("iterating over a reader while it's not open")
glos = self._glos

cssFilename = join(dirname(self._filename), "DefaultStyle.css")
if isfile(cssFilename):
with open(cssFilename, mode="rb") as cssFile:
cssBytes = cssFile.read()
yield glos.newDataEntry("style.css", cssBytes)

_file = self._file
limit = self._limit
Expand Down

0 comments on commit 4adb83a

Please sign in to comment.