summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-05-23 23:00:48 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-05-23 23:00:48 -0500
commit9874f9321b1d6bc28f299da624455c7a07832c7f (patch)
treeff11f5e0d8073755d8712723927662d379c38fb5
parent2a46aec465207280f31dbe8031f420e8b9851ece (diff)
downloadapkkit-9874f9321b1d6bc28f299da624455c7a07832c7f.tar.gz
apkkit-9874f9321b1d6bc28f299da624455c7a07832c7f.tar.bz2
apkkit-9874f9321b1d6bc28f299da624455c7a07832c7f.tar.xz
apkkit-9874f9321b1d6bc28f299da624455c7a07832c7f.zip
index: make requests optional, but recommended
-rw-r--r--apkkit/base/index.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/apkkit/base/index.py b/apkkit/base/index.py
index ee0af9f..3976932 100644
--- a/apkkit/base/index.py
+++ b/apkkit/base/index.py
@@ -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."""
+
+
+try:
+ # logger needed. pylint: disable=wrong-import-order,wrong-import-position
+ import requests
+ HAVE_REQUESTS = True
+ """Determines if the `requests` module is available."""
+except ImportError:
+ INDEX_LOGGER.warning("You need install Requests to load indexes over "
+ "the network.")
+ HAVE_REQUESTS = False
+ """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: