Staging instance, all changes can be removed at any time

Skip to content

identifiers: Make invalid persistent identifier parsing raise error

So far we accept any kinds of persistent identifier, including invalid ones. We should raise instead.

Related #1104 (closed)

Before, for example:

$ python3
In [1]: from swh.model.identifiers import parse_persistent_identifier
In [2]: parse_persistent_identifier('foo')
Out[2]: {'namespace': 'foo', 'scheme_version': {}}

Now:

$ python3
Python 3.6.6rc1 (default, Jun 13 2018, 06:59:48)
[GCC 8.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from swh.model.identifiers import parse_persistent_identifier
>>> parse_persistent_identifier('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-model/swh/model/identifiers.py", line 677, in parse_persistent_identifier
    'Wrong format: There should be 4 mandatory parameters')
swh.model.identifiers.SWHMalformedIdentifierException: Wrong format: There should be 4 mandatory parameters

Test Plan

Tests should still pass


Migrated from D346 (view on Phabricator)

Merge request reports

Loading