summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-12-01 21:46:29 -0500
committerBen Sima <ben@bsima.me>2024-12-21 10:08:01 -0500
commitaafa73c47325185ed733da387c9649d934f6529c (patch)
treebc2e180afa7151b736a02a37701b731baf9ce795 /Biz
parent2ed757bc8c60fad0f2bf9d07478e2a287b7e24aa (diff)
Test Python code with bild --test
I had forgotten to add this feature, apparently, so bild --test just didn't do the test part.
Diffstat (limited to 'Biz')
-rw-r--r--Biz/Dragons/main.py31
-rw-r--r--Biz/Que/Client.py19
2 files changed, 30 insertions, 20 deletions
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()