فهرست منبع

supply: ignore materials

also restructure config
raylu 2 روز پیش
والد
کامیت
76b9b78ea1
4فایلهای تغییر یافته به همراه24 افزوده شده و 2 حذف شده
  1. 15 1
      config.py
  2. 1 1
      market.py
  3. 6 0
      readme.md
  4. 2 0
      supply.py

+ 15 - 1
config.py

@@ -8,12 +8,26 @@ import typing
 class Config:
     username: str
     fio_api_key: str
-    ignore_warehouses: typing.Sequence[str]
+    market: MarketConfig
+    supply: SupplyConfig
 
     def __init__(self) -> None:
         with open('config.toml', 'rb') as f:
             config = tomllib.load(f)
         for k, v in config.items():
+            match k:
+                case 'market':
+                    v = MarketConfig(**v)
+                case 'supply':
+                    v = SupplyConfig(**v)
             object.__setattr__(self, k, v)
 
+@dataclasses.dataclass(eq=False, frozen=True, slots=True)
+class MarketConfig:
+    ignore_warehouses: typing.Sequence[str]
+
+@dataclasses.dataclass(eq=False, frozen=True, slots=True)
+class SupplyConfig:
+    ignore_materials: typing.Sequence[str]
+
 config = Config()

+ 1 - 1
market.py

@@ -68,7 +68,7 @@ def check_cxos() -> None:
 	warehouses: typing.Sequence[Warehouse] = cache.get('https://rest.fnar.net/sites/warehouses/' + config.username,
 			headers={'Authorization': config.fio_api_key})
 	for warehouse in warehouses:
-		if warehouse['LocationNaturalId'] in config.ignore_warehouses:
+		if warehouse['LocationNaturalId'] in config.market.ignore_warehouses:
 			continue
 		storage: Storage = cache.get(f'https://rest.fnar.net/storage/{config.username}/{warehouse["StoreId"]}',
 			headers={'Authorization': config.fio_api_key})

+ 6 - 0
readme.md

@@ -6,6 +6,12 @@ get a FIO API key from https://fio.fnar.net/settings and create a `config.toml`
 ```toml
 username = 'raylu'
 fio_api_key = 'uuid_here'
+
+[market]
+ignore_warehouses = ['HRT']
+
+[supply]
+ignore_materials = ['RAT']
 ```
 
 `uv run supply.py promitor`

+ 2 - 0
supply.py

@@ -179,6 +179,8 @@ class Planet:
 				if net < 0:
 					continue
 			c['net_consumption'] = net
+			if c['MaterialTicker'] in config.supply.ignore_materials:
+				continue
 			self.net_consumption.append(c)
 
 	def buy_for_target(self, target_days: float) -> dict[str, int]: