arcp.generate¶
Generate arcp URIs with various prefixes.
As detailed in draft-soilandreyes-arcp, the choice of arcp _prefix_ depends on the uniqueness constraints required to identify the archive.
arcp_random()
can be used for a fresh arcp URI
based on a pseudo-random generator. Use
urllib.parse.urljoin()
to
resolve paths within the same archive.
arcp_uuid()
can be used with a pre-made UUID instance,
for instance loaded from an archive’s manifest
or generated with uuid.uuid4()
arcp_location()
can be used to identify an archive based on
its location URL, facilitating a UUID v5 authority.
arcp_name()
can be used to identify an archive based on its
absolute DNS name or package name within an installation.
-
arcp.generate.
arcp_hash
(bytes=b'', path='/', query=None, fragment=None, hash=None)[source]¶ Generate an arcp URI for a given archive hash checksum.
- Parameters:
- bytes – Optional bytes of archive to checksum
- path – Optional path within archive.
- query – Optional query component.
- fragment – Optional fragment component.
- hash – Optional hash instance from
hashlib.sha256()
Either
bytes
orhash
must be provided. Thehash
parameter can be provided to avoid representing the whole archive bytes in memory.
-
arcp.generate.
arcp_location
(location, path='/', query=None, fragment=None, namespace=UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8'))[source]¶ Generate an arcp URI for a given archive location.
- Parameters:
- location: URL or location of archive, e.g.
http://example.com/data.zip
- path – Optional path within archive.
- query – Optional query component.
- fragment – Optional fragment component.
- namespace – optional namespace UUID for non-URL location.
- location: URL or location of archive, e.g.
-
arcp.generate.
arcp_name
(name, path='/', query=None, fragment=None)[source]¶ Generate an arcp URI for a given archive name.
- Parameters:
- name – Absolute DNS or package name, e.g.
app.example.com
- path – Optional path within archive.
- query – Optional query component.
- fragment – Optional fragment component.
- namespace – optional namespace UUID for non-URL location.
- name – Absolute DNS or package name, e.g.
-
arcp.generate.
arcp_random
(path='/', query=None, fragment=None, uuid=None)[source]¶ Generate an arcp URI using a random uuid.
- Parameters:
- path – Optional path within archive.
- query – Optional query component.
- fragment – Optional fragment component.
- uuid – optional UUID v4 string or UUID instance
-
arcp.generate.
arcp_uuid
(uuid, path='/', query=None, fragment=None)[source]¶ Generate an arcp URI for the given uuid.
- Parameters:
- uuid – a uuid string or UUID instance identifying the archive, e.g.
58ca7fa6-be2f-48e4-8b69-e63fb0d929fe
- path – Optional path within archive.
- query – Optional query component.
- fragment – Optional fragment component.
- uuid – a uuid string or UUID instance identifying the archive, e.g.