pystac.extensions.file#
Implements the File Info Extension.
- class pystac.extensions.file.AssetFileExtension(asset: Asset)[source]#
A concrete implementation of
FileExtension
on anAsset
that extends the Asset fields to include properties defined in the File Info Extension.This class should generally not be instantiated directly. Instead, call
FileExtension.ext()
on anAsset
to extend it.
- class pystac.extensions.file.ByteOrder(value)[source]#
List of allows values for the
"file:byte_order"
field defined by the File Info Extension.- BIG_ENDIAN = 'big-endian'#
- LITTLE_ENDIAN = 'little-endian'#
- class pystac.extensions.file.FileExtension[source]#
A class that can be used to extend the properties of an
Asset
orLink
with properties from the File Info Extension.To create an instance of
FileExtension
, use theFileExtension.ext()
method. For example:>>> asset: pystac.Asset = ... >>> file_ext = FileExtension.ext(asset)
- apply(byte_order: ByteOrder | None = None, checksum: str | None = None, header_size: int | None = None, size: int | None = None, values: list[MappingObject] | None = None, local_path: str | None = None) None [source]#
Applies file extension properties to the extended Item.
- Parameters:
byte_order – Optional byte order of integer values in the file. One of
"big-endian"
or"little-endian"
.checksum – Optional multihash for the corresponding file, encoded as hexadecimal (base 16) string with lowercase letters.
header_size – Optional header size of the file, in bytes.
size – Optional size of the file, in bytes.
values – Optional list of
MappingObject
instances that lists the values that are in the file and describe their meaning. See the Mapping Object docs for an example. If given, at least one array element is required.
- property byte_order: ByteOrder | None#
Gets or sets the byte order of integer values in the file. One of big-endian or little-endian.
- property checksum: str | None#
Get or sets the multihash for the corresponding file, encoded as hexadecimal (base 16) string with lowercase letters.
- classmethod ext(obj: Asset | Link, add_if_missing: bool = False) FileExtension[T] [source]#
Extends the given STAC Object with properties from the File Info Extension.
- property local_path: str | None#
Get or sets a relative local path for the asset/link.
The
file:local_path
field indicates a relative path that can be used by clients for different purposes to organize the files locally. For compatibility reasons the name-separator character in paths must be/
and the Windows separator\
is not allowed.
- name: Literal['file'] = 'file'#
- property values: list[MappingObject] | None#
Get or sets the list of
MappingObject
instances that lists the values that are in the file and describe their meaning. See the Mapping Object docs for an example. If given, at least one array element is required.
- class pystac.extensions.file.FileExtensionHooks[source]#
- migrate(obj: dict[str, Any], version: STACVersionID, info: STACJSONDescription) None [source]#
Migrate a STAC Object in dict format from a previous version. The base implementation will update the stac_extensions to the latest schema ID. This method will only be called for STAC objects that have been identified as a previous version of STAC. Implementations should directly manipulate the obj dict. Remember to call super() in order to change out the old ‘stac_extension’ entry with the latest schema URI.
- prev_extension_ids = {'file', 'https://stac-extensions.github.io/file/v1.0.0/schema.json', 'https://stac-extensions.github.io/file/v2.0.0/schema.json'}#
- removed_fields = {'file:bits_per_sample', 'file:data_type', 'file:nodata', 'file:unit'}#
- stac_object_types = {STACObjectType.CATALOG, STACObjectType.COLLECTION, STACObjectType.ITEM}#
- class pystac.extensions.file.LinkFileExtension(link: Link)[source]#
A concrete implementation of
FileExtension
on anLink
that extends the Link fields to include properties defined in the File Info Extension.This class should generally not be instantiated directly. Instead, call
FileExtension.ext()
on anLink
to extend it.
- class pystac.extensions.file.MappingObject(properties: dict[str, Any])[source]#
Represents a value map used by assets that are used as classification layers, and give details about the values in the asset and their meanings.
- apply(values: list[Any], summary: str) None [source]#
Sets the properties for this
MappingObject
instance.- Parameters:
values – The value(s) in the file. At least one array element is required.
summary – A short description of the value(s).
- classmethod create(values: list[Any], summary: str) MappingObject [source]#
Creates a new
MappingObject
instance.- Parameters:
values – The value(s) in the file. At least one array element is required.
summary – A short description of the value(s).