reconfigured the Folder Templates for git so that the engagement specific template file doesnt cause Master branch sync issues
This commit is contained in:
@@ -14,6 +14,24 @@ DEFAULT_CONFIG = "config.ini"
|
||||
TEMPLATE_CONFIG = "config.template.ini"
|
||||
|
||||
|
||||
def ensure_from_template(path, template):
|
||||
"""Create a per-machine working file from its git-tracked template.
|
||||
|
||||
If `path` doesn't exist but `template` does, copy template -> path and
|
||||
announce it. Returns True if the file exists (or was just created).
|
||||
Used for config.ini and fccs_folders.txt so local edits never drift the
|
||||
repo — the working copies are git-ignored, only the templates are tracked.
|
||||
"""
|
||||
if os.path.exists(path):
|
||||
return True
|
||||
if os.path.exists(template):
|
||||
shutil.copyfile(template, path)
|
||||
print(f"Created {os.path.basename(path)} from "
|
||||
f"{os.path.basename(template)}. Edit it for this machine: {path}")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def parse_args():
|
||||
"""Parse the optional --config argument common to all scripts."""
|
||||
parser = argparse.ArgumentParser()
|
||||
@@ -41,12 +59,7 @@ def load_config(path=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}")
|
||||
ensure_from_template(path, os.path.join(script_dir, TEMPLATE_CONFIG))
|
||||
if not os.path.exists(path):
|
||||
print(f"ERROR: config file not found: {path}")
|
||||
print(f" Expected {DEFAULT_CONFIG} or a --config path "
|
||||
@@ -71,9 +84,17 @@ def make_logger(log_file):
|
||||
|
||||
|
||||
def load_folder_list(path):
|
||||
"""Load known FCCS folder names from file, one per line."""
|
||||
if not os.path.exists(path):
|
||||
"""Load known FCCS folder names from file, one per line.
|
||||
|
||||
Like config.ini, the folder list is split into a tracked template
|
||||
(fccs_folders.template.txt) and a git-ignored per-engagement working copy
|
||||
(fccs_folders.txt) — auto-created from the template on first use.
|
||||
"""
|
||||
root, ext = os.path.splitext(path)
|
||||
template = root + ".template" + ext
|
||||
if not ensure_from_template(path, template):
|
||||
print(f"ERROR: folder list file not found: {path}")
|
||||
print(f" (no template found at {template} to create it from)")
|
||||
sys.exit(1)
|
||||
folders = []
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
|
||||
Reference in New Issue
Block a user