swh.storage.postgresql.converters module#

swh.storage.postgresql.converters.author_to_db(author: Person | None) Dict[str, Any][source]#

Convert a swh-model author to its DB representation.

Parameters:

author – a swh.model compatible author

Returns:

a dictionary with three keys: author, fullname and email

Return type:

dict

swh.storage.postgresql.converters.db_to_author(fullname: bytes | None, name: bytes | None, email: bytes | None) Person | None[source]#

Convert the DB representation of an author to a swh-model author.

Parameters:
  • fullname (bytes) – the author’s fullname

  • name (bytes) – the author’s name

  • email (bytes) – the author’s email

Returns:

a Person object, or None if ‘fullname’ is None.

swh.storage.postgresql.converters.db_to_git_headers(db_git_headers)[source]#
swh.storage.postgresql.converters.db_to_date(date: datetime | None, offset_bytes: bytes) TimestampWithTimezone | None[source]#

Convert the DB representation of a date to a swh-model compatible date.

Parameters:
  • date – a date pulled out of the database

  • offset_bytes – a byte representation of the latter two, usually as “+HHMM” or “-HHMM”

Returns:

a TimestampWithTimezone, or None if the date is None.

swh.storage.postgresql.converters.date_to_db(ts_with_tz: TimestampWithTimezone | None) Dict[str, Any][source]#

Convert a swh-model date_offset to its DB representation.

Parameters:

ts_with_tz – a TimestampWithTimezone object

Returns:

a dictionary with these keys:

  • timestamp: a date in ISO format

  • offset_bytes: a byte representation of the latter two, usually as “+HHMM” or “-HHMM”

Return type:

dict

swh.storage.postgresql.converters.revision_to_db(revision: Revision) Dict[str, Any][source]#

Convert a swh-model revision to its database representation.

swh.storage.postgresql.converters.db_to_optional_revision(db_revision: Dict[str, Any]) Revision | None[source]#

Convert a database representation of a revision to its swh-model representation. This is similar to db_to_revision(), but this returns None instead of crashing if the revision does not exist (returned by an outer join).

swh.storage.postgresql.converters.db_to_revision(db_revision: Dict[str, Any]) Revision[source]#

Convert a database representation of a revision to its swh-model representation. Raises ValueError if required values are None.

swh.storage.postgresql.converters.release_to_db(release: Release) Dict[str, Any][source]#

Convert a swh-model release to its database representation.

swh.storage.postgresql.converters.db_to_optional_release(db_release: Dict[str, Any]) Release | None[source]#

Convert a database representation of a release to its swh-model representation. This is similar to db_to_release(), but this returns None instead of crashing if the revision does not exist (returned by an outer join).

swh.storage.postgresql.converters.db_to_release(db_release: Dict[str, Any]) Release[source]#

Convert a database representation of a release to its swh-model representation. Raises ValueError if required values are None.

swh.storage.postgresql.converters.db_to_raw_extrinsic_metadata(row) RawExtrinsicMetadata[source]#
swh.storage.postgresql.converters.db_to_extid(row) ExtID[source]#
swh.storage.postgresql.converters.object_reference_to_db(reference: ObjectReference) Tuple[str, bytes, str, bytes][source]#
swh.storage.postgresql.converters.db_to_object_reference_source(row) ExtendedSWHID[source]#