Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stardict: support for .syn.dz (packed) files #410

Closed
windwerfer opened this issue Jan 14, 2023 · 1 comment
Closed

stardict: support for .syn.dz (packed) files #410

windwerfer opened this issue Jan 14, 2023 · 1 comment
Labels

Comments

@windwerfer
Copy link

windwerfer commented Jan 14, 2023

feature request: process stardict .syn.dz files as well.
at the moment they need to be unpacked and saved as .syn files fist.

this works for me:

diff --git a/plugins/stardict.py
index 31ba63b..de35933 100644
--- a/plugins/stardict.py
+++ b/plugins/stardict.py
@@ -334,12 +334,24 @@ class Reader(object):
 		"""
 		return synDict, a dict { entryIndex -> altList }
 		"""
-		if not isfile(self._filename + ".syn"):
-			return {}
+
 		unicode_errors = self._unicode_errors
 
-		with open(self._filename + ".syn", "rb") as synFile:
-			synBytes = synFile.read()
+		synBytes = ''
+		if isfile(self._filename + ".syn.dz"):
+			with gzip.open(self._filename + ".syn.dz", mode="rb") as synFile:
+				synBytes = synFile.read()
+		if isfile(self._filename + ".syn"):
+			with open(self._filename + ".syn", mode="rb") as synFile:
+				synBytes = synFile.read()
+		if (synBytes == ''):
+			return {}
+
 		synBytesLen = len(synBytes)
 		synDict = {}
 		pos = 0

@ilius
Copy link
Owner

ilius commented Jan 14, 2023

Done.

@ilius ilius closed this as completed Jan 14, 2023
@ilius ilius added the Feature label May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants