Bläddra i källkod

buy: take days as argument

raylu 2 veckor sedan
förälder
incheckning
72593673c9
1 ändrade filer med 5 tillägg och 3 borttagningar
  1. 5 3
      buy.py

+ 5 - 3
buy.py

@@ -3,6 +3,7 @@ from __future__ import annotations
 import collections
 import concurrent.futures
 import dataclasses
+import sys
 import typing
 
 import cache
@@ -13,10 +14,11 @@ if typing.TYPE_CHECKING:
 	import market
 
 def main() -> None:
+	days = int(sys.argv[1])
 	with concurrent.futures.ThreadPoolExecutor() as executor:
 		futures = [
 			executor.submit(get_raw_prices),
-			executor.submit(get_total_buy), # what we need to buy
+			executor.submit(get_total_buy, days), # what we need to buy
 			executor.submit(supply.warehouse_inventory), # what we have
 			executor.submit(get_planet_exports_and_ship_storage),
 			executor.submit(get_bids), # what we already are bidding for
@@ -56,12 +58,12 @@ def get_raw_prices() -> typing.Mapping[str, market.RawPrice]:
 	return {p['MaterialTicker']: p
 			for p in cache.get('https://refined-prun.github.io/refined-prices/all.json') if p['ExchangeCode'] == 'IC1'}
 
-def get_total_buy() -> typing.Mapping[str, int]:
+def get_total_buy(days: int) -> typing.Mapping[str, int]:
 	planets = [supply.Planet(fio_burn) for fio_burn in cache.get('https://rest.fnar.net/fioweb/burn/user/' + config.username,
 			headers={'Authorization': config.fio_api_key})]
 	buy: dict[str, int] = collections.defaultdict(int)
 	for planet in planets:
-		for mat, amount in planet.supply_for_days(7).items():
+		for mat, amount in planet.supply_for_days(days).items():
 			buy[mat] += amount
 	return buy