python: Reformat code with black 22.3.0
Related to T3922
This commit is contained in:
parent
00f1b99ad9
commit
d38e05cff7
37 changed files with 265 additions and 144 deletions
|
@ -87,12 +87,18 @@ class MavenLister(Lister[MavenListerState, RepoPage]):
|
|||
instance = parse_url(url).host
|
||||
|
||||
super().__init__(
|
||||
scheduler=scheduler, credentials=credentials, url=url, instance=instance,
|
||||
scheduler=scheduler,
|
||||
credentials=credentials,
|
||||
url=url,
|
||||
instance=instance,
|
||||
)
|
||||
|
||||
self.session = requests.Session()
|
||||
self.session.headers.update(
|
||||
{"Accept": "application/json", "User-Agent": USER_AGENT,}
|
||||
{
|
||||
"Accept": "application/json",
|
||||
"User-Agent": USER_AGENT,
|
||||
}
|
||||
)
|
||||
|
||||
def state_from_dict(self, d: Dict[str, Any]) -> MavenListerState:
|
||||
|
@ -119,7 +125,7 @@ class MavenLister(Lister[MavenListerState, RepoPage]):
|
|||
return response
|
||||
|
||||
def get_pages(self) -> Iterator[RepoPage]:
|
||||
""" Retrieve and parse exported maven indexes to
|
||||
"""Retrieve and parse exported maven indexes to
|
||||
identify all pom files and src archives.
|
||||
"""
|
||||
|
||||
|
@ -213,7 +219,10 @@ class MavenLister(Lister[MavenListerState, RepoPage]):
|
|||
):
|
||||
continue
|
||||
url_path = f"{path}/{aid}/{version}/{aid}-{version}.{ext}"
|
||||
url_pom = urljoin(self.BASE_URL, url_path,)
|
||||
url_pom = urljoin(
|
||||
self.BASE_URL,
|
||||
url_path,
|
||||
)
|
||||
out_pom[url_pom] = doc_id
|
||||
elif (
|
||||
classifier.lower() == "sources" or ("src" in classifier)
|
||||
|
@ -271,9 +280,7 @@ class MavenLister(Lister[MavenListerState, RepoPage]):
|
|||
logger.info("Could not parse POM %s XML: %s. Next.", pom, error)
|
||||
|
||||
def get_origins_from_page(self, page: RepoPage) -> Iterator[ListedOrigin]:
|
||||
"""Convert a page of Maven repositories into a list of ListedOrigins.
|
||||
|
||||
"""
|
||||
"""Convert a page of Maven repositories into a list of ListedOrigins."""
|
||||
assert self.lister_obj.id is not None
|
||||
scm_types_ok = ("git", "svn", "hg", "cvs", "bzr")
|
||||
if page["type"] == "scm":
|
||||
|
@ -288,13 +295,17 @@ class MavenLister(Lister[MavenListerState, RepoPage]):
|
|||
if scm_type in scm_types_ok:
|
||||
scm_url = m_scm.group("url")
|
||||
origin = ListedOrigin(
|
||||
lister_id=self.lister_obj.id, url=scm_url, visit_type=scm_type,
|
||||
lister_id=self.lister_obj.id,
|
||||
url=scm_url,
|
||||
visit_type=scm_type,
|
||||
)
|
||||
yield origin
|
||||
else:
|
||||
if page["url"].endswith(".git"):
|
||||
origin = ListedOrigin(
|
||||
lister_id=self.lister_obj.id, url=page["url"], visit_type="git",
|
||||
lister_id=self.lister_obj.id,
|
||||
url=page["url"],
|
||||
visit_type="git",
|
||||
)
|
||||
yield origin
|
||||
else:
|
||||
|
|
|
@ -84,7 +84,12 @@ def maven_pom_3(datadir) -> str:
|
|||
|
||||
|
||||
def test_maven_full_listing(
|
||||
swh_scheduler, requests_mock, mocker, maven_index, maven_pom_1, maven_pom_2,
|
||||
swh_scheduler,
|
||||
requests_mock,
|
||||
mocker,
|
||||
maven_index,
|
||||
maven_pom_1,
|
||||
maven_pom_2,
|
||||
):
|
||||
"""Covers full listing of multiple pages, checking page results and listed
|
||||
origins, statelessness."""
|
||||
|
|
|
@ -35,7 +35,8 @@ def test_task_lister_maven(
|
|||
url="https://repo1.maven.org/maven2/", index_url="http://indexes/export.fld"
|
||||
)
|
||||
res = swh_scheduler_celery_app.send_task(
|
||||
f"swh.lister.maven.tasks.{task_name}", kwargs=kwargs,
|
||||
f"swh.lister.maven.tasks.{task_name}",
|
||||
kwargs=kwargs,
|
||||
)
|
||||
assert res
|
||||
res.wait()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue