feat: catch regex pattern matching failure

This commit is contained in:
2025-10-05 16:07:24 +01:00
parent f8814ce993
commit 0597be32df

View File

@@ -40,8 +40,13 @@ def split_path(path):
return split_path
def get_path_components(asset_path: str):
pattern = re.compile(r"(?P<full_path>/shows/(?P<project_name>\S*?)/\S*?/(?P<asset_type>\S*?)/(?P<asset_name>\S*?)_v(?P<asset_version>\S*?)/(?P<task>\S*?)/\S*?/(?P<file_name>\S*?)_v(?P<file_version>\d*)\D*?(?P<frame_number>\d*)\D*?\.(?P<file_extension>\w*)\Z)")
regex_pattern = r"(?P<full_path>/shows/(?P<project_name>\S*?)/\S*?/(?P<asset_type>\S*?)/(?P<asset_name>\S*?)_v(?P<asset_version>\S*?)/(?P<task>\S*?)/\S*?/(?P<file_name>\S*?)_v(?P<file_version>\d*)\D*?(?P<frame_number>\d*)\D*?\.(?P<file_extension>\w*)\Z)"
pattern = re.compile(regex_pattern)
match = pattern.match(asset_path)
if(not match):
raise Exception("Regex pattern matching failed. This is likely due to one of your paths using the incorrect schema.")
path_components = match.groupdict()
return path_components