Skip to content

Commit 4cce631

Browse files
committed
python legalcode tools update
- cc0_update.py - added support for user-specified files (helpful for development) - avoid blanklines when there is no diff - cc4_update.py - replaces prep_cc4_code.py and update_cc4_includes.py - adds file newline normalization - adds languages anchor normalization - adds faq translation link normalization - improves missing comment insertion
1 parent f2e09de commit 4cce631

File tree

4 files changed

+616
-628
lines changed

4 files changed

+616
-628
lines changed

tools/cc0_update.py

+24-6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def diff_changes(filename, old, new):
5959
n=3,
6060
)
6161
)
62+
if not diff:
63+
return
6264
# Color diff output
6365
rst = "\033[0m"
6466
for i, line in enumerate(diff):
@@ -350,26 +352,42 @@ def setup():
350352
351353
Return argsparse namespace.
352354
"""
355+
default_glob = ["zero_1.0*.html"]
353356
ap = argparse.ArgumentParser(description=__doc__)
354357
ap.add_argument(
355358
"-d",
356359
"--debug",
357360
action="store_true",
358361
help="Debug mode: list changes without modification",
359362
)
363+
ap.add_argument(
364+
"globs",
365+
nargs="*",
366+
default=default_glob,
367+
help=(
368+
"Filename or shell glob of the file(s) that will be updated"
369+
f' (default: "{default_glob[0]}")'
370+
),
371+
metavar="FILENAME",
372+
)
360373
args = ap.parse_args()
361374
return args
362375

363376

364377
def main():
365378
args = setup()
366379
file_list = sorted(
367-
[
368-
filename
369-
for filename in glob.glob("zero_1.0*.html")
370-
if os.path.isfile(filename)
371-
if not os.path.islink(filename)
372-
]
380+
list(
381+
set(
382+
[
383+
filename
384+
for fileglob in args.globs
385+
for filename in glob.glob(fileglob)
386+
if os.path.isfile(filename)
387+
if not os.path.islink(filename)
388+
]
389+
)
390+
)
373391
)
374392
lang_tags = lang_tags_from_filenames(file_list)
375393
process_file_contents(args, file_list, lang_tags)

0 commit comments

Comments
 (0)