gitea: Inherit from Gogs lister
This removes code and adds support for incremental pagination. While both are essentially the same lister now, it still makes sense to keep the Gitea lister separate, in order to: 1. display them in different categories on https://archive.softwareheritage.org/ 2. support possible divergence of APIs in the future
This commit is contained in:
parent
dde7865ac4
commit
17a219ece0
3 changed files with 32 additions and 132 deletions
|
@ -96,7 +96,8 @@ class GogsLister(Lister[GogsListerState, GogsListerPage]):
|
|||
"Using authentication credentials from user %s", username or "???"
|
||||
)
|
||||
else:
|
||||
raise ValueError("No credentials or API token provided")
|
||||
# Raises an error on Gogs, or a warning on Gitea
|
||||
self.on_anonymous_mode()
|
||||
|
||||
self.max_page_limit = 2
|
||||
|
||||
|
@ -105,10 +106,15 @@ class GogsLister(Lister[GogsListerState, GogsListerPage]):
|
|||
{
|
||||
"Accept": "application/json",
|
||||
"User-Agent": USER_AGENT,
|
||||
"Authorization": f"token {self.api_token}",
|
||||
}
|
||||
)
|
||||
|
||||
if self.api_token:
|
||||
self.session.headers["Authorization"] = f"token {self.api_token}"
|
||||
|
||||
def on_anonymous_mode(self):
|
||||
raise ValueError("No credentials or API token provided")
|
||||
|
||||
def state_from_dict(self, d: Dict[str, Any]) -> GogsListerState:
|
||||
return GogsListerState(**d)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue