Skip to content

template_registry

Registry of alias for common variables that may be used in other templates.

Functions:

Name Description
get_regex

Attributes:

Name Type Description
KNOWN_REGEX_PATTERNS
TEMPLATE_REGISTRY
UNKNOWN_REGEX_PATTERN

Attributes#

KNOWN_REGEX_PATTERNS module-attribute #

KNOWN_REGEX_PATTERNS = dict(
    year="(?P<year>[0-9]{4})",
    month="(?P<month>[0-9]{2})",
    day="(?P<day>[0-9]{2})",
    hour="(?P<hour>[0-9]{2})",
    minute="(?P<minute>[0-9]{2})",
    second="(?P<second>[0-9]{2})",
    yyyy="(?P<yyyy>[0-9]{4})",
    mm="(?P<mm>[0-9]{2})",
    dd="(?P<dd>[0-9]{2})",
    HH="(?P<HH>[0-9]{2})",
    MM="(?P<MM>[0-9]{2})",
    SS="(?P<SS>[0-9]{2})",
    date_time="(?P<date_time>[0-9]{8}\\.[0-9]{6})",
    date="(?P<date>[0-9]{8})",
    time="(?P<time>[0-9]{6})",
    start_date="(?P<start_date>[0-9]{8})",
    start_time="(?P<start_time>[0-9]{6})",
    title="(?P<title>[a-zA-Z0-9_]+)",
    location_id="(?P<location_id>[a-zA-Z0-9_]+)",
    dataset_name="(?P<dataset_name>[a-z0-9_]+)",
    qualifier="(?P<qualifier>[a-zA-Z0-9_]+)",
    temporal="(?P<temporal>[0-9]+[a-zA-Z]+)",
    data_level="(?P<data_level>[a-z0-9]+)",
)

TEMPLATE_REGISTRY module-attribute #

TEMPLATE_REGISTRY = dict(
    datastream="{location_id}.{dataset_name}[-{qualifier}][-{temporal}].{data_level}"
)

UNKNOWN_REGEX_PATTERN module-attribute #

UNKNOWN_REGEX_PATTERN = '(?P<{variable}>[a-zA-Z0-9_]+)'

Functions#

get_regex #

get_regex(var_name: str) -> str
Source code in tsdat/tstring/template_registry.py
def get_regex(var_name: str) -> str:
    return KNOWN_REGEX_PATTERNS.get(
        var_name,
        UNKNOWN_REGEX_PATTERN.format(variable=var_name),
    )