diff --git a/src/access_nri_intake/source/builders.py b/src/access_nri_intake/source/builders.py index 564e6d4..a4d20b7 100644 --- a/src/access_nri_intake/source/builders.py +++ b/src/access_nri_intake/source/builders.py @@ -67,6 +67,9 @@ class BaseBuilder(Builder): # Base class carries an empty set, and a GenericParser PATTERNS: list = [] + REDACTION_GROUPS: list = [ + TIMESTAMP_GROUP, + ] TIME_PARSER = GenericTimeParser def __init__( @@ -243,9 +246,6 @@ def parse_filename( patterns: list[str] | None = None, frequencies: dict = FREQUENCIES, redaction_fill: str = "X", - redaction_groups: list[str] = [ - TIMESTAMP_GROUP, - ], ) -> tuple[str, str | None, str | None]: """ Parse an ACCESS model filename and return a file id and any time information @@ -291,7 +291,7 @@ def parse_filename( match = re.match(pattern, file_id) if match: timestamp = match.group(TIMESTAMP_GROUP) - for grp in redaction_groups: + for grp in cls.REDACTION_GROUPS: if grp in match.groupdict().keys(): redaction = re.sub(r"\d", redaction_fill, match.group(grp)) file_id = ( @@ -508,6 +508,10 @@ class Mom6Builder(BaseBuilder): rf"[^\.]*(?P<{TIMESTAMP_GROUP}>{PATTERNS_HELPERS['ymd-ns']})\.{PATTERNS_HELPERS['mom6_components']}.*(?P{PATTERNS_HELPERS['mom6_added_timestamp']}).*$", # Daily snapshot naming rf"[^\.]*(?P<{TIMESTAMP_GROUP}>{PATTERNS_HELPERS['ymd-ns']})\.{PATTERNS_HELPERS['mom6_components']}.*$", # Basic naming ] + REDACTION_GROUPS = [ + TIMESTAMP_GROUP, + "mom6_added_timestamp", + ] TIME_PARSER = GfdlTimeParser def __init__(self, path): @@ -548,23 +552,6 @@ def __init__(self, path): super().__init__(**kwargs) - @classmethod - def parse_filename( - cls, - filename, - patterns=None, - frequencies=FREQUENCIES, - redaction_fill="X", - redaction_groups=[TIMESTAMP_GROUP], - ): - return super().parse_filename( - filename, - patterns, - frequencies, - redaction_fill, - redaction_groups=[TIMESTAMP_GROUP, "mom6_added_timestamp"], - ) - @classmethod def parser(cls, file): try: