# HG changeset patch # User Franz Glasner # Date 1743028928 -3600 # Node ID 8e62738e746949afc9e3c23d4d5bf9636ab472d1 # Parent a464f36fffcb68f4e8e249e40e58aaae1e41d601 treesum: implement option "--output-style". Currently only the existing output writer implementing the BSD style tagged output is allowed. diff -r a464f36fffcb -r 8e62738e7469 cutils/treesum.py --- a/cutils/treesum.py Wed Mar 26 23:06:05 2025 +0100 +++ b/cutils/treesum.py Wed Mar 26 23:42:08 2025 +0100 @@ -166,6 +166,13 @@ help="Put the checksum into given file. " "If not given or if it is given as `-' then stdout is used.") gp.add_argument( + "--output-style", dest="output_style", default="tagged", + choices=("tagged", "tag"), + help=""" +Select the output style: "tagged" or "tag" selects BSD style tagged format. +Default is "tagged". +""") + gp.add_argument( "--physical", "-P", action=SymlinkAction, dest="follow_symlinks", const=FollowSymlinkConfig(False, False, False), help="""Do not follow any symbolic links whether they are given @@ -429,6 +436,7 @@ mmap=None, mtime=False, output=None, + output_style="tagged", print_size=False, size_only=False, utf8=False): @@ -446,6 +454,9 @@ "every kind of every item in `fnmatch_filters' must be" " \"include\", \"exclude\" or \"accept-treesum\"" ) + if output_tyle not in ("tagged", "tag"): + raise ValueError( + "given output_style `%s' not allowed" % (output_style,)) # Not following symlinks to files is not yet supported: reset to True # if not follow_symlinks.file: @@ -469,6 +480,7 @@ metadata_mode=mode, metadata_mtime=mtime, output=output, + output_style=output_style, print_size=print_size, size_only=size_only, utf8=utf8) @@ -516,6 +528,8 @@ fnmatcher = fnmatch.FnMatcher.build_from_commandline_patterns( opts.fnmatch_filters) + assert opts.output_style in ("tagged", "tag") + with out_cm as outfp: writer = TaggedTreesumWriter(outfp) for d in opts.directories: