Skip to content

Use attributes of *PackageInfo objects instead of untyped dicts.

This commit does the following:

  • Move artifact_identity to BasePackageInfo, which uses a class attribute (and is overriden for ArchivePackageInfo, which needs a custom behavior to override keys). Also moved/improved its test
  • Add attributes to *PackageInfo classes, that can be accessed instead of the raw metadata.
  • Add a from_metadata class method to all *PackageInfo classes, to parse the raw metadata and build the object from it.
  • Pass the PackageInfo object to resolve_revision_from and build_revision instead of untyped dicts.

Depends on !122 (closed) and !123 (closed)

Suggested reading order:

  • first, swh/loader/package/loader.py
  • then each loader but debian and archive (they have more extensive changes)
  • then archive and debian

Test Plan

Functional tests are not affected. Unit tests of functions formerly working on dicts are updated to work with the new attr classes


Migrated from D3603 (view on Phabricator)

Merge request reports