reverted how we compile the ignore list. The longer numbers will actually handle fine so we dont need to ignore. For example 01230 we need to handle but 01230TS we dont. Also we created a separate script to handle clashing numbers specifically as well as helper function that will dump control id's

This commit is contained in:
2026-07-09 20:33:07 -05:00
parent b5862a7ea7
commit 1b300eacb3
4 changed files with 118 additions and 27 deletions

View File

@@ -19,45 +19,40 @@ _IGNORE_HEADER = [
"#",
"# Add password-protected or otherwise-excluded drawers here.",
"#",
"# The IDs auto-added below are prefix clashes: searching any of them in",
"# FCCS can pop a selection box that breaks the automation, so ALL drawers",
"# in each clash group are skipped by default. DELETE or comment out any",
"# you actually DO want exported (then handle them manually), keep the rest.",
"# The IDs auto-added below are prefix clashes: searching the base ID in",
"# FCCS pops a selection box that breaks the plain export. Only the base",
"# (shorter) ID is listed — the longer, more-specific IDs export normally.",
"# The base IDs are exported separately by fccs_export_clashes.py, which",
"# handles the selection box. DELETE or comment out any you'd rather skip.",
"",
]
def update_ignore_file(ignore_file, clashes, log):
"""Create ignore.txt if missing and seed it with clash-group IDs.
"""Create ignore.txt if missing and seed it with clash base (prefix) IDs.
Every drawer involved in a clash (both the prefix and each longer ID that
matches it) is added, since any of them can trip the FCCS selection box.
Never overwrites existing entries — only appends IDs not already present,
and de-dupes so no ID is written twice. Returns the list of IDs added.
Only the shorter (prefix) ID of each clash is added — that's the one that
triggers the FCCS selection box and needs special handling. The longer,
more-specific IDs (e.g. '02218A') search fine and export normally.
Never overwrites existing entries — only appends prefixes not already
present. Returns the list of IDs added.
"""
existing = set(load_lines(ignore_file))
file_exists = os.path.exists(ignore_file)
seen = set(existing) # never re-add anything already listed
blocks = [] # (comment, [new_ids]) to append, in clash order
for short, matches in clashes:
group = [short] + list(matches)
new_ids = [g for g in group if g not in seen]
if not new_ids:
continue
seen.update(new_ids)
blocks.append((f"# clash group: {', '.join(group)}", new_ids))
to_add = [(short, matches) for short, matches in clashes
if short not in existing]
# Existing file already covers every clash — leave it untouched.
if file_exists and not blocks:
if file_exists and not to_add:
return []
lines = []
if not file_exists:
lines.extend(_IGNORE_HEADER)
for comment, new_ids in blocks:
lines.append(comment)
lines.extend(new_ids)
for short, matches in to_add:
lines.append(f"# clashes with: {', '.join(matches)}")
lines.append(short)
mode = "a" if file_exists else "w"
with open(ignore_file, mode, encoding="utf-8") as f:
@@ -65,11 +60,11 @@ def update_ignore_file(ignore_file, clashes, log):
f.write("\n") # separate the new block from prior content
f.write("\n".join(lines) + "\n")
added = [i for _, ids in blocks for i in ids]
added = [short for short, _ in to_add]
if not file_exists:
log(f"Created ignore file: {ignore_file}")
if added:
log(f"Added {len(added)} clash-group ID(s) to ignore list: "
log(f"Added {len(added)} clash base ID(s) to ignore list: "
f"{', '.join(added)}")
return added