Verified Commit 9874f932 authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

index: make requests optional, but recommended

parent 2a46aec4
......@@ -3,13 +3,25 @@
from io import BytesIO
import logging
import os
import requests
import tarfile
from apkkit.base.package import Package
INDEX_LOGGER = logging.getLogger(__name__)
"""The logger for messages coming from this module."""
# logger needed. pylint: disable=wrong-import-order,wrong-import-position
import requests
"""Determines if the `requests` module is available."""
except ImportError:
INDEX_LOGGER.warning("You need install Requests to load indexes over "
"the network.")
"""Determines if the `requests` module is available."""
class Index:
......@@ -28,9 +40,11 @@ class Index:
:param str url:
(Optional) The URL to download the index from. All other
parameters are ignored if this is specified.
.. note:: URL downloading requires the Requests module to be installed.
if url is not None:
if HAVE_REQUESTS and url is not None:
self._url = url
resp = requests.get(url)
if resp.status_code != 200:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment