libera_utils.io.filenaming.AbstractDataProductFilename#
- class libera_utils.io.filenaming.AbstractDataProductFilename(*args, **kwargs)#
Bases:
AbstractValidFilenameAbstract base class for data product filenames.
This class adds the data product specific requirements that all data products must have: a processing step ID and a data product ID. For example, an L0Filename or a LiberaDataProductFilename are both AbstractDataProductFilenames.
- Attributes:
archive_prefixProperty that contains the generated prefix used for archiving, when applicable
data_product_idProperty that contains the DataProductIdentifier for this file type
filename_partsProperty that contains a namespace of filename parts
pathProperty containing the file path
Methods
from_file_path(*args, **kwargs)Factory method to produce an AbstractValidFilename from a valid Libera file path (str or Path)
from_filename_parts(*args, **kwargs)Abstract method that must be implemented to provide hinting for required parts
generate_prefixed_path(parent_path)Generates an absolute path of the form {parent_path}/{prefix_structure}/{file_basename} The parent_path can be an S3 bucket or an absolute local filepath (must start with /)
regex_match(path)Parse and validate a given path against class-attribute defined regex
- __init__(*args, **kwargs)#
Methods
from_file_path(*args, **kwargs)Factory method to produce an AbstractValidFilename from a valid Libera file path (str or Path)
from_filename_parts(*args, **kwargs)Abstract method that must be implemented to provide hinting for required parts
generate_prefixed_path(parent_path)Generates an absolute path of the form {parent_path}/{prefix_structure}/{file_basename} The parent_path can be an S3 bucket or an absolute local filepath (must start with /)
regex_match(path)Parse and validate a given path against class-attribute defined regex
Attributes
Property that contains the generated prefix used for archiving, when applicable
Property that contains the DataProductIdentifier for this file type
Property that contains a namespace of filename parts
Property containing the file path
- abstractmethod classmethod _format_filename_parts(*args: Any, **kwargs: Any)#
Format parts into a filename
Note: When this is implemented by concrete classes, *args and **kwargs become specific parameters
- classmethod _from_filename_parts(*, basepath: str | Path | S3Path | None = None, **parts: Any)#
Create instance from filename parts.
The part kwarg names are named according to the regex for the file type.
- Parameters:
basepath (Union[str, Path, S3Path], Optional) – Allows prepending a basepath or prefix.
parts (Any) – Passed directly to _format_filename_parts. This is a dict of variable kwargs that will differ in each filename class based on the required parts for that particular filename type.
- Return type:
- abstractmethod _parse_filename_parts()#
Parse the filename parts into objects from regex matched strings
- Returns:
namespace object containing filename parts as parsed objects
- Return type:
- abstract property archive_prefix: str#
Property that contains the generated prefix used for archiving, when applicable
- abstract property data_product_id: DataProductIdentifier#
Property that contains the DataProductIdentifier for this file type
- property filename_parts#
Property that contains a namespace of filename parts
- classmethod from_file_path(*args, **kwargs)#
Factory method to produce an AbstractValidFilename from a valid Libera file path (str or Path)
- abstractmethod classmethod from_filename_parts(*args: Any, **kwargs: Any)#
Abstract method that must be implemented to provide hinting for required parts
- generate_prefixed_path(parent_path: str | CloudPath | Path) CloudPath | Path#
Generates an absolute path of the form {parent_path}/{prefix_structure}/{file_basename} The parent_path can be an S3 bucket or an absolute local filepath (must start with /)
- Parameters:
parent_path (Union[str, Path, S3Path]) – Absolute path to the parent directory or S3 bucket prefix. The generated path prefix is appended to the parent path and followed by the file basename.
- Return type: