From a72791507f12b4404ba18be0272958230a2ac7a2 Mon Sep 17 00:00:00 2001 From: agnewee Date: Mon, 4 Dec 2017 23:55:25 +0800 Subject: [PATCH] move ulib and urlparse to compat --- pydu/compat.py | 6 +++++- pydu/request.py | 9 +-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pydu/compat.py b/pydu/compat.py index 0444588..9700eae 100644 --- a/pydu/compat.py +++ b/pydu/compat.py @@ -4,10 +4,14 @@ import sys PY2 = sys.version_info[0] == 2 -# urljoin +# urllib, urlparse and urljoin if PY2: + import urllib as ulib + import urlparse from urlparse import urljoin else: + import urllib.request as ulib + import urllib.parse as urlparse from urllib.parse import urljoin # Dictionary iteration diff --git a/pydu/request.py b/pydu/request.py index b74660a..ee7ff37 100644 --- a/pydu/request.py +++ b/pydu/request.py @@ -1,16 +1,9 @@ import os import shutil import tempfile -from pydu.compat import PY2, string_types +from pydu.compat import string_types, ulib, urlparse from pydu.string import safeunicode -if PY2: - import urllib as ulib - import urlparse -else: - import urllib.request as ulib - import urllib.parse as urlparse - class FileName(object): @staticmethod