tweaked the ignore list so it includes all files not just prefix, so 02800 and 02800TP now
This commit is contained in:
42
fccs_scan.py
42
fccs_scan.py
@@ -19,39 +19,45 @@ _IGNORE_HEADER = [
|
||||
"#",
|
||||
"# Add password-protected or otherwise-excluded drawers here.",
|
||||
"#",
|
||||
"# The IDs auto-added below are prefix clashes: searching them in FCCS",
|
||||
"# pops a selection box that breaks the automation, so they're skipped by",
|
||||
"# default. DELETE or comment out any you actually DO want exported (then",
|
||||
"# handle them manually), and keep the rest.",
|
||||
"# 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.",
|
||||
"",
|
||||
]
|
||||
|
||||
|
||||
def update_ignore_file(ignore_file, clashes, log):
|
||||
"""Create ignore.txt if missing and seed it with clash prefix IDs.
|
||||
"""Create ignore.txt if missing and seed it with clash-group IDs.
|
||||
|
||||
Never overwrites existing entries — only appends clash prefixes that
|
||||
aren't already present. The shorter (prefix) ID of each clash is the one
|
||||
that triggers the FCCS selection box, so it's the candidate to skip.
|
||||
Returns the list of IDs that were added.
|
||||
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.
|
||||
"""
|
||||
existing = set(load_lines(ignore_file))
|
||||
file_exists = os.path.exists(ignore_file)
|
||||
|
||||
to_add = [(short, matches) for short, matches in clashes
|
||||
if short not in existing]
|
||||
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))
|
||||
|
||||
# Existing file already covers every clash — leave it untouched.
|
||||
if file_exists and not to_add:
|
||||
if file_exists and not blocks:
|
||||
return []
|
||||
|
||||
lines = []
|
||||
if not file_exists:
|
||||
lines.extend(_IGNORE_HEADER)
|
||||
|
||||
for short, matches in to_add:
|
||||
lines.append(f"# clashes with: {', '.join(matches)}")
|
||||
lines.append(short)
|
||||
for comment, new_ids in blocks:
|
||||
lines.append(comment)
|
||||
lines.extend(new_ids)
|
||||
|
||||
mode = "a" if file_exists else "w"
|
||||
with open(ignore_file, mode, encoding="utf-8") as f:
|
||||
@@ -59,11 +65,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 = [short for short, _ in to_add]
|
||||
added = [i for _, ids in blocks for i in ids]
|
||||
if not file_exists:
|
||||
log(f"Created ignore file: {ignore_file}")
|
||||
if added:
|
||||
log(f"Added {len(added)} clash prefix ID(s) to ignore list: "
|
||||
log(f"Added {len(added)} clash-group ID(s) to ignore list: "
|
||||
f"{', '.join(added)}")
|
||||
return added
|
||||
|
||||
|
||||
Reference in New Issue
Block a user