Skip to main content
`Ctrl`+`K`

# pystac.extensions.file

Implements the File Info Extension.

class pystac.extensions.file.AssetFileExtension(asset: Asset)

  A concrete implementation of `FileExtension` on an `Asset` 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 an `Asset` to extend it.

  additional_read_properties: Iterable[dict[str, Any]] | None = None

    If present, this will be a list containing 1 dictionary representing the properties of the owner.

  asset_href: str

    The `href` value of the `Asset` being extended.

  properties: dict[str, Any]

    The `Asset` fields, including extension properties.

class pystac.extensions.file.ByteOrder(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

  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

  A class that can be used to extend the properties of an `Asset` or `Link` with properties from the File Info Extension.

  To create an instance of `FileExtension`, use the `FileExtension.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

    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]

    Extends the given STAC Object with properties from the File Info Extension.

    This extension can be applied to instances of `Asset` or `Link`

  classmethod get_schema_uri() → str

    Gets the schema URI associated with this extension.

  property header_size: int | None

    Get or sets the header size of the file, in bytes.

  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 size: int | None

    Get or sets the size of the file, in bytes.

  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
  migrate(obj: dict[str, Any], version: STACVersionID, info: STACJSONDescription) → None

    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'}
  schema_uri: str = 'https://stac-extensions.github.io/file/v2.1.0/schema.json'
  stac_object_types = {'Catalog', 'Collection', 'Feature'}

class pystac.extensions.file.LinkFileExtension(link: Link)

  A concrete implementation of `FileExtension` on an `Link` 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 an `Link` to extend it.

  additional_read_properties: Iterable[dict[str, Any]] | None = None

    If present, this will be a list containing 1 dictionary representing the properties of the owner.

  link_href: str

    The `href` value of the `Link` being extended.

  properties: dict[str, Any]

    The `Link` fields, including extension properties.

class pystac.extensions.file.MappingObject(properties: dict[str, Any])

  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

    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

    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).

  classmethod from_dict(d: dict[str, Any]) → MappingObject
  properties: dict[str, Any]
  property summary: str

    Gets or sets the short description of the value(s).

  to_dict() → dict[str, Any]
  property values: list[Any]

    Gets or sets the list of value(s) in the file. At least one array element is required.

class pystac.extensions.file.T

  Generalized version of `Asset`, `Link`,

  alias of TypeVar(‘T’, ~pystac.asset.Asset, ~pystac.link.Link)