tof-voters: simplify sub-command loading
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I10a0ba59fda4c40680ee1445f28a98d9eee2ff67
diff --git a/tof-voters/libvoters/entry_point.py b/tof-voters/libvoters/entry_point.py
index 1a4e049..1dd50c3 100644
--- a/tof-voters/libvoters/entry_point.py
+++ b/tof-voters/libvoters/entry_point.py
@@ -4,14 +4,6 @@
from importlib import import_module
from typing import List
-subcommands = [
- "analyze-commits",
- "analyze-reviews",
- "dump-gerrit",
- "report",
-]
-
-
def main() -> int:
parser = argparse.ArgumentParser(description="Obtain TOF voter metrics")
parser.add_argument(
@@ -24,11 +16,13 @@
subparser = parser.add_subparsers(help="Available subcommands")
- commands = []
- for c in subcommands:
- commands.append(
- import_module("libvoters.subcmd." + c).subcmd(subparser) # type: ignore
- )
+ commands = [
+ import_module("libvoters.subcmd.analyze-commits"),
+ import_module("libvoters.subcmd.analyze-reviews"),
+ import_module("libvoters.subcmd.dump-gerrit"),
+ import_module("libvoters.subcmd.report"),
+ ]
+ commands = [x.subcmd(subparser) for x in commands] # type: ignore
args = parser.parse_args()