added some more generic handling of TR products instead of hard coding UltraTax. We now have a list we loop through for things like Planner and Practice CS and can add more later
This commit is contained in:
@@ -105,30 +105,38 @@ def load_folder_list(path):
|
||||
return folders
|
||||
|
||||
|
||||
# Thomson Reuters product integrations that auto-generate folders named
|
||||
# "{Product} MM-DD-YYYY" in FCCS. Matched built-in (no fccs_folders.txt entry
|
||||
# needed); add newly-discovered products here.
|
||||
TR_PRODUCT_FOLDERS = ("UltraTax CS", "Planner CS", "Practice CS")
|
||||
|
||||
|
||||
def build_folder_patterns(templates):
|
||||
"""
|
||||
Convert folder template strings into regex patterns for matching.
|
||||
|
||||
Templates use YYYY as a year placeholder (e.g. 'YYYY Tax Documents').
|
||||
Non-recurring folders (no YYYY) are matched literally.
|
||||
A built-in pattern for 'UltraTax CS MM-DD-YYYY' is always included.
|
||||
Built-in patterns for '{Product} MM-DD-YYYY' Thomson Reuters product
|
||||
folders (TR_PRODUCT_FOLDERS, e.g. UltraTax CS) are always included.
|
||||
|
||||
Returns a list of (compiled_regex, template_name, folder_type) tuples,
|
||||
sorted longest-first to prevent partial matches.
|
||||
|
||||
folder_type is one of:
|
||||
"yyyy" — recurring folder with year prefix (captured in group 1)
|
||||
"ultratax" — UltraTax CS folder with date suffix (captured in group 1)
|
||||
"ultratax" — TR product folder with date suffix (captured in group 1)
|
||||
"static" — non-recurring folder, no decomposition needed
|
||||
"""
|
||||
patterns = []
|
||||
|
||||
# Built-in: UltraTax CS folders (auto-generated by UltraTax integration)
|
||||
patterns.append((
|
||||
re.compile(r"UltraTax CS (\d{2}-\d{2}-\d{4})$"),
|
||||
"UltraTax CS",
|
||||
"ultratax",
|
||||
))
|
||||
# Built-in: TR product folders (auto-generated by each product's integration)
|
||||
for product in TR_PRODUCT_FOLDERS:
|
||||
patterns.append((
|
||||
re.compile(re.escape(product) + r" (\d{2}-\d{2}-\d{4})$"),
|
||||
product,
|
||||
"ultratax",
|
||||
))
|
||||
|
||||
for tmpl in templates:
|
||||
if "YYYY" in tmpl:
|
||||
@@ -156,8 +164,9 @@ def decompose_folder_path(match, folder_type, template_name):
|
||||
Examples:
|
||||
yyyy: "YYYY Tax Documents" matched "2025 Tax Documents"
|
||||
→ ("Tax Documents", "2025")
|
||||
ultratax: "UltraTax CS 12-31-2008"
|
||||
→ ("UltraTax CS", "12-31-2008")
|
||||
ultratax: any TR product folder, e.g. "UltraTax CS 12-31-2008"
|
||||
→ ("UltraTax CS", "12-31-2008"),
|
||||
"Planner CS 12-31-2016" → ("Planner CS", "12-31-2016")
|
||||
static: "Permanent File"
|
||||
→ ("Permanent File",)
|
||||
"""
|
||||
@@ -168,7 +177,7 @@ def decompose_folder_path(match, folder_type, template_name):
|
||||
return (base_name, year)
|
||||
elif folder_type == "ultratax":
|
||||
date = match.group(1)
|
||||
return ("UltraTax CS", date)
|
||||
return (template_name, date)
|
||||
else:
|
||||
return (template_name,)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user