core: make it possible to specify the api_baseurl init argument in override_config
This is required to be able to make lister classes instanciation easier and more reliable, especially in the context of cli tools like 'swh lister run', for which we want to be able to specify any lister init argument as extra parameter of the command.
This commit is contained in:
parent
3816b4d3bf
commit
22f2f2c43c
3 changed files with 7 additions and 3 deletions
|
@ -245,5 +245,5 @@ class IndexingHttpLister(ListerHttpTransport, IndexingLister):
|
|||
"""Convenience class for ensuring right lookup and init order
|
||||
when combining IndexingLister and ListerHttpTransport."""
|
||||
def __init__(self, api_baseurl=None, override_config=None):
|
||||
ListerHttpTransport.__init__(self, api_baseurl=api_baseurl)
|
||||
IndexingLister.__init__(self, override_config=override_config)
|
||||
ListerHttpTransport.__init__(self, api_baseurl=api_baseurl)
|
||||
|
|
|
@ -29,7 +29,7 @@ class ListerHttpTransport(abc.ABC):
|
|||
|
||||
To be used in conjunction with ListerBase or a subclass of it.
|
||||
"""
|
||||
|
||||
DEFAULT_URL = None
|
||||
PATH_TEMPLATE = AbstractAttribute('string containing a python string'
|
||||
' format pattern that produces the API'
|
||||
' endpoint path for listing stored'
|
||||
|
@ -143,6 +143,10 @@ class ListerHttpTransport(abc.ABC):
|
|||
return False, 0
|
||||
|
||||
def __init__(self, api_baseurl=None):
|
||||
if not api_baseurl:
|
||||
api_baseurl = self.config.get('api_baseurl')
|
||||
if not api_baseurl:
|
||||
api_baseurl = self.DEFAULT_URL
|
||||
if not api_baseurl:
|
||||
raise NameError('HTTP Lister Transport requires api_baseurl.')
|
||||
self.api_baseurl = api_baseurl # eg. 'https://api.github.com'
|
||||
|
|
|
@ -156,5 +156,5 @@ class PageByPageHttpLister(ListerHttpTransport, PageByPageLister):
|
|||
|
||||
"""
|
||||
def __init__(self, api_baseurl=None, override_config=None):
|
||||
ListerHttpTransport.__init__(self, api_baseurl=api_baseurl)
|
||||
PageByPageLister.__init__(self, override_config=override_config)
|
||||
ListerHttpTransport.__init__(self, api_baseurl=api_baseurl)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue