From 41e59d71c15ebb7a475aadd16092c21be7bb6097 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Tue, 12 Dec 2023 16:18:43 +0100 Subject: [PATCH] Fix newline changes to read universally Signed-off-by: TheJackiMonster --- manuskript/functions/spellchecker.py | 4 ++-- manuskript/importer/folderImporter.py | 2 +- manuskript/importer/markdownImporter.py | 2 +- manuskript/loadSave.py | 2 +- manuskript/load_save/version_1.py | 2 +- manuskript/ui/exporters/manuskript/plainTextSettings.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manuskript/functions/spellchecker.py b/manuskript/functions/spellchecker.py index 54fc53a..47cb71c 100644 --- a/manuskript/functions/spellchecker.py +++ b/manuskript/functions/spellchecker.py @@ -148,7 +148,7 @@ class BasicDictionary: self._customDict = set() customPath = self.getCustomDictionaryPath() try: - with gzip.open(customPath, "rt", encoding='utf-8', newline="\n") as f: + with gzip.open(customPath, 'rt', encoding='utf-8') as f: self._customDict = set(json.loads(f.read())) for word in self._customDict: self._dict.create_dictionary_entry(word, self.CUSTOM_COUNT) @@ -416,7 +416,7 @@ class SymSpellDictionary(BasicDictionary): if pyspellchecker: path = os.path.join(pyspellchecker.__path__[0], "resources", "{}.json.gz".format(self.name)) if os.path.exists(path): - with gzip.open(path, "rt", encoding='utf-8', newline="\n") as f: + with gzip.open(path, 'rt', encoding='utf-8') as f: data = json.loads(f.read()) for key in data: self._dict.create_dictionary_entry(key, data[key]) diff --git a/manuskript/importer/folderImporter.py b/manuskript/importer/folderImporter.py index 7767d9a..a8cb823 100644 --- a/manuskript/importer/folderImporter.py +++ b/manuskript/importer/folderImporter.py @@ -46,7 +46,7 @@ class folderImporter(abstractImporter): fName, fExt = os.path.splitext(f) if fExt.lower() in ext: try: - with open(os.path.join(dirpath, f), "r", encoding="utf-8", newline="\n") as fr: + with open(os.path.join(dirpath, f), 'rt', encoding="utf-8") as fr: content = fr.read() child = outlineItem(title=fName, _type="md", parent=item) child._data[Outline.text] = content diff --git a/manuskript/importer/markdownImporter.py b/manuskript/importer/markdownImporter.py index 60f8964..5cf06b5 100644 --- a/manuskript/importer/markdownImporter.py +++ b/manuskript/importer/markdownImporter.py @@ -65,7 +65,7 @@ class markdownImporter(abstractImporter): if not fromString: # Read file - with open(filePath, "r", encoding="utf-8", newline="\n") as f: + with open(filePath, 'rt', encoding="utf-8") as f: txt = f.read() else: txt = fromString diff --git a/manuskript/loadSave.py b/manuskript/loadSave.py index 745fb6f..2528b05 100644 --- a/manuskript/loadSave.py +++ b/manuskript/loadSave.py @@ -56,7 +56,7 @@ def loadProject(project): # Not a zip else: - with open(project, "r", encoding="utf-8", newline="\n") as f: + with open(project, 'rt', encoding="utf-8") as f: version = int(f.read()) LOGGER.info("Loading: %s", project) diff --git a/manuskript/load_save/version_1.py b/manuskript/load_save/version_1.py index c087c04..14b6871 100644 --- a/manuskript/load_save/version_1.py +++ b/manuskript/load_save/version_1.py @@ -692,7 +692,7 @@ def loadProject(project, zip=None): else: try: filename = os.path.join(dirpath, f) - with open(filename, "r", encoding="utf8", newline="\n") as fo: + with open(filename, 'rt', encoding="utf8") as fo: files[os.path.join(p, f)] = fo.read() except PermissionError as e: LOGGER.error("Cannot open file " + filename + ": " + e.strerror) diff --git a/manuskript/ui/exporters/manuskript/plainTextSettings.py b/manuskript/ui/exporters/manuskript/plainTextSettings.py index d4d53c1..f96371f 100644 --- a/manuskript/ui/exporters/manuskript/plainTextSettings.py +++ b/manuskript/ui/exporters/manuskript/plainTextSettings.py @@ -128,7 +128,7 @@ class exporterSettings(QWidget, Ui_exporterSettings): def loadSettings(self): filename = self.getSettingsPath() if os.path.exists(filename): - with open(filename, "r", encoding="utf-8", newline="\n") as f: + with open(filename, 'r', encoding="utf-8") as f: self.settings = json.load(f) self.updateFromSettings()