mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-04-29 18:42:34 +12:00
Fix newline changes to read universally
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
parent
98d6eb4975
commit
41e59d71c1
|
@ -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])
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue