Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/github/lister.py
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | def get_next_target_from_response(self, response): | ||||
next_url = response.links['next']['url'] | next_url = response.links['next']['url'] | ||||
return int(self.API_URL_INDEX_RE.match(next_url).group(1)) | return int(self.API_URL_INDEX_RE.match(next_url).group(1)) | ||||
def transport_response_simplified(self, response): | def transport_response_simplified(self, response): | ||||
repos = response.json() | repos = response.json() | ||||
return [self.get_model_from_repo(repo) for repo in repos] | return [self.get_model_from_repo(repo) for repo in repos] | ||||
def request_headers(self): | def request_headers(self): | ||||
return {'Accept': 'application/vnd.github.v3+json'} | """(Override) Set requests headers to send when querying the GitHub API | ||||
""" | |||||
headers = super().request_headers() | |||||
headers['Accept'] = 'application/vnd.github.v3+json' | |||||
return headers | |||||
def disable_deleted_repo_tasks(self, index, next_index, keep_these): | def disable_deleted_repo_tasks(self, index, next_index, keep_these): | ||||
""" (Overrides) Fix provided index value to avoid erroneously disabling | """ (Overrides) Fix provided index value to avoid erroneously disabling | ||||
some scheduler tasks | some scheduler tasks | ||||
""" | """ | ||||
# Next listed repository ids are strictly greater than the 'since' | # Next listed repository ids are strictly greater than the 'since' | ||||
# parameter, so increment the index to avoid disabling the latest | # parameter, so increment the index to avoid disabling the latest | ||||
# created task when processing a new repositories page returned by | # created task when processing a new repositories page returned by | ||||
# the Github API | # the Github API | ||||
return super().disable_deleted_repo_tasks(index + 1, next_index, | return super().disable_deleted_repo_tasks(index + 1, next_index, | ||||
keep_these) | keep_these) |