From 323a30d9e08d82f3fd0d4fb14df82434d277993d Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 3 Apr 2026 15:23:02 +0100 Subject: [PATCH] Read build_dir from ~/.config/newegg-hdd/config Config file uses INI format: [newegg-hdd] build_dir = /path/to/output Falls back to output/ in the script directory if the config file or key is absent. Co-Authored-By: Claude Sonnet 4.6 --- crawl.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crawl.py b/crawl.py index 236537f..9e24331 100755 --- a/crawl.py +++ b/crawl.py @@ -2,6 +2,7 @@ """Crawl newegg.com for storage prices.""" import collections +import configparser import decimal import logging import os @@ -332,9 +333,20 @@ def group_items( yield {"name": name, "label": label, "items": items} +def get_build_root() -> str: + """Read build_dir from ~/.config/newegg-hdd/config, fall back to output/.""" + config_path = os.path.expanduser("~/.config/newegg-hdd/config") + if os.path.exists(config_path): + config = configparser.ConfigParser() + config.read(config_path) + if config.has_option("newegg-hdd", "build_dir"): + return config.get("newegg-hdd", "build_dir") + return os.path.join(root_dir, "output") + + def build() -> None: """Build.""" - build_root = os.path.join(root_dir, "output") + build_root = get_build_root() today = date.today() templates_dir = os.path.join(root_dir, "templates")