From aafa73c47325185ed733da387c9649d934f6529c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sun, 1 Dec 2024 21:46:29 -0500 Subject: Test Python code with bild --test I had forgotten to add this feature, apparently, so bild --test just didn't do the test part. --- Biz/Dragons/main.py | 31 ++++++++++++++++++------------- Biz/Que/Client.py | 19 ++++++++++++------- 2 files changed, 30 insertions(+), 20 deletions(-) (limited to 'Biz') diff --git a/Biz/Dragons/main.py b/Biz/Dragons/main.py index f85d9e7..e9df03f 100644 --- a/Biz/Dragons/main.py +++ b/Biz/Dragons/main.py @@ -225,27 +225,32 @@ def guard_git(repo: Repo) -> None: sys.exit(f"error: not a git repository: {repo}") -if __name__ == "__main__": - ARGS = get_args() - if ARGS.test: +def main() -> None: + """Entrypoint.""" + args = get_args() + if args.test: sys.stdout.write("ok") sys.exit() - logging.basicConfig(stream=sys.stderr, level=ARGS.verbosity.upper()) + logging.basicConfig(stream=sys.stderr, level=args.verbosity.upper()) logging.debug("starting") - os.chdir(pathlib.Path(ARGS.repo).resolve()) + os.chdir(pathlib.Path(args.repo).resolve()) - guard_git(ARGS.repo) + guard_git(args.repo) # if no active users provided, load from .mailmap - if ARGS.active_users == [] and pathlib.Path(".mailmap").exists(): - ARGS.active_users = mailmap_users() + if args.active_users == [] and pathlib.Path(".mailmap").exists(): + args.active_users = mailmap_users() # collect data - REPO = Repo(ARGS.ignored, ARGS.active_users) + repo = Repo(args.ignored, args.active_users) # print data - REPO.print_score() - REPO.print_blackholes(full=ARGS.blackholes) - REPO.print_liabilities(full=ARGS.liabilities) - REPO.print_stale(full=ARGS.stale) + repo.print_score() + repo.print_blackholes(full=args.blackholes) + repo.print_liabilities(full=args.liabilities) + repo.print_stale(full=args.stale) + + +if __name__ == "__main__": + main() diff --git a/Biz/Que/Client.py b/Biz/Que/Client.py index 9620c5e..ccbb980 100644 --- a/Biz/Que/Client.py +++ b/Biz/Que/Client.py @@ -215,21 +215,26 @@ def get_args() -> argparse.Namespace: return cli.parse_args() -if __name__ == "__main__": - ARGV = get_args() - if ARGV.test: +def main() -> None: + """Entrypoint.""" + argv = get_args() + if argv.test: sys.stdout.write("ok\n") sys.exit() - if ARGV.debug: + if argv.debug: logging.basicConfig( format="%(asctime)s: %(levelname)s: %(message)s", level=logging.DEBUG, datefmt="%Y.%m.%d..%H.%M.%S", ) try: - if ARGV.infile: - send(ARGV) + if argv.infile: + send(argv) else: - recv(ARGV) + recv(argv) except KeyboardInterrupt: sys.exit(0) + + +if __name__ == "__main__": + main() -- cgit v1.2.3