From 7e3d9b90ef898702ccb12beafb82e794ddbc9db4 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: May 20 2020 20:21:20 +0000 Subject: spectool: code cosmetics and use black (with --line-length 100) This commit also adds a config file for black. --- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..aa4949a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 100 diff --git a/rpmdev-spectool b/rpmdev-spectool index ae64b70..2d4f43c 100755 --- a/rpmdev-spectool +++ b/rpmdev-spectool @@ -57,8 +57,7 @@ def get_args() -> dict: argcomplete = None parser = argparse.ArgumentParser( - description=HELP_TEXT, - formatter_class=argparse.RawDescriptionHelpFormatter, + description=HELP_TEXT, formatter_class=argparse.RawDescriptionHelpFormatter, ) ops = parser.add_argument_group("Operating mode") @@ -103,35 +102,19 @@ def get_args() -> dict: ) files.add_argument( - "--sources", - "-S", - action="store_const", - const=True, - default=False, - help="all sources", + "--sources", "-S", action="store_const", const=True, default=False, help="all sources", ) files.add_argument( - "--patches", - "-P", - action="store_const", - const=True, - default=False, - help="all patches", + "--patches", "-P", action="store_const", const=True, default=False, help="all patches", ) files.add_argument( - "--source", - "-s", - action="store", - help="specified sources", + "--source", "-s", action="store", help="specified sources", ) files.add_argument( - "--patch", - "-p", - action="store", - help="specified patches", + "--patch", "-p", action="store", help="specified patches", ) misc = parser.add_argument_group("Miscellaneous") @@ -189,10 +172,7 @@ def get_args() -> dict: help="output debug info, don't clean up when done", ) - specfile = parser.add_argument( - "specfile", - action="store", - ) + specfile = parser.add_argument("specfile", action="store") if argcomplete: specfile.completer = complete_spec_paths @@ -204,7 +184,7 @@ def get_args() -> dict: def split_numbers(args: str) -> list: - return list(arg for arg in args.split(",")) + return args.split(",") def get_file(url: str, path: str, force: bool) -> bool: @@ -336,6 +316,7 @@ def main() -> int: if args["debug"]: import pprint + print("Parsed command line arguments:") pprint.pprint(args) @@ -409,9 +390,11 @@ def main() -> int: if args["directory"]: directory = args["directory"] elif args["sourcedir"]: - ret = subprocess.run(["rpm", "--eval", "%{_sourcedir}"], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + ret = subprocess.run( + ["rpm", "--eval", "%{_sourcedir}"], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) ret.check_returncode() directory = ret.stdout.decode().strip() else: