Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/metadata_dictionary.py
Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | def parse_repositories(self, d): | ||||
res = self.parse_repository(d, repo) | res = self.parse_repository(d, repo) | ||||
if res: | if res: | ||||
results.append(res) | results.append(res) | ||||
return results | return results | ||||
def parse_repository(self, d, repo): | def parse_repository(self, d, repo): | ||||
if repo.get('layout', 'default') != 'default': | if repo.get('layout', 'default') != 'default': | ||||
return # TODO ? | return # TODO ? | ||||
url = repo['url'] | url = repo.get('url') | ||||
if d['groupId']: | group_id = d.get('groupId') | ||||
url = os.path.join(url, *d['groupId'].split('.')) | artifact_id = d.get('artifactId') | ||||
if d['artifactId']: | if isinstance(url, str): | ||||
url = os.path.join(url, d['artifactId']) | if isinstance(group_id, str): | ||||
url = os.path.join(url, *group_id.split('.')) | |||||
if isinstance(artifact_id, str): | |||||
url = os.path.join(url, artifact_id) | |||||
return {"@id": url} | return {"@id": url} | ||||
douardda: I find this code a bit bloated.
Is it possible to have something other than a str or None for… | |||||
def normalize_groupId(self, id_): | def normalize_groupId(self, id_): | ||||
return {"@id": id_} | return {"@id": id_} | ||||
def parse_licenses(self, d): | def parse_licenses(self, d): | ||||
"""https://maven.apache.org/pom.html#Licenses | """https://maven.apache.org/pom.html#Licenses | ||||
The origin XML has the form: | The origin XML has the form: | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |
I find this code a bit bloated.
Is it possible to have something other than a str or None for these values? (url, group and artifact) ?
Isn't this code enough?
Hard to tell since it seems this method has no unit test 😈