updated the config files to a tempalte/local standard format

This commit is contained in:
2026-08-18 13:53:28 -05:00
parent 07472711e7
commit 5e0fbdbf70
11 changed files with 42 additions and 4 deletions

View File

@@ -5,11 +5,13 @@ Shared configuration, logging, and utilities for the FCCS extraction tool.
import os
import re
import sys
import shutil
import argparse
import configparser
from datetime import datetime
DEFAULT_CONFIG = "config.ini"
TEMPLATE_CONFIG = "config.template.ini"
def parse_args():
@@ -24,12 +26,31 @@ def parse_args():
def load_config(path=None):
"""Read config.ini and return a ConfigParser object."""
"""Read the config file and return a ConfigParser object.
Config is split into two files:
- config.template.ini : tracked in git, the pristine template.
- config.ini : git-ignored, this machine's working copy.
When no explicit --config path is given, the per-machine config.ini is used.
If it doesn't exist yet, it's created from config.template.ini so a freshly
cloned/pulled repo works out of the box without editing the tracked file.
Edit config.ini locally; your changes never drift the repo.
"""
if path is None:
script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
path = os.path.join(script_dir, DEFAULT_CONFIG)
# Auto-create the per-machine config from the template on first run.
if not os.path.exists(path):
template = os.path.join(script_dir, TEMPLATE_CONFIG)
if os.path.exists(template):
shutil.copyfile(template, path)
print(f"Created {DEFAULT_CONFIG} from {TEMPLATE_CONFIG}. "
f"Edit it for this machine's settings: {path}")
if not os.path.exists(path):
print(f"ERROR: config file not found: {path}")
print(f" Expected {DEFAULT_CONFIG} or a --config path "
f"(template: {TEMPLATE_CONFIG}).")
sys.exit(1)
cfg = configparser.ConfigParser()
cfg.read(path, encoding="utf-8")