libera_utils.io.manifest.Manifest#
- class libera_utils.io.manifest.Manifest(manifest_type: ManifestType, files: list = None, configuration: dict = None, filename: str = None)#
Bases:
object
Object representation of a JSON manifest file
Methods
add_desired_time_range
(start_datetime, ...)Add a file to the manifest from filename
add_file_to_manifest
(file)Deprecated legacy method replaced by add_files
add_files
(*files)Add files to the manifest from filename
from_file
(filepath)Read a manifest file and return a Manifest object (factory method).
Create Output manifest from input manifest file path, adds input files to output manifest configuration
Create a dict representation suitable for writing out.
validate
()Validate the contents of this manifest object
Validate checksums of listed files
write
(outpath[, filename])Write a manifest file from a Manifest object (self).
- __init__(manifest_type: ManifestType, files: list = None, configuration: dict = None, filename: str = None)#
Constructor
- Parameters:
manifest_type (ManifestType) – Type of manifest
files (list, Optional) – List of dictionaries. Each entry must contain a filename key and a checksum key.
configuration (dict, Optional) – Freeform dictionary of configuration items. It’s up to the consumer to understand this JSON object.
filename (str or ManifestFilename, Optional) – Preset filename. Must be a ManifestFilename object or a str representing a valid manifest file path.
Methods
add_desired_time_range
(start_datetime, ...)Add a file to the manifest from filename
add_file_to_manifest
(file)Deprecated legacy method replaced by add_files
add_files
(*files)Add files to the manifest from filename
from_file
(filepath)Read a manifest file and return a Manifest object (factory method).
Create Output manifest from input manifest file path, adds input files to output manifest configuration
Create a dict representation suitable for writing out.
validate
()Validate the contents of this manifest object
Validate checksums of listed files
write
(outpath[, filename])Write a manifest file from a Manifest object (self).
- _generate_filename()#
Generate a valid manifest filename
- add_desired_time_range(start_datetime: datetime, end_datetime: datetime)#
Add a file to the manifest from filename
- Parameters:
start_datetime (datetime.datetime) – The desired start time for the range of data in this manifest
end_datetime (datetime.datetime) – The desired end time for the range of data in this manifest
- Return type:
None
- add_file_to_manifest(file)#
Deprecated legacy method replaced by add_files
- add_files(*files)#
Add files to the manifest from filename
- Parameters:
files (str or pathlib.Path or cloudpathlib.s3.s3path.S3Path) – Path to the file to add to the manifest.
- Return type:
None
- classmethod from_file(filepath: str)#
Read a manifest file and return a Manifest object (factory method).
- Parameters:
filepath (str or pathlib.Path or cloudpathlib.s3.s3path.S3Path) – Location of manifest file to read.
- Return type:
- classmethod output_manifest_from_input_manifest(input_manifest: Path) Manifest #
Create Output manifest from input manifest file path, adds input files to output manifest configuration
- Parameters:
input_manifest (pathlib.Path or cloudpathlib.s3.s3path.S3Path or Manifest) – An S3 or regular path to an input_manifest object, or the input manifest object itself
- Returns:
output_manifest – The newly created output manifest
- Return type:
- validate()#
Validate the contents of this manifest object
- validate_checksums()#
Validate checksums of listed files
- write(outpath: str, filename: str = None)#
Write a manifest file from a Manifest object (self).
- Parameters:
outpath (str or pathlib.Path or cloudpathlib.s3.s3path.S3Path) – Directory path to write to (directory being used loosely to refer also to an S3 bucket path).
filename (str, Optional) – Optional filename, must be a valid manifest filename. If not provided, the method uses the objects internal filename attribute. If that is not set, then a filename is automatically generated.
- Return type: