From fb56ca1dd40cc9e3b3d2f046c29f64ca24cb4f79 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Tue, 26 Aug 2025 17:21:03 -0700 Subject: [PATCH] Formatting --- ucsinfer/__main__.py | 5 +++-- ucsinfer/util.py | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ucsinfer/__main__.py b/ucsinfer/__main__.py index dcdd70a..a787d85 100644 --- a/ucsinfer/__main__.py +++ b/ucsinfer/__main__.py @@ -107,8 +107,9 @@ def evaluate(dataset, offset, limit): miss_counts = [] for cat in cats: - miss_counts.append((cat, len([x for x in results - if x['catid'] == cat and x['result'] == 'MISS']))) + miss_counts.append( + (cat, len([x for x in results + if x['catid'] == cat and x['result'] == 'MISS']))) miss_counts = sorted(miss_counts, key=lambda x: x[1]) diff --git a/ucsinfer/util.py b/ucsinfer/util.py index 08a43ac..003faef 100644 --- a/ucsinfer/util.py +++ b/ucsinfer/util.py @@ -66,12 +66,14 @@ def build_ucs(components: UcsNameComponents, extension: str) -> str: """ Build a UCS filename """ - assert components.validate(), "UcsNameComponents contains invalid characters" + assert components.validate(), \ + "UcsNameComponents contains invalid characters" return "" -def parse_ucs(rootname: str, catid_list: list[str]) -> Optional[UcsNameComponents]: +def parse_ucs(rootname: str, + catid_list: list[str]) -> Optional[UcsNameComponents]: """ Parse the UCS components from a file name root. @@ -80,11 +82,12 @@ def parse_ucs(rootname: str, catid_list: list[str]) -> Optional[UcsNameComponent :returns: the components, or `None` if the filename is not in UCS format """ - regexp1 = r"^(?P[A-z]+)(-(?P[^_]+))?_((?P[^-]+)-)?(?P[^_]+)" + regexp1 = r"^(?P[A-z]+)(-(?P[^_]+))?_" + regexp2 = r"((?P[^-]+)-)?(?P[^_]+)" + regexp3 = r"(_(?P[^_]+)(_(?P[^_]+)" + regexp4 = r"(_(?P[^.]+))?)?)?" - regexp2 = r"(_(?P[^_]+)(_(?P[^_]+)(_(?P[^.]+))?)?)?" - - regexp = regexp1 + regexp2 + regexp = regexp1 + regexp2 + regexp3 + regexp4 matches = match(regexp, rootname)