Allow re-use of method to get any URL

This commit is contained in:
Kovid Goyal 2020-12-27 10:18:01 +05:30
parent 28455a23c4
commit ffdf794246
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -99,11 +99,12 @@ def parse_metadata(full_name, raw_bytes):
return module_version, minimum_calibre_version return module_version, minimum_calibre_version
def fetch_module(full_name, etag=None, timeout=default_timeout): def fetch_module(full_name, etag=None, timeout=default_timeout, url=None):
if timeout is default_timeout: if timeout is default_timeout:
timeout = DEFAULT_TIMEOUT timeout = DEFAULT_TIMEOUT
path = '/'.join(full_name.split('.')) + '.py' if url is None:
url = 'https://code.calibre-ebook.com/src/' + path path = '/'.join(full_name.split('.')) + '.py'
url = 'https://code.calibre-ebook.com/src/' + path
headers = {'accept-encoding': 'gzip'} headers = {'accept-encoding': 'gzip'}
if etag: if etag:
headers['if-none-match'] = f'"{etag}"' headers['if-none-match'] = f'"{etag}"'