Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def normalize_identifier(self, data):
"""Normalize identifier."""
data['identifier'] = idutils.normalize_pid(
data['identifier'], data['scheme'])
def _deserialize(self, value, attr, data):
"""Deserialize persistent identifier value."""
value = super(PersistentId, self)._deserialize(value, attr, data)
value = value.strip()
schemes = idutils.detect_identifier_schemes(value)
if self.scheme and self.scheme.lower() not in schemes:
self.fail('invalid_scheme', scheme=self.scheme)
if not schemes:
self.fail('invalid_pid')
return idutils.normalize_pid(value, schemes[0]) \
if self.normalize else value