summaryrefslogtreecommitdiff
path: root/scripts/setup_eve_data.py
diff options
context:
space:
mode:
authorkboz <kutayboz@gmail.com>2026-04-19 01:50:32 +0200
committerkboz <kutayboz@gmail.com>2026-04-19 01:50:32 +0200
commitacbf6d6bd6d63ab0e9f7c4e119827f76e0382aac (patch)
tree9d2f74608ae4b910a480648c7bd95fdf6c403389 /scripts/setup_eve_data.py
parent8cc70dfee2049772a2da9cfdeb15f64452bc390b (diff)
downloadhaul-acbf6d6bd6d63ab0e9f7c4e119827f76e0382aac.tar.gz
feat(backend): unify boot process and refactor route properties
- Added scripts/haul.sh, setup_auth.py, and setup_eve_data.py for simplified SSO and CSV data bootstrapping. - Refactored `Ship` and `RouteStep` properties across route planning modules to utilize dictionaries instead of strict dataclass attributes. - Re-aligned route limits, reducing upfront capital risk values in `arbitrage.py` and updating ship metrics in `manager.py`. - Updated `.gitignore`, `.env.example`, and created AI-assistant prompt configuration. - Added comprehensive "Getting Started" guides to the README and initialized CHANGELOG.md.
Diffstat (limited to 'scripts/setup_eve_data.py')
-rw-r--r--scripts/setup_eve_data.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/setup_eve_data.py b/scripts/setup_eve_data.py
new file mode 100644
index 0000000..a7f7efd
--- /dev/null
+++ b/scripts/setup_eve_data.py
@@ -0,0 +1,55 @@
+from __future__ import annotations
+
+import bz2
+import shutil
+import sys
+import urllib.request
+from pathlib import Path
+
+
+ROOT_DIR = Path(__file__).resolve().parent.parent
+DATA_DIR = ROOT_DIR / "backend" / "data"
+BASE_URL = "https://www.fuzzwork.co.uk/dump/latest"
+
+REQUIRED_FILES = {
+ "mapDenormalize.csv": f"{BASE_URL}/mapDenormalize.csv.bz2",
+ "mapJumps.csv": f"{BASE_URL}/mapJumps.csv.bz2",
+ "invTypes.csv": f"{BASE_URL}/invTypes.csv.bz2",
+ "mapRegions.csv": f"{BASE_URL}/mapRegions.csv.bz2",
+}
+
+
+def download_and_extract(file_name: str, url: str) -> None:
+ destination = DATA_DIR / file_name
+ archive_path = destination.with_suffix(destination.suffix + ".bz2")
+
+ if destination.exists():
+ print(f"Skipping {file_name}; already exists.")
+ return
+
+ print(f"Downloading {file_name} from {url}")
+
+ try:
+ with urllib.request.urlopen(url, timeout=60) as response, archive_path.open("wb") as output_file:
+ shutil.copyfileobj(response, output_file)
+
+ with bz2.open(archive_path, "rb") as compressed_file, destination.open("wb") as output_file:
+ shutil.copyfileobj(compressed_file, output_file)
+ finally:
+ archive_path.unlink(missing_ok=True)
+
+ print(f"Wrote {destination}")
+
+
+def main() -> int:
+ DATA_DIR.mkdir(parents=True, exist_ok=True)
+
+ for file_name, url in REQUIRED_FILES.items():
+ download_and_extract(file_name, url)
+
+ print("EVE static data is ready.")
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main()) \ No newline at end of file