Fix newline changes to read universally

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
TheJackiMonster 2023-12-12 16:18:43 +01:00
parent 98d6eb4975
commit 41e59d71c1
No known key found for this signature in database
GPG key ID: D850A5F772E880F9
6 changed files with 7 additions and 7 deletions

View file

@ -148,7 +148,7 @@ class BasicDictionary:
self._customDict = set() self._customDict = set()
customPath = self.getCustomDictionaryPath() customPath = self.getCustomDictionaryPath()
try: 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())) self._customDict = set(json.loads(f.read()))
for word in self._customDict: for word in self._customDict:
self._dict.create_dictionary_entry(word, self.CUSTOM_COUNT) self._dict.create_dictionary_entry(word, self.CUSTOM_COUNT)
@ -416,7 +416,7 @@ class SymSpellDictionary(BasicDictionary):
if pyspellchecker: if pyspellchecker:
path = os.path.join(pyspellchecker.__path__[0], "resources", "{}.json.gz".format(self.name)) path = os.path.join(pyspellchecker.__path__[0], "resources", "{}.json.gz".format(self.name))
if os.path.exists(path): 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()) data = json.loads(f.read())
for key in data: for key in data:
self._dict.create_dictionary_entry(key, data[key]) self._dict.create_dictionary_entry(key, data[key])

View file

@ -46,7 +46,7 @@ class folderImporter(abstractImporter):
fName, fExt = os.path.splitext(f) fName, fExt = os.path.splitext(f)
if fExt.lower() in ext: if fExt.lower() in ext:
try: 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() content = fr.read()
child = outlineItem(title=fName, _type="md", parent=item) child = outlineItem(title=fName, _type="md", parent=item)
child._data[Outline.text] = content child._data[Outline.text] = content

View file

@ -65,7 +65,7 @@ class markdownImporter(abstractImporter):
if not fromString: if not fromString:
# Read file # 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() txt = f.read()
else: else:
txt = fromString txt = fromString

View file

@ -56,7 +56,7 @@ def loadProject(project):
# Not a zip # Not a zip
else: 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()) version = int(f.read())
LOGGER.info("Loading: %s", project) LOGGER.info("Loading: %s", project)

View file

@ -692,7 +692,7 @@ def loadProject(project, zip=None):
else: else:
try: try:
filename = os.path.join(dirpath, f) 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() files[os.path.join(p, f)] = fo.read()
except PermissionError as e: except PermissionError as e:
LOGGER.error("Cannot open file " + filename + ": " + e.strerror) LOGGER.error("Cannot open file " + filename + ": " + e.strerror)

View file

@ -128,7 +128,7 @@ class exporterSettings(QWidget, Ui_exporterSettings):
def loadSettings(self): def loadSettings(self):
filename = self.getSettingsPath() filename = self.getSettingsPath()
if os.path.exists(filename): 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.settings = json.load(f)
self.updateFromSettings() self.updateFromSettings()