Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/maven/lister.py
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | def get_pages(self) -> Iterator[RepoPage]: | ||||
try: | try: | ||||
response = self.page_request(pom, {}) | response = self.page_request(pom, {}) | ||||
project = xmltodict.parse(response.content.decode()) | project = xmltodict.parse(response.content.decode()) | ||||
project_d = project.get("project", {}) | project_d = project.get("project", {}) | ||||
scm_d = project_d.get("scm") | scm_d = project_d.get("scm") | ||||
if scm_d is not None: | if scm_d is not None: | ||||
connection = scm_d.get("connection") | connection = scm_d.get("connection") | ||||
if connection is not None: | if connection is not None: | ||||
scm = connection | |||||
gid = project_d["groupId"] | |||||
aid = project_d["artifactId"] | |||||
artifact_metadata_d = { | artifact_metadata_d = { | ||||
"type": "scm", | "type": "scm", | ||||
"doc": out_pom[pom], | "doc": out_pom[pom], | ||||
"url": scm, | "url": connection, | ||||
"project": f"{gid}.{aid}", | |||||
} | } | ||||
logger.debug("* Yielding pom %s: %s", pom, artifact_metadata_d) | logger.debug("* Yielding pom %s: %s", pom, artifact_metadata_d) | ||||
yield artifact_metadata_d | yield artifact_metadata_d | ||||
else: | else: | ||||
logger.debug("No scm.connection in pom %s", pom) | logger.debug("No scm.connection in pom %s", pom) | ||||
else: | else: | ||||
logger.debug("No scm in pom %s", pom) | logger.debug("No scm in pom %s", pom) | ||||
except requests.HTTPError: | except requests.HTTPError: | ||||
Show All 16 Lines | def get_origins_from_page(self, page: RepoPage) -> Iterator[ListedOrigin]: | ||||
# detect the content to match it properly. | # detect the content to match it properly. | ||||
m_scm = re.match(r"^scm:(?P<type>[^:]+):(?P<url>.*)$", page["url"]) | m_scm = re.match(r"^scm:(?P<type>[^:]+):(?P<url>.*)$", page["url"]) | ||||
if m_scm is not None: | if m_scm is not None: | ||||
scm_type = m_scm.group("type") | scm_type = m_scm.group("type") | ||||
if scm_type in scm_types_ok: | if scm_type in scm_types_ok: | ||||
scm_url = m_scm.group("url") | scm_url = m_scm.group("url") | ||||
origin = ListedOrigin( | origin = ListedOrigin( | ||||
lister_id=self.lister_obj.id, | lister_id=self.lister_obj.id, | ||||
url=scm_url, | url=scm_url, | ||||
ardumont: right ^! | |||||
visit_type=scm_type, | visit_type=scm_type, | ||||
) | ) | ||||
yield origin | yield origin | ||||
else: | else: | ||||
if page["url"].endswith(".git"): | if page["url"].endswith(".git"): | ||||
origin = ListedOrigin( | origin = ListedOrigin( | ||||
lister_id=self.lister_obj.id, | lister_id=self.lister_obj.id, | ||||
url=page["url"], | url=page["url"], | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |
right ^!