consistent 'with open(…) as fp:' syntax
This commit is contained in:
@@ -48,8 +48,8 @@ for action in option.build_parser()._actions:
|
||||
opts.append(opt)
|
||||
|
||||
PATH = util.path("data/completion/gallery-dl")
|
||||
with util.lazy(PATH) as file:
|
||||
file.write(TEMPLATE % {
|
||||
with util.lazy(PATH) as fp:
|
||||
fp.write(TEMPLATE % {
|
||||
"opts" : " ".join(opts),
|
||||
"diropts" : "|".join(diropts),
|
||||
"fileopts": "|".join(fileopts),
|
||||
|
||||
@@ -41,5 +41,5 @@ for action in option.build_parser()._actions:
|
||||
opts.append(opt)
|
||||
|
||||
PATH = util.path("data/completion/gallery-dl.fish")
|
||||
with util.lazy(PATH) as file:
|
||||
file.write(TEMPLATE % {"opts": "\n".join(opts)})
|
||||
with util.lazy(PATH) as fp:
|
||||
fp.write(TEMPLATE % {"opts": "\n".join(opts)})
|
||||
|
||||
@@ -53,5 +53,5 @@ for action in option.build_parser()._actions:
|
||||
|
||||
|
||||
PATH = util.path("data/completion/_gallery-dl")
|
||||
with util.lazy(PATH) as file:
|
||||
file.write(TEMPLATE % {"opts": " \\\n".join(opts)})
|
||||
with util.lazy(PATH) as fp:
|
||||
fp.write(TEMPLATE % {"opts": " \\\n".join(opts)})
|
||||
|
||||
@@ -239,8 +239,8 @@ def main():
|
||||
os.makedirs(args.target, exist_ok=True)
|
||||
for name, tests in collect_tests(args.category).items():
|
||||
name = name.replace(".", "")
|
||||
with util.lazy(f"{args.target}/{name}.py") as file:
|
||||
file.write(export_tests(tests))
|
||||
with util.lazy(f"{args.target}/{name}.py") as fp:
|
||||
fp.write(export_tests(tests))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -100,8 +100,8 @@ and https://github.com/mikf/gallery-dl/graphs/contributors
|
||||
|
||||
if not path:
|
||||
path = util.path("data/man/gallery-dl.1")
|
||||
with util.lazy(path) as file:
|
||||
file.write(TEMPLATE.lstrip() % {
|
||||
with util.lazy(path) as fp:
|
||||
fp.write(TEMPLATE.lstrip() % {
|
||||
"options": "\n".join(options),
|
||||
"version": gallery_dl.version.__version__,
|
||||
"date" : datetime.datetime.now().strftime("%Y-%m-%d"),
|
||||
@@ -218,8 +218,8 @@ and https://github.com/mikf/gallery-dl/graphs/contributors
|
||||
|
||||
if not path:
|
||||
path = util.path("data/man/gallery-dl.conf.5")
|
||||
with util.lazy(path) as file:
|
||||
file.write(TEMPLATE.lstrip() % {
|
||||
with util.lazy(path) as fp:
|
||||
fp.write(TEMPLATE.lstrip() % {
|
||||
"options": "\n".join(content),
|
||||
"version": gallery_dl.version.__version__,
|
||||
"date" : datetime.datetime.now().strftime("%Y-%m-%d"),
|
||||
@@ -229,8 +229,8 @@ and https://github.com/mikf/gallery-dl/graphs/contributors
|
||||
def parse_docs_configuration():
|
||||
|
||||
doc_path = util.path("docs", "configuration.rst")
|
||||
with open(doc_path, encoding="utf-8") as file:
|
||||
doc_lines = file.readlines()
|
||||
with open(doc_path, encoding="utf-8") as fp:
|
||||
doc_lines = fp.readlines()
|
||||
|
||||
sections = {}
|
||||
sec_name = None
|
||||
|
||||
@@ -38,8 +38,8 @@ opts = opts.replace("\n ", "\n ") # indent by 4
|
||||
|
||||
PATH = (sys.argv[1] if len(sys.argv) > 1 else
|
||||
util.path("docs", "options.md"))
|
||||
with util.lazy(PATH) as file:
|
||||
file.write(TEMPLATE.format(
|
||||
with util.lazy(PATH) as fp:
|
||||
fp.write(TEMPLATE.format(
|
||||
"/".join(os.path.normpath(__file__).split(os.sep)[-2:]),
|
||||
opts,
|
||||
))
|
||||
|
||||
@@ -593,5 +593,5 @@ Consider all listed sites to potentially be NSFW.
|
||||
categories, domains = build_extractor_list()
|
||||
PATH = (sys.argv[1] if len(sys.argv) > 1 else
|
||||
util.path("docs", "supportedsites.md"))
|
||||
with util.lazy(PATH) as file:
|
||||
file.write(generate_output(COLUMNS, categories, domains))
|
||||
with util.lazy(PATH) as fp:
|
||||
fp.write(generate_output(COLUMNS, categories, domains))
|
||||
|
||||
Reference in New Issue
Block a user