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()
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])

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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()