archive.py: add support for skipping building during archiving

If it is known that the documents have already been built or if it
is imperative to use the versions built even if local changes have
been applied since the last build, this switch comes in handy.
This commit is contained in:
Jonas Schäfer 2020-06-13 17:08:08 +02:00
parent a694dd21ab
commit 7eb2c2e095
1 changed files with 12 additions and 4 deletions

View File

@ -11,13 +11,14 @@ from datetime import datetime, timedelta
from xeplib import load_xepinfos, Status from xeplib import load_xepinfos, Status
def do_archive(xeps_dir, attic, xep, old_version, new_version): def do_archive(xeps_dir, attic, xep, old_version, new_version, build):
curr_file = xeps_dir / "xep-{:04d}.html".format(xep) curr_file = xeps_dir / "xep-{:04d}.html".format(xep)
attic_file = attic / "xep-{:04d}-{}.html".format(xep, new_version) attic_file = attic / "xep-{:04d}-{}.html".format(xep, new_version)
print("XEP-{:04d}:".format(xep), old_version, "->", new_version) print("XEP-{:04d}:".format(xep), old_version, "->", new_version)
subprocess.check_call(["make", "build/xep-{:04d}.html".format(xep)]) if build:
subprocess.check_call(["make", "build/xep-{:04d}.html".format(xep)])
shutil.copy(str(curr_file), str(attic_file)) shutil.copy(str(curr_file), str(attic_file))
@ -55,6 +56,13 @@ def main():
help="Path to the attic (defaults to ../xep-attic/content/)" help="Path to the attic (defaults to ../xep-attic/content/)"
) )
parser.add_argument(
"--no-build",
action="store_false",
dest="build",
default=True,
)
parser.add_argument( parser.add_argument(
"xeps", "xeps",
nargs="*", nargs="*",
@ -89,7 +97,7 @@ def main():
continue continue
force_archive.discard(xep) force_archive.discard(xep)
do_archive(args.xeps_dir, args.attic, xep, old_version, new_version) do_archive(args.xeps_dir, args.attic, xep, old_version, new_version, args.build)
changed = True changed = True
for xep in force_archive: for xep in force_archive:
@ -98,7 +106,7 @@ def main():
) )
new_version = new_accepted[xep]["last_revision"]["version"] new_version = new_accepted[xep]["last_revision"]["version"]
do_archive(args.xeps_dir, args.attic, xep, old_version, new_version) do_archive(args.xeps_dir, args.attic, xep, old_version, new_version, args.build)
changed = True changed = True
if changed: if changed: