Browse Source

company: group output by expertise

raylu 6 days ago
parent
commit
d8589f6cac
1 changed files with 10 additions and 2 deletions
  1. 10 2
      company.py

+ 10 - 2
company.py

@@ -28,10 +28,18 @@ def main() -> None:
 	print()
 	print()
 
 
 	company_report = integration.pmmg_monthly_report()[company['CompanyId']]
 	company_report = integration.pmmg_monthly_report()[company['CompanyId']]
+	report_by_expertise: dict[str | None, dict[str, int]] = collections.defaultdict(dict)
 	for mat, production in company_report.items():
 	for mat, production in company_report.items():
 		expertise = experts.get(mat)
 		expertise = experts.get(mat)
-		print(f'{mat:3} {production["amount"]:8,.0f} {expertise or '':19}',
-				', '.join(cogc_planets.get(expertise, []))) # pyright: ignore[reportArgumentType, reportCallIssue]
+		report_by_expertise[expertise][mat] = production['amount']
+
+	for expertise, sub_report in report_by_expertise.items():
+		print(expertise, end=' ')
+		if expertise is not None:
+			print(', '.join(cogc_planets.get(expertise, [])), end='')
+		print()
+		for mat, amount in sub_report.items():
+			print(f'\t{mat:3} {amount:9,.1f}')
 
 
 def iter_planet_cogc() -> typing.Iterator[tuple[Planet, Expertise | None]]:
 def iter_planet_cogc() -> typing.Iterator[tuple[Planet, Expertise | None]]:
 	all_planets: typing.Collection[Planet] = cache.get('https://universemap.taiyibureau.de/planet_data.json',
 	all_planets: typing.Collection[Planet] = cache.get('https://universemap.taiyibureau.de/planet_data.json',