changeset 167:ffd14e2de130

Formatting
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 09 Jan 2025 14:17:01 +0100
parents ed45abb4940f
children bcc4441cf216
files cutils/shasum.py
diffstat 1 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/shasum.py	Thu Jan 09 14:06:01 2025 +0100
+++ b/cutils/shasum.py	Thu Jan 09 14:17:01 2025 +0100
@@ -33,16 +33,21 @@
         fromfile_prefix_chars='@')
     aparser.add_argument(
         "--algorithm", "-a", action="store", type=util.argv2algo,
-        help="1 (default, aka sha1), 224, 256, 384, 512, 3 (alias for sha3-512), 3-224, 3-256, 3-384, 3-512, blake2b, blake2b-256, blake2s, blake2 (alias for blake2b), blake2-256 (alias for blake2b-256), md5")
+        help="""1 (default, aka sha1), 224, 256, 384, 512,
+3 (alias for sha3-512), 3-224, 3-256, 3-384, 3-512,
+blake2b, blake2b-256, blake2s, blake2 (alias for blake2b),
+blake2-256 (alias for blake2b-256), md5""")
     aparser.add_argument(
         "--base64", action="store_true",
         help="Output checksums in base64 notation, not hexadecimal (OpenBSD).")
     aparser.add_argument(
-        "--binary", "-b", action="store_false", dest="text_mode", default=False,
+        "--binary", "-b", action="store_false", dest="text_mode",
+        default=False,
         help="Read in binary mode (default)")
     aparser.add_argument(
         "--bsd", "-B", action="store_true", dest="bsd", default=False,
-        help="Write BSD style output. This is also the default output format of :command:`openssl dgst`.")
+        help="""Write BSD style output. This is also the default output format
+of :command:`openssl dgst`.""")
     aparser.add_argument(
         "--check", "-c", action="store_true",
         help="""Read digests from FILEs and check them.
@@ -60,11 +65,13 @@
     aparser.add_argument(
         "--checklist-allow-distinfo", action="store_true",
         dest="allow_distinfo",
-        help='Allow FreeBSD "distinfo" formatted checklists: ignore SIZE and TIMESTAMP lines.')
+        help='''Allow FreeBSD "distinfo" formatted checklists:
+ignore SIZE and TIMESTAMP lines.''')
 
     aparser.add_argument(
         "--follow-symlinks", action="store_true", dest="follow_symlinks",
-        help="""Also follow symlinks that resolve to directories. Only effective if `--recurse` is activated.""")
+        help="""Also follow symlinks that resolve to directories.
+Only effective if `--recurse` is activated.""")
 
     aparser.add_argument(
         "--mmap", action="store_true", dest="mmap", default=None,
@@ -76,19 +83,24 @@
 
     aparser.add_argument(
         "--recurse", action="store_true",
-        help="Recurse into sub-directories while interpreting every FILE as a directory.")
+        help="""Recurse into sub-directories while interpreting every
+FILE as a directory.""")
 
     aparser.add_argument(
         "--reverse", "-r", action="store_false", dest="bsd", default=False,
-        help="Explicitely select normal coreutils style output (to be option compatible with BSD style commands and :command:`openssl dgst -r`)")
+        help="""Explicitely select normal coreutils style output
+(to be option compatible with BSD style commands and
+:command:`openssl dgst -r`)""")
     aparser.add_argument(
         "--tag", action="store_true", dest="bsd", default=False,
-        help="Alias for the `--bsd' option (to be compatible with :command:`b2sum`)")
+        help="""Alias for the `--bsd' option (to be compatible with
+:command:`b2sum`)""")
     aparser.add_argument(
         "--text", "-t", action="store_true", dest="text_mode", default=False,
         help="Read in text mode (not supported)")
     aparser.add_argument(
-        "--version", "-v", action="version", version="%s (rv:%s)" % (__version__, __revision__))
+        "--version", "-v", action="version",
+        version="%s (rv:%s)" % (__version__, __revision__))
     aparser.add_argument(
         "files", nargs="*", metavar="FILE")
 
@@ -227,7 +239,7 @@
         else:
             # base64
             if re.search(
-                    r"\A(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?\Z",
+                    r"\A(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?\Z",    # noqa: E501  line too long
                     expected_digest):
                 try:
                     exd = base64.b64decode(expected_digest)
@@ -264,7 +276,8 @@
             print("{}: {}: {}".format(tag, "-", res), file=dest)
     else:
         for fn in opts.files:
-            pl = get_parsed_digest_line_from_checklist(opts.checklist, opts, fn)
+            pl = get_parsed_digest_line_from_checklist(
+                opts.checklist, opts, fn)
             if pl is None:
                 print("{}: MISSING".format(fn), file=dest)
                 exit_code = 1
@@ -353,7 +366,8 @@
             if parts[0] in ("SIZE", "TIMESTAMP"):
                 assert opts.allow_distinfo
                 continue
-            fn = util.normalize_filename(parts[2], strip_leading_dot_slash=True)
+            fn = util.normalize_filename(
+                parts[2], strip_leading_dot_slash=True)
             if fn in filenames:
                 return parts
         else:
@@ -432,9 +446,9 @@
     else:
         digest = binascii.hexlify(digest).decode("ascii")
     print("{} {}{}".format(
-                digest,
-                '*' if binary else ' ',
-                '-' if filename is None else util.normalize_filename(filename)),
+              digest,
+              '*' if binary else ' ',
+              '-' if filename is None else util.normalize_filename(filename)),
           file=dest)