Changeset View
Changeset View
Standalone View
Standalone View
swh/model/identifiers.py
Show First 20 Lines • Show All 639 Lines • ▼ Show 20 Lines | Args: | ||||
object_type (str): the type of object the identifier points to, | object_type (str): the type of object the identifier points to, | ||||
either 'content', 'directory', 'release', 'revision' or 'snapshot' | either 'content', 'directory', 'release', 'revision' or 'snapshot' | ||||
object_id (dict/bytes/str): object's dict representation or | object_id (dict/bytes/str): object's dict representation or | ||||
object identifier | object identifier | ||||
metadata (dict): optional dict filled with metadata related to | metadata (dict): optional dict filled with metadata related to | ||||
pointed object | pointed object | ||||
Raises: | Raises: | ||||
swh.model.exceptions.ValidationError: In case of invalid object type or id | swh.model.exceptions.ValidationError: In case of invalid object type | ||||
or id | |||||
Once created, it contains the following attributes: | Once created, it contains the following attributes: | ||||
Attributes: | Attributes: | ||||
namespace (str): the namespace of the identifier | namespace (str): the namespace of the identifier | ||||
scheme_version (int): the scheme version of the identifier | scheme_version (int): the scheme version of the identifier | ||||
object_type (str): the type of object the identifier points to | object_type (str): the type of object the identifier points to | ||||
object_id (str): hexadecimal representation of the object hash | object_id (str): hexadecimal representation of the object hash | ||||
metadata (dict): metadata related to the pointed object | metadata (dict): metadata related to the pointed object | ||||
To get the raw persistent identifier string from an instance of | To get the raw persistent identifier string from an instance of | ||||
this named tuple, use the :func:`str` function:: | this named tuple, use the :func:`str` function:: | ||||
pid = PersistentId(object_type='content', object_id='8ff44f081d43176474b267de5451f2c2e88089d0') | pid = PersistentId( | ||||
twitu: this one is just exceeding 80 characters, it would mean moving the comment to the next line… | |||||
Not Done Inline ActionsIt should be fine on the next line. vlorentz: It should be fine on the next line. | |||||
pid_str = str(pid) # 'swh:1:cnt:8ff44f081d43176474b267de5451f2c2e88089d0' | object_type='content', | ||||
""" # noqa | object_id='8ff44f081d43176474b267de5451f2c2e88089d0' | ||||
) | |||||
pid_str = str(pid) | |||||
# 'swh:1:cnt:8ff44f081d43176474b267de5451f2c2e88089d0' | |||||
""" | |||||
__slots__ = () | __slots__ = () | ||||
def __new__(cls, namespace='swh', scheme_version=1, | def __new__(cls, namespace='swh', scheme_version=1, | ||||
object_type='', object_id='', metadata={}): | object_type='', object_id='', metadata={}): | ||||
o = _object_type_map.get(object_type) | o = _object_type_map.get(object_type) | ||||
if not o: | if not o: | ||||
raise ValidationError('Wrong input: Supported types are %s' % ( | raise ValidationError('Wrong input: Supported types are %s' % ( | ||||
list(_object_type_map.keys()))) | list(_object_type_map.keys()))) | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |
this one is just exceeding 80 characters, it would mean moving the comment to the next line, which defeats the purpose of the line comment.