Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cgit/lister.py
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | def __init__( | ||||
credentials: Optional[CredentialsType] = None, | credentials: Optional[CredentialsType] = None, | ||||
base_git_url: Optional[str] = None, | base_git_url: Optional[str] = None, | ||||
): | ): | ||||
"""Lister class for CGit repositories. | """Lister class for CGit repositories. | ||||
Args: | Args: | ||||
url: main URL of the CGit instance, i.e. url of the index | url: main URL of the CGit instance, i.e. url of the index | ||||
of published git repositories on this instance. | of published git repositories on this instance. | ||||
instance: Name of cgit instance. Defaults to url's hostname | instance: Name of cgit instance. Defaults to url's network location | ||||
if unset. | if unset. | ||||
base_git_url: Optional base git url which allows the origin url | base_git_url: Optional base git url which allows the origin url | ||||
computations. | computations. | ||||
""" | """ | ||||
if not instance: | |||||
instance = urlparse(url).hostname | |||||
assert instance is not None # Make mypy happy | |||||
super().__init__( | super().__init__( | ||||
scheduler=scheduler, url=url, instance=instance, credentials=credentials, | scheduler=scheduler, url=url, instance=instance, credentials=credentials, | ||||
) | ) | ||||
self.session = requests.Session() | self.session = requests.Session() | ||||
self.session.headers.update( | self.session.headers.update( | ||||
{"Accept": "application/html", "User-Agent": USER_AGENT} | {"Accept": "application/html", "User-Agent": USER_AGENT} | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |