export_logistics.py 752 B

12345678910111213141516171819202122232425262728
  1. from __future__ import annotations
  2. import sys
  3. import typing
  4. import cache
  5. import supply
  6. def main() -> None:
  7. (fio_burn,) = supply.get_fio_burn([sys.argv[1]])
  8. planet = supply.Planet(fio_burn)
  9. materials: typing.Mapping[str, supply.Material] = {mat['Ticker']: mat
  10. for mat in cache.get('https://rest.fnar.net/material/allmaterials')}
  11. total_weight = total_volume = 0.0
  12. for mat in planet.exporting:
  13. if amount := planet.inventory.get(mat):
  14. weight = amount * materials[mat]['Weight']
  15. volume = amount * materials[mat]['Volume']
  16. print(f'{mat:3} {amount:5,} {weight:5.2f}t {volume:5.2f}m³')
  17. total_weight += weight
  18. total_volume += volume
  19. print(f'total {total_weight:.2f}t {total_volume:.2f}m³')
  20. if __name__ == '__main__':
  21. main()