From a3412301f0aa942df11cf86b47933998064a1b44 Mon Sep 17 00:00:00 2001 From: MestreLion Date: Tue, 20 Feb 2018 20:18:24 -0300 Subject: [PATCH] improve PY2/3 imports and documentation --- httpbot.py | 15 +++++++-------- humblebundle.py | 13 +++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/httpbot.py b/httpbot.py index 5c6c4fa..097c4c1 100644 --- a/httpbot.py +++ b/httpbot.py @@ -25,17 +25,16 @@ import hashlib if sys.version_info.major < 3: - import urllib2 - import urlparse + import urllib2 # @UnresolvedImport + import urlparse # @UnresolvedImport else: - urllib2 = urllib.request - urlparse = urllib.parse + urllib2 = urllib.request # @UndefinedVariable + urlparse = urllib.parse # @UndefinedVariable -# Debian/Ubuntu: python-lxml -from lxml import html + +from lxml import html # Debian/Ubuntu: python-lxml try: - # Debian/Ubuntu: python-progressbar - import progressbar + import progressbar # Debian/Ubuntu: python-progressbar except ImportError: progressbar = None diff --git a/humblebundle.py b/humblebundle.py index 96cd9f8..c4160c9 100755 --- a/humblebundle.py +++ b/humblebundle.py @@ -39,25 +39,26 @@ import shlex import shutil -if sys.version_info.major < 3: +try: import cookielib from urlparse import urljoin, urlsplit, parse_qs import Queue -else: +except ImportError: # Python 3 import http.cookiejar as cookielib from urllib.parse import urljoin, urlsplit, parse_qs import queue as Queue -# Debian/Ubuntu: python-xdg -import xdg.BaseDirectory as xdg + +import xdg.BaseDirectory as xdg # Debian/Ubuntu: python-xdg try: - # Debian/Ubuntu: python-keyring - import keyring + import keyring # Debian/Ubuntu: python-keyring except ImportError: keyring = None + import httpbot + log = logging.getLogger(__name__)