granicus_archiver.types

class granicus_archiver.types.Serializable[source]

Bases: ABC

class granicus_archiver.types.FileMeta(content_length: int, content_type: str, last_modified: datetime | None, etag: str | None, sha1: SHA1Hash | None = None)[source]

Bases: Serializable

Metadata for a file

Parameters:
  • content_length (int)

  • content_type (str)

  • last_modified (datetime | None)

  • etag (str | None)

  • sha1 (SHA1Hash | None)

content_length: int

File size (in bytes)

content_type: str

The file’s mime type

last_modified: datetime | None

Last modified datetime

etag: str | None

The etag value (if available)

sha1: SHA1Hash | None = None

SHA1 hash of the file

classmethod from_headers(headers: MultiMapping[str] | dict[str, str]) Self[source]

Create an instance from http headers

Parameters:

headers (MultiMapping[str] | dict[str, str])

Return type:

Self

classmethod create_zero_length() Self[source]

Create an instance to indicate that the file has a reported length of zero

This may be used to indicate that a file is malformed or no longer exists on the server.

Zero-length FileMeta instances can be detected from their is_zero_length attribute.

Return type:

Self

property is_pdf: bool

Whether this is a pdf file

property is_zero_length: bool

Whether this instance represents a zero-length file (created by create_zero_length())