only rewrite utility files if contents changed

This commit is contained in:
Mike Fährmann
2023-01-27 18:04:13 +01:00
parent 0d818d3540
commit e60ec1699a
7 changed files with 52 additions and 13 deletions

View File

@@ -33,10 +33,10 @@ opts = re.sub(r"(?m)^(\w+.*)", "## \\1", opts) # group names to headings
opts = opts.replace("\n ", "\n ") # indent by 4
outfile = sys.argv[1] if len(sys.argv) > 1 else util.path("docs", "options.md")
with open(outfile, "w", encoding="utf-8") as fp:
fp.write(TEMPLATE.format(
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(
"/".join(os.path.normpath(__file__).split(os.sep)[-2:]),
opts,
))