Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/metadata_dictionary/npm.py
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | def normalize_author(self, d): | ||||
""" # noqa | """ # noqa | ||||
author = {'@type': SCHEMA_URI+'Person'} | author = {'@type': SCHEMA_URI+'Person'} | ||||
if isinstance(d, dict): | if isinstance(d, dict): | ||||
name = d.get('name', None) | name = d.get('name', None) | ||||
email = d.get('email', None) | email = d.get('email', None) | ||||
url = d.get('url', None) | url = d.get('url', None) | ||||
elif isinstance(d, str): | elif isinstance(d, str): | ||||
match = self._parse_author.match(d) | match = self._parse_author.match(d) | ||||
if not match: | |||||
return None | |||||
name = match.group('name') | name = match.group('name') | ||||
email = match.group('email') | email = match.group('email') | ||||
url = match.group('url') | url = match.group('url') | ||||
else: | else: | ||||
return None | return None | ||||
if name and isinstance(name, str): | if name and isinstance(name, str): | ||||
author[SCHEMA_URI+'name'] = name | author[SCHEMA_URI+'name'] = name | ||||
if email and isinstance(email, str): | if email and isinstance(email, str): | ||||
Show All 31 Lines |