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