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 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-04-03 15:23:02 +01:00
parent 2dc799ecaa
commit 323a30d9e0

View file

@ -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")