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:
parent
2dc799ecaa
commit
323a30d9e0
1 changed files with 13 additions and 1 deletions
14
crawl.py
14
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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue