From 71ffc1fbb536f3f072983275b4a0b522a1741cc6 Mon Sep 17 00:00:00 2001 From: dat972 Date: Thu, 20 Aug 2026 22:07:55 -0500 Subject: [PATCH] reconfigured the Folder Templates for git so that the engagement specific template file doesnt cause Master branch sync issues --- .gitignore | 3 ++ README.md | 5 ++- fccs_config.py | 37 +++++++++++++++---- fccs_folders.txt => fccs_folders.template.txt | 6 ++- 4 files changed, 40 insertions(+), 11 deletions(-) rename fccs_folders.txt => fccs_folders.template.txt (70%) diff --git a/.gitignore b/.gitignore index a023691..3acf7d5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ config.ini # Python bytecode cache __pycache__/ *.pyc + +# Per-engagement folder list (created from fccs_folders.template.txt on first run) +fccs_folders.txt diff --git a/README.md b/README.md index e285bf2..439802b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Extracts and organizes documents from FileCabinet CS (Thomson Reuters) using GUI |------|---------| | `config.template.ini` | Tracked template for all paths, timeouts, and FCCS control identifiers | | `config.ini` | Per-machine working config (git-ignored; auto-created from the template) | -| `fccs_folders.txt` | FCCS folder templates (manually populated per engagement) | +| `fccs_folders.template.txt` | Tracked template for FCCS folder names | +| `fccs_folders.txt` | Per-engagement folder list (git-ignored; auto-created from the template) | | `fccs_config.py` | Shared config loading, logging, folder pattern building | | `fccs_scan.py` | Step 1: Scan backup directory for drawer IDs | | `fccs_export.py` | Step 2: Automate FCCS GUI to export all drawers | @@ -28,7 +29,7 @@ Extracts and organizes documents from FileCabinet CS (Thomson Reuters) using GUI ## Setup Per Engagement 1. Edit `config.ini` -- point `backup_dir`, `export_dir`, and `output_dir` at the client's directories. This file is created automatically from `config.template.ini` the first time you run any script (it's git-ignored, so your machine-specific paths never drift the repo). To reset a machine, delete `config.ini` and re-run. Keep shared/default changes in `config.template.ini` (the tracked file). -2. Populate `fccs_folders.txt` -- open FCCS > System Configuration > Document Folders and list each folder template exactly as shown, one per line. Keep the `YYYY` prefix on recurring folders. UltraTax CS folders are detected automatically and do not need to be listed. +2. Populate `fccs_folders.txt` -- open FCCS > System Configuration > Document Folders and list each folder template exactly as shown, one per line. Keep the `YYYY` prefix on recurring folders. UltraTax CS folders are detected automatically and do not need to be listed. Like `config.ini`, this file is auto-created from `fccs_folders.template.txt` on first use and is git-ignored — edit it freely per engagement; put only broadly-useful defaults in the tracked template. ## Workflow diff --git a/fccs_config.py b/fccs_config.py index 657bea9..780e344 100644 --- a/fccs_config.py +++ b/fccs_config.py @@ -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: diff --git a/fccs_folders.txt b/fccs_folders.template.txt similarity index 70% rename from fccs_folders.txt rename to fccs_folders.template.txt index a64d821..977158c 100644 --- a/fccs_folders.txt +++ b/fccs_folders.template.txt @@ -1,5 +1,9 @@ -# FCCS Folder Templates +# FCCS Folder Templates — TEMPLATE (tracked in git; do NOT edit per-engagement) # --------------------- +# On first run the scripts copy this file to fccs_folders.txt (git-ignored) and +# use that. Edit fccs_folders.txt for the current engagement so local changes +# never drift the repo. Delete fccs_folders.txt to reset from this template. +# # List folder names exactly as shown in FCCS System Configuration > Document Folders. # Keep the YYYY prefix for recurring folders. Non-recurring folders go as-is. # UltraTax CS folders are handled automatically — do not list them here.