updated scan.py to help us error handle the weird searches and alos build an ignore list
This commit is contained in:
@@ -137,3 +137,23 @@ def load_lines(path):
|
||||
return []
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return [line.strip() for line in f if line.strip() and not line.strip().startswith("#")]
|
||||
|
||||
|
||||
def check_for_clashes(drawer_ids):
|
||||
"""Find drawer IDs that are a prefix of another drawer ID.
|
||||
|
||||
FCCS searches by prefix, so searching the shorter ID (e.g. '02218')
|
||||
pops up a selection box when a longer ID exists (e.g. '02218A'),
|
||||
which breaks the automated navigation.
|
||||
|
||||
Returns a list of (short_id, [longer_ids...]) tuples, sorted by short_id.
|
||||
Empty list means no clashes.
|
||||
"""
|
||||
ids = sorted(set(drawer_ids))
|
||||
clashes = []
|
||||
for short in ids:
|
||||
matches = [other for other in ids
|
||||
if other != short and other.startswith(short)]
|
||||
if matches:
|
||||
clashes.append((short, matches))
|
||||
return clashes
|
||||
|
||||
Reference in New Issue
Block a user