|
|
@@ -1,5 +1,6 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
+import collections
|
|
|
import sys
|
|
|
import typing
|
|
|
|
|
|
@@ -10,19 +11,17 @@ def main() -> None:
|
|
|
|
|
|
recipes: list[Recipe] = cache.get('https://api.prunplanner.org/data/recipes')
|
|
|
companies: dict[str, dict[str, CompanyOutput]] = cache.get(
|
|
|
- 'https://pmmg-products.github.io/reports/data/company-data-oct25.json')['individual']
|
|
|
+ 'https://pmmg-products.github.io/reports/data/company-data-dec25.json')['individual']
|
|
|
|
|
|
print(mat, '→')
|
|
|
- wrought = (recipe for recipe in recipes if mat in (i['Ticker'] for i in recipe['Inputs']))
|
|
|
+ wrought = (recipe for recipe in recipes if mat in (i['Ticker'] for i in recipe['Inputs']) and len(recipe['Outputs']) == 1)
|
|
|
output_mats = {}
|
|
|
- for recipe in wrought:
|
|
|
- if len(recipe['Outputs']) != 1:
|
|
|
- continue
|
|
|
+ for recipe in sorted(wrought, key=lambda r: r['Outputs'][0]['Ticker']):
|
|
|
(output,) = recipe['Outputs']
|
|
|
(input,) = (i for i in recipe['Inputs'] if i['Ticker'] == mat)
|
|
|
ratio = input['Amount'] / output['Amount']
|
|
|
output_mats[output['Ticker']] = ratio
|
|
|
- print(f'\t{output["Ticker"]}:', ratio)
|
|
|
+ print(f'\t{output["Ticker"]:3}:', ratio)
|
|
|
|
|
|
companies_produced = companies_consumed = companies_consumed_80 = 0
|
|
|
into = dict.fromkeys(output_mats.keys(), 0)
|
|
|
@@ -43,8 +42,17 @@ def main() -> None:
|
|
|
print(f'{companies_produced} companies producing')
|
|
|
print(f'{companies_consumed} companies consuming their own production')
|
|
|
print(f'{companies_consumed_80} companies consuming 80%+ of their own production')
|
|
|
- for output_mat, total in into.items():
|
|
|
- print(f'{output_mat}:', total)
|
|
|
+
|
|
|
+ recipes_per_output = collections.defaultdict(int)
|
|
|
+ for recipe in recipes:
|
|
|
+ for output in recipe['Outputs']:
|
|
|
+ if output['Ticker'] in into:
|
|
|
+ recipes_per_output[output['Ticker']] += 1
|
|
|
+ for output_mat, total in sorted(into.items(), key=lambda kv: kv[1], reverse=True):
|
|
|
+ alt = ''
|
|
|
+ if (recipe_count := recipes_per_output[output_mat]) != 1:
|
|
|
+ alt = f' ({recipe_count} recipes)'
|
|
|
+ print(f'{output_mat:3}: {total:8,.0f}{alt}')
|
|
|
|
|
|
class CompanyOutput(typing.TypedDict):
|
|
|
amount: int
|