arkimet.formatter package¶
Module contents¶
- class arkimet.formatter.Formatter[source]¶
Registry for metadata formatters implemented in Python.
This is used to register formatter implementations, and access them while formatting.
Use
arkimet.Formatter
to do the actual formatting: it will call either into this or in C++ implementations as needed.- formatters = {'area': [<function format_area>], 'level': [<function format_level>], 'origin': [<function format_origin>], 'proddef': [<function format_proddef>], 'product': [<function format_product>], 'timerange': [<function format_timerange>]}¶
- classmethod register(type: str, formatter: Callable[[Dict[str, Any]], Optional[str]])[source]¶
Register a callable as a formatter for the given metadata type.
A registered callable can return None to fall back on previously registered callables. This allows to add formatters for specific cases only, without losing the default handling.
Submodules¶
arkimet.formatter.area module¶
arkimet.formatter.eccodes module¶
- class arkimet.formatter.eccodes.GribTable(edition: int, table: str)[source]¶
Read a grib table.
edition is the GRIB edition: 1 or 2
table is the table name, for example “0.0”
Returns a table where the index maps to a couple { abbreviation, description }, or nil if the file had no such entry.
For convenience, the table has also two functions, ‘abbr’ and ‘desc’, that return the abbreviation or the description, falling back on returning the table index if they are not available.
For example:
origins = GribTable(1, “0”) print(origins.abbr(98)) – Prints ‘ecmf’ print(origins.desc(98)) – Prints ‘European Center for Medium-Range Weather Forecasts’ print(origins.abbr(999)) – Prints ‘999’ print(origins.desc(999)) – Prints ‘999’
- cache = {(1, '0'): <arkimet.formatter.eccodes.GribTable object>}¶
- classmethod load(edition: int, table: str) arkimet.formatter.eccodes.GribTable [source]¶
- re_table_line = re.compile('^\\s*(?P<idx>\\d+)\\s+(?P<abbr>\\S+)\\s+(?P<desc>.+)$')¶
arkimet.formatter.formatter module¶
This module implements a registry of Python formatters for various metadata types, along with default implementations.
- class arkimet.formatter.formatter.Formatter[source]¶
Registry for metadata formatters implemented in Python.
This is used to register formatter implementations, and access them while formatting.
Use
arkimet.Formatter
to do the actual formatting: it will call either into this or in C++ implementations as needed.- formatters = {'area': [<function format_area>], 'level': [<function format_level>], 'origin': [<function format_origin>], 'proddef': [<function format_proddef>], 'product': [<function format_product>], 'timerange': [<function format_timerange>]}¶
- classmethod register(type: str, formatter: Callable[[Dict[str, Any]], Optional[str]])[source]¶
Register a callable as a formatter for the given metadata type.
A registered callable can return None to fall back on previously registered callables. This allows to add formatters for specific cases only, without losing the default handling.