feat: catch regex pattern matching failure
This commit is contained in:
@@ -40,8 +40,13 @@ def split_path(path):
|
|||||||
return split_path
|
return split_path
|
||||||
|
|
||||||
def get_path_components(asset_path: str):
|
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)
|
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()
|
path_components = match.groupdict()
|
||||||
|
|
||||||
return path_components
|
return path_components
|
||||||
|
|||||||
Reference in New Issue
Block a user