consistent 'with open(…) as fp:' syntax

This commit is contained in:
Mike Fährmann
2024-06-14 01:22:00 +02:00
parent 3fc2e61818
commit 9c65db2a92
15 changed files with 46 additions and 46 deletions

View File

@@ -167,8 +167,8 @@ def load(files=None, strict=False, loads=util.json_loads):
for pathfmt in files or _default_configs:
path = util.expand_path(pathfmt)
try:
with open(path, encoding="utf-8") as file:
conf = loads(file.read())
with open(path, encoding="utf-8") as fp:
conf = loads(fp.read())
except OSError as exc:
if strict:
log.error(exc)

View File

@@ -188,8 +188,8 @@ def _firefox_cookies_database(profile=None, container=None):
os.path.dirname(path), "containers.json")
try:
with open(containers_path) as file:
identities = util.json_loads(file.read())["identities"]
with open(containers_path) as fp:
identities = util.json_loads(fp.read())["identities"]
except OSError:
_log_error("Unable to read Firefox container database at '%s'",
containers_path)
@@ -745,8 +745,8 @@ def _get_windows_v10_key(browser_root):
_log_error("Unable to find Local State file")
return None
_log_debug("Found Local State file at '%s'", path)
with open(path, encoding="utf-8") as file:
data = util.json_loads(file.read())
with open(path, encoding="utf-8") as fp:
data = util.json_loads(fp.read())
try:
base64_key = data["os_crypt"]["encrypted_key"]
except KeyError:

View File

@@ -18,8 +18,8 @@ class TextDownloader(DownloaderBase):
if self.part:
pathfmt.part_enable(self.partdir)
self.out.start(pathfmt.path)
with pathfmt.open("wb") as file:
file.write(url.encode()[5:])
with pathfmt.open("wb") as fp:
fp.write(url.encode()[5:])
return True

View File

@@ -266,8 +266,8 @@ class UgoiraPP(PostProcessor):
append("")
ffconcat = tempdir + "/ffconcat.txt"
with open(ffconcat, "w") as file:
file.write("\n".join(content))
with open(ffconcat, "w") as fp:
fp.write("\n".join(content))
return ffconcat
def _write_mkvmerge_timecodes(self, tempdir):
@@ -282,8 +282,8 @@ class UgoiraPP(PostProcessor):
append("")
timecodes = tempdir + "/timecodes.tc"
with open(timecodes, "w") as file:
file.write("\n".join(content))
with open(timecodes, "w") as fp:
fp.write("\n".join(content))
return timecodes
def calculate_framerate(self, frames):