swh.storage.postgresql.converters module¶
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
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_date
(date: Optional[datetime.datetime], offset: int, neg_utc_offset: Optional[bool]) → Optional[swh.model.model.TimestampWithTimezone][source]¶ Convert the DB representation of a date to a swh-model compatible date.
- Parameters
date – a date pulled out of the database
offset – an integer number of minutes representing an UTC offset
neg_utc_offset – whether an utc offset is negative
- Returns
a TimestampWithTimezone, or None if the date is None.
-
swh.storage.postgresql.converters.
date_to_db
(ts_with_tz: Optional[swh.model.model.TimestampWithTimezone]) → 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 three keys:
timestamp: a date in ISO format
offset: the UTC offset in minutes
neg_utc_offset: a boolean indicating whether a null offset is negative or positive.
- Return type
dict
-
swh.storage.postgresql.converters.
revision_to_db
(revision: swh.model.model.Revision) → Dict[str, Any][source]¶ Convert a swh-model revision to its database representation.
-
swh.storage.postgresql.converters.
db_to_revision
(db_revision: Dict[str, Any]) → Optional[swh.model.model.Revision][source]¶ Convert a database representation of a revision to its swh-model representation.
-
swh.storage.postgresql.converters.
release_to_db
(release: swh.model.model.Release) → Dict[str, Any][source]¶ Convert a swh-model release to its database representation.
-
swh.storage.postgresql.converters.
db_to_release
(db_release: Dict[str, Any]) → Optional[swh.model.model.Release][source]¶ Convert a database representation of a release to its swh-model representation.
-
swh.storage.postgresql.converters.
db_to_raw_extrinsic_metadata
(row) → swh.model.model.RawExtrinsicMetadata[source]¶