add missing encoding argument to open calls
This commit is contained in:
parent
9a103b3716
commit
553ce808e5
@ -21,7 +21,7 @@ def _build_info_path() -> str:
|
|||||||
|
|
||||||
def _get_build_info() -> Dict[str, str]:
|
def _get_build_info() -> Dict[str, str]:
|
||||||
info = {}
|
info = {}
|
||||||
with open(_build_info_path()) as file:
|
with open(_build_info_path(), encoding="utf8") as file:
|
||||||
for line in file.readlines():
|
for line in file.readlines():
|
||||||
elems = line.split()
|
elems = line.split()
|
||||||
if len(elems) == 2:
|
if len(elems) == 2:
|
||||||
|
@ -311,7 +311,7 @@ class SupermemoXmlImporter(NoteImporter):
|
|||||||
|
|
||||||
# try to open with native open function (if source is pathname)
|
# try to open with native open function (if source is pathname)
|
||||||
try:
|
try:
|
||||||
return open(source)
|
return open(source, encoding="utf8")
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ class SupermemoXmlImporter(NoteImporter):
|
|||||||
"""Load source file and parse with xml.dom.minidom"""
|
"""Load source file and parse with xml.dom.minidom"""
|
||||||
self.source = source
|
self.source = source
|
||||||
self.logger("Load started...")
|
self.logger("Load started...")
|
||||||
sock = open(self.source)
|
sock = open(self.source, encoding="utf8")
|
||||||
self.xmldoc = minidom.parse(sock).documentElement
|
self.xmldoc = minidom.parse(sock).documentElement
|
||||||
sock.close()
|
sock.close()
|
||||||
self.logger("Load done.")
|
self.logger("Load done.")
|
||||||
|
@ -142,7 +142,7 @@ def _save_latex_image(
|
|||||||
ext = "png"
|
ext = "png"
|
||||||
|
|
||||||
# write into a temp file
|
# write into a temp file
|
||||||
log = open(namedtmp("latex_log.txt"), "w")
|
log = open(namedtmp("latex_log.txt"), "w", encoding="utf8")
|
||||||
texpath = namedtmp("tmp.tex")
|
texpath = namedtmp("tmp.tex")
|
||||||
texfile = open(texpath, "w", encoding="utf8")
|
texfile = open(texpath, "w", encoding="utf8")
|
||||||
texfile.write(latex)
|
texfile.write(latex)
|
||||||
@ -170,7 +170,7 @@ def _errMsg(col: anki.collection.Collection, type: str, texpath: str) -> Any:
|
|||||||
msg = f"{col.tr.media_error_executing(val=type)}<br>"
|
msg = f"{col.tr.media_error_executing(val=type)}<br>"
|
||||||
msg += f"{col.tr.media_generated_file(val=texpath)}<br>"
|
msg += f"{col.tr.media_generated_file(val=texpath)}<br>"
|
||||||
try:
|
try:
|
||||||
with open(namedtmp("latex_log.txt", rm=False)) as f:
|
with open(namedtmp("latex_log.txt", rm=False), encoding="utf8") as f:
|
||||||
log = f.read()
|
log = f.read()
|
||||||
if not log:
|
if not log:
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
@ -573,14 +573,14 @@ create table if not exists profiles
|
|||||||
def video_driver(self) -> VideoDriver:
|
def video_driver(self) -> VideoDriver:
|
||||||
path = self._gldriver_path()
|
path = self._gldriver_path()
|
||||||
try:
|
try:
|
||||||
with open(path) as file:
|
with open(path, encoding="utf8") as file:
|
||||||
text = file.read().strip()
|
text = file.read().strip()
|
||||||
return VideoDriver(text).constrained_to_platform()
|
return VideoDriver(text).constrained_to_platform()
|
||||||
except (ValueError, OSError):
|
except (ValueError, OSError):
|
||||||
return VideoDriver.default_for_platform()
|
return VideoDriver.default_for_platform()
|
||||||
|
|
||||||
def set_video_driver(self, driver: VideoDriver) -> None:
|
def set_video_driver(self, driver: VideoDriver) -> None:
|
||||||
with open(self._gldriver_path(), "w") as file:
|
with open(self._gldriver_path(), "w", encoding="utf8") as file:
|
||||||
file.write(driver.value)
|
file.write(driver.value)
|
||||||
|
|
||||||
def set_next_video_driver(self) -> None:
|
def set_next_video_driver(self) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user