|
Extract the UUID part from a MusicBrainz identifier.
This function takes a MusicBrainz ID (an absolute URI) as the input
and returns the UUID part of the URI, thus turning it into a relative
URI. If uriStr is None or a relative URI, then it is
returned unchanged.
The resType parameter can be used for error checking. Set
it to 'artist', 'release', or 'track' to make sure uriStr is
a syntactically valid MusicBrainz identifier of the given resource type.
If it isn't, a ValueError exception is raised. This error
checking only works if uriStr is an absolute URI, of
course.
Example:
>>> from musicbrainz2.utils import extractUuid
>>> extractUuid('http://musicbrainz.org/artist/c0b2500e-0cef-4130-869d-732b23ed9df5', 'artist')
'c0b2500e-0cef-4130-869d-732b23ed9df5'
>>>
- Parameters:
uriStr - a string containing a MusicBrainz ID (an URI), or None
resType - a string containing a resource type
- Returns:
- a string containing a relative URI, or None
- Raises:
ValueError - the given URI is no valid MusicBrainz ID
|