swh.lister.core.lister_transports: Fix typo and pep8 violations

This commit is contained in:
Antoine R. Dumont (@ardumont) 2018-06-28 13:33:04 +02:00
parent 1540c989b5
commit c350434127
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8
2 changed files with 10 additions and 8 deletions

View file

@ -134,9 +134,9 @@ class SWHListerBase(abc.ABC, config.SWHConfig):
pass
def filter_before_inject(self, models_list):
"""Function run after transport_response_simplified but before injection
into the local db and creation of workers. Can be used to eliminate
some of the results if necessary.
"""Function run after transport_response_simplified but before
injection into the local db and creation of workers. Can be
used to eliminate some of the results if necessary.
MAY BE OVERRIDDEN if an intermediate Lister class needs to filter
results before injection without requiring every child class to do so.

View file

@ -55,11 +55,12 @@ class SWHListerHttpTransport(abc.ABC):
return self.api_baseurl + path
def request_params(self, identifier):
"""Get the full parameters passed to requests given the transport_request
identifier.
"""Get the full parameters passed to requests given the
transport_request identifier.
MAY BE OVERRIDDEN if something more complex than the request headers
ois needed.
is needed.
"""
params = {}
params['headers'] = self.request_headers() or {}
@ -70,12 +71,13 @@ class SWHListerHttpTransport(abc.ABC):
return params
def transport_quota_check(self, response):
"""Implements SWHListerBase.transport_quota_check with standard 429 code
check for HTTP with Requests library.
"""Implements SWHListerBase.transport_quota_check with standard 429
code check for HTTP with Requests library.
MAY BE OVERRIDDEN if the server notifies about rate limits in a
non-standard way that doesn't use HTTP 429 and the Retry-After
response header. ( https://tools.ietf.org/html/rfc6585#section-4 )
"""
if response.status_code == 429: # HTTP too many requests
retry_after = response.headers.get('Retry-After', self.back_off())