1 from bugzilla
import Bugzilla
4 from pathlib
import Path
5 from budget_sync
.util
import all_bugs
6 from budget_sync
.config
import Config
, ConfigParseError
7 from budget_sync
.budget_graph
import BudgetGraph
, BudgetGraphBaseError
8 from budget_sync
.write_budget_markdown
import write_budget_markdown
12 parser
= argparse
.ArgumentParser(
13 description
="Check for errors in "
14 "Libre-SOC's style of budget tracking in Bugzilla.")
16 "-c", "--config", type=argparse
.FileType('r'),
17 required
=True, help="The path to the configuration TOML file",
18 dest
="config", metavar
="<path/to/budget-sync-config.toml>")
20 "-o", "--output-dir", type=Path
, default
=None,
21 help="The path to the output directory, will be created if it "
23 dest
="output_dir", metavar
="<path/to/output/dir>")
24 args
= parser
.parse_args()
26 with args
.config
as config_file
:
27 config
= Config
.from_file(config_file
)
28 except (IOError, ConfigParseError
) as e
:
29 logging
.error("Failed to parse config file: %s", e
)
31 logging
.info("Using Bugzilla instance at %s", config
.bugzilla_url
)
32 bz
= Bugzilla(config
.bugzilla_url
)
33 logging
.debug("Connected to Bugzilla")
34 budget_graph
= BudgetGraph(all_bugs(bz
), config
)
35 for error
in budget_graph
.get_errors():
36 logging
.error("%s", error
)
37 if args
.output_dir
is not None:
38 write_budget_markdown(budget_graph
, args
.output_dir
)
40 # quick hack to display total payment amounts per-milestone
41 for milestone
, payments
in budget_graph
.milestone_payments
.items():
45 for payment
in payments
:
47 total
+= payment
.amount
50 if __name__
== "__main__":