Scrapy, a fast high-level web crawling & scraping framework for Python.
Remove six.moves occurrences
Eugenio Lacuestadf00389c16fc
diff --git a/scrapy/_monkeypatches.py b/scrapy/_monkeypatches.pyindex 1f8067b35..f74f89bda 100644--- a/scrapy/_monkeypatches.py+++ b/scrapy/_monkeypatches.py@@ -1,4 +1,4 @@-from six.moves import copyreg+import copyreg# Undo what Twisted's perspective broker adds to pickle registerdiff --git a/scrapy/commands/bench.py b/scrapy/commands/bench.pyindex 90c8d56a2..7bbe362e7 100644--- a/scrapy/commands/bench.py+++ b/scrapy/commands/bench.py@@ -1,8 +1,7 @@import sysimport timeimport subprocess--from six.moves.urllib.parse import urlencode+from urllib.parse import urlencodeimport scrapyfrom scrapy.commands import ScrapyCommanddiff --git a/scrapy/core/downloader/handlers/ftp.py b/scrapy/core/downloader/handlers/ftp.pyindex 806a537d4..2116a5a44 100644--- a/scrapy/core/downloader/handlers/ftp.py+++ b/scrapy/core/downloader/handlers/ftp.py@@ -30,7 +30,7 @@ In case of status 200 request, response.headers will come with two keys:import refrom io import BytesIO-from six.moves.urllib.parse import unquote+from urllib.parse import unquotefrom twisted.internet import reactorfrom twisted.protocols.ftp import FTPClient, CommandFaileddiff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.pyindex 7d917cb74..63dedc19b 100644--- a/scrapy/core/downloader/handlers/http11.py+++ b/scrapy/core/downloader/handlers/http11.py@@ -2,10 +2,10 @@import reimport logging+import warningsfrom io import BytesIOfrom time import time-import warnings-from six.moves.urllib.parse import urldefrag+from urllib.parse import urldefragfrom zope.interface import implementerfrom twisted.internet import defer, reactor, protocoldiff --git a/scrapy/core/downloader/handlers/s3.py b/scrapy/core/downloader/handlers/s3.pyindex d8bbdd326..85b733228 100644--- a/scrapy/core/downloader/handlers/s3.py+++ b/scrapy/core/downloader/handlers/s3.py@@ -1,4 +1,4 @@-from six.moves.urllib.parse import unquote+from urllib.parse import unquotefrom scrapy.exceptions import NotConfiguredfrom scrapy.utils.httpobj import urlparse_cacheddiff --git a/scrapy/core/downloader/webclient.py b/scrapy/core/downloader/webclient.pyindex 3a5890ed0..9699da109 100644--- a/scrapy/core/downloader/webclient.py+++ b/scrapy/core/downloader/webclient.py@@ -1,5 +1,5 @@from time import time-from six.moves.urllib.parse import urlparse, urlunparse, urldefrag+from urllib.parse import urlparse, urlunparse, urldefragfrom twisted.web.client import HTTPClientFactoryfrom twisted.web.http import HTTPClientdiff --git a/scrapy/downloadermiddlewares/httpproxy.py b/scrapy/downloadermiddlewares/httpproxy.pyindex 2212d9688..814ce78fe 100644--- a/scrapy/downloadermiddlewares/httpproxy.py+++ b/scrapy/downloadermiddlewares/httpproxy.py@@ -1,7 +1,6 @@import base64-from six.moves.urllib.parse import unquote, urlunparse-from six.moves.urllib.request import getproxies, proxy_bypass-from urllib.request import _parse_proxy+from urllib.parse import unquote, urlunparse+from urllib.request import getproxies, proxy_bypass, _parse_proxyfrom scrapy.exceptions import NotConfiguredfrom scrapy.utils.httpobj import urlparse_cacheddiff --git a/scrapy/downloadermiddlewares/redirect.py b/scrapy/downloadermiddlewares/redirect.pyindex b73f864dd..77cb5aa94 100644--- a/scrapy/downloadermiddlewares/redirect.py+++ b/scrapy/downloadermiddlewares/redirect.py@@ -1,5 +1,5 @@import logging-from six.moves.urllib.parse import urljoin, urlparse+from urllib.parse import urljoin, urlparsefrom w3lib.url import safe_url_string@@ -7,6 +7,7 @@ from scrapy.http import HtmlResponsefrom scrapy.utils.response import get_meta_refreshfrom scrapy.exceptions import IgnoreRequest, NotConfigured+logger = logging.getLogger(__name__)diff --git a/scrapy/exporters.py b/scrapy/exporters.pyindex f276c28e8..d9531e67c 100644--- a/scrapy/exporters.py+++ b/scrapy/exporters.py@@ -7,15 +7,16 @@ import ioimport sysimport pprintimport marshal-import six-from six.moves import cPickle as pickle+import warnings+from import picklefrom xml.sax.saxutils import XMLGenerator+import six+from scrapy.utils.serialize import ScrapyJSONEncoderfrom scrapy.utils.python import to_bytes, to_unicode, is_listlikefrom scrapy.item import BaseItemfrom scrapy.exceptions import ScrapyDeprecationWarning-import warnings__all__ = ['BaseItemExporter', 'PprintItemExporter', 'PickleItemExporter',diff --git a/scrapy/extensions/feedexport.py b/scrapy/extensions/feedexport.pyindex 07ffd3476..0b854e6f3 100644--- a/scrapy/extensions/feedexport.py+++ b/scrapy/extensions/feedexport.py@@ -10,7 +10,7 @@ import loggingimport posixpathfrom tempfile import NamedTemporaryFilefrom datetime import datetime-from six.moves.urllib.parse import urlparse, unquote+from urllib.parse import urlparse, unquotefrom ftplib import FTPfrom zope.interface import Interface, implementerdiff --git a/scrapy/extensions/httpcache.py b/scrapy/extensions/httpcache.pyindex b1ed0b9f8..b98ec218f 100644--- a/scrapy/extensions/httpcache.py+++ b/scrapy/extensions/httpcache.py@@ -1,13 +1,13 @@import gzipimport loggingimport os+import picklefrom email.utils import mktime_tz, parsedate_tzfrom importlib import import_modulefrom time import timefrom warnings import warnfrom weakref import WeakKeyDictionary-from six.moves import cPickle as picklefrom w3lib.http import headers_raw_to_dict, headers_dict_to_rawfrom scrapy.exceptions import ScrapyDeprecationWarningdiff --git a/scrapy/extensions/spiderstate.py b/scrapy/extensions/spiderstate.pyindex 2220cbd8f..2c8e46914 100644--- a/scrapy/extensions/spiderstate.py+++ b/scrapy/extensions/spiderstate.py@@ -1,10 +1,11 @@import os-from six.moves import cPickle as pickle+import picklefrom scrapy import signalsfrom scrapy.exceptions import NotConfiguredfrom scrapy.utils.job import job_dir+class SpiderState(object):"""Store and load spider state during a scraping job"""diff --git a/scrapy/http/cookies.py b/scrapy/http/cookies.pyindex 4532c3ab7..c39de0b52 100644--- a/scrapy/http/cookies.py+++ b/scrapy/http/cookies.py@@ -1,7 +1,6 @@import time-from six.moves.http_cookiejar import (- CookieJar as _CookieJar, DefaultCookiePolicy, IPV4_RE-)+from http.cookiejar import CookieJar as _CookieJar, DefaultCookiePolicy, IPV4_RE+from scrapy.utils.httpobj import urlparse_cachedfrom scrapy.utils.python import to_unicodediff --git a/scrapy/http/request/form.py b/scrapy/http/request/form.pyindex b6feede07..d2bcf77b7 100644--- a/scrapy/http/request/form.py+++ b/scrapy/http/request/form.py@@ -5,10 +5,10 @@ This module implements the FormRequest class which is a more convenient classSee documentation in docs/topics/request-response.rst"""-import six-from six.moves.urllib.parse import urljoin, urlencode+from urllib.parse import urljoin, urlencodeimport lxml.html+import sixfrom parsel.selector import create_root_nodefrom w3lib.html import strip_html5_whitespacediff --git a/scrapy/http/request/rpc.py b/scrapy/http/request/rpc.pyindex bd09f7534..811d3ad6b 100644--- a/scrapy/http/request/rpc.py+++ b/scrapy/http/request/rpc.py@@ -4,7 +4,7 @@ This module implements the XmlRpcRequest class which is a more convenient classSee documentation in docs/topics/request-response.rst"""-from six.moves import xmlrpc_client as xmlrpclib+import xmlrpc.client as xmlrpclibfrom scrapy.http.request import Requestfrom scrapy.utils.python import get_func_argsdiff --git a/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.pyindex a81404afb..64e9c6c20 100644--- a/scrapy/http/response/__init__.py+++ b/scrapy/http/response/__init__.py@@ -4,7 +4,7 @@ responses in Scrapy.See documentation in docs/topics/request-response.rst"""-from six.moves.urllib.parse import urljoin+from urllib.parse import urljoinfrom scrapy.http.request import Requestfrom scrapy.http.headers import Headersdiff --git a/scrapy/http/response/text.py b/scrapy/http/response/text.pyindex 37f450e54..69bcba577 100644--- a/scrapy/http/response/text.py+++ b/scrapy/http/response/text.py@@ -5,10 +5,10 @@ discovering (through HTTP headers) to base Response class.See documentation in docs/topics/request-response.rst"""-import six-from six.moves.urllib.parse import urljoin+from urllib.parse import urljoinimport parsel+import sixfrom w3lib.encoding import html_to_unicode, resolve_encoding, \html_body_declared_encoding, http_content_type_encodingfrom w3lib.html import strip_html5_whitespacediff --git a/scrapy/linkextractors/__init__.py b/scrapy/linkextractors/__init__.pyindex ebf3cd7d8..594c7264d 100644--- a/scrapy/linkextractors/__init__.py+++ b/scrapy/linkextractors/__init__.py@@ -6,8 +6,8 @@ This package contains a collection of Link Extractors.For more info see docs/topics/link-extractors.rst"""import re+from urllib.parse import urlparse-from six.moves.urllib.parse import urlparsefrom parsel.csstranslator import HTMLTranslatorfrom w3lib.url import canonicalize_urldiff --git a/scrapy/linkextractors/htmlparser.py b/scrapy/linkextractors/htmlparser.pyindex 27978a8a1..623732cee 100644--- a/scrapy/linkextractors/htmlparser.py+++ b/scrapy/linkextractors/htmlparser.py@@ -2,10 +2,10 @@HTMLParser-based link extractor"""import warnings-import six-from six.moves.html_parser import HTMLParser-from six.moves.urllib.parse import urljoin+from html.parser import HTMLParser+from urllib.parse import urljoin+import sixfrom w3lib.url import safe_url_stringfrom w3lib.html import strip_html5_whitespacediff --git a/scrapy/linkextractors/lxmlhtml.py b/scrapy/linkextractors/lxmlhtml.pyindex 890c019c8..5b7e709de 100644--- a/scrapy/linkextractors/lxmlhtml.py+++ b/scrapy/linkextractors/lxmlhtml.py@@ -1,9 +1,9 @@"""Link extractor based on lxml.html"""-import six-from six.moves.urllib.parse import urljoin+from urllib.parse import urljoin+import siximport lxml.etree as etreefrom w3lib.html import strip_html5_whitespacefrom w3lib.url import canonicalize_urldiff --git a/scrapy/linkextractors/regex.py b/scrapy/linkextractors/regex.pyindex e689b4727..f96db256b 100644--- a/scrapy/linkextractors/regex.py+++ b/scrapy/linkextractors/regex.py@@ -1,11 +1,12 @@import re-from six.moves.urllib.parse import urljoin+from urllib.parse import urljoinfrom w3lib.html import remove_tags, replace_entities, replace_escape_chars, get_base_urlfrom scrapy.link import Linkfrom .sgml import SgmlLinkExtractor+linkre = re.compile("<a\s.*?href=(\"[.#]+?\"|\'[.#]+?\'|[^\s]+?)(>|\s.*?>)(.*?)<[/ ]?a>",re.DOTALL | re.IGNORECASE)diff --git a/scrapy/linkextractors/sgml.py b/scrapy/linkextractors/sgml.pyindex 8940a4d77..98bed15e9 100644--- a/scrapy/linkextractors/sgml.py+++ b/scrapy/linkextractors/sgml.py@@ -1,11 +1,11 @@"""SGMLParser-based Link extractors"""-import six-from six.moves.urllib.parse import urljoinimport warnings+from urllib.parse import urljoinfrom sgmllib import SGMLParser+import sixfrom w3lib.url import safe_url_string, canonicalize_urlfrom w3lib.html import strip_html5_whitespacediff --git a/scrapy/mail.py b/scrapy/mail.pyindex d24de2212..891bb5e09 100644--- a/scrapy/mail.py+++ b/scrapy/mail.py@@ -3,21 +3,21 @@ Mail sending helpersSee documentation in docs/topics/email.rst"""-from io import BytesIOimport logging--from email.utils import COMMASPACE, formatdate-from six.moves.email_mime_multipart import MIMEMultipart-from six.moves.email_mime_text import MIMEText-from six.moves.email_mime_base import MIMEBase-from email.mime.nonmultipart import MIMENonMultipartfrom email import encoders as Encoders+from email.mime.base import MIMEBase+from email.mime.multipart import MIMEMultipart+from email.mime.nonmultipart import MIMENonMultipart+from email.mime.text import MIMEText+from email.utils import COMMASPACE, formatdate+from io import BytesIOfrom twisted.internet import defer, reactor, sslfrom scrapy.utils.misc import arg_to_iterfrom scrapy.utils.python import to_bytes+logger = logging.getLogger(__name__)diff --git a/scrapy/pipelines/files.py b/scrapy/pipelines/files.pyindex 8d74c5011..432d4c182 100644--- a/scrapy/pipelines/files.py+++ b/scrapy/pipelines/files.py@@ -5,17 +5,17 @@ See documentation in topics/media-pipeline.rst"""import functoolsimport hashlib-from io import BytesIO+import loggingimport mimetypesimport osimport os.pathimport time-import logging-from email.utils import parsedate_tz, mktime_tz-from six.moves.urllib.parse import urlparsefrom collections import defaultdict-import six+from email.utils import parsedate_tz, mktime_tz+from io import BytesIO+from urllib.parse import urlparse+import sixfrom twisted.internet import defer, threadsfrom scrapy.pipelines.media import MediaPipelinediff --git a/scrapy/robotstxt.py b/scrapy/robotstxt.pyindex 95a8c09b8..397924110 100644--- a/scrapy/robotstxt.py+++ b/scrapy/robotstxt.py@@ -53,7 +53,7 @@ class RobotParser(with_metaclass(ABCMeta)):class PythonRobotParser(RobotParser):def __init__(self, robotstxt_body, spider):- from six.moves.urllib_robotparser import RobotFileParser+ from urllib.robotparser import RobotFileParserself.spider = spiderrobotstxt_body = decode_robotstxt(robotstxt_body, spider, to_native_str_type=True)self.rp = RobotFileParser()diff --git a/scrapy/spidermiddlewares/referer.py b/scrapy/spidermiddlewares/referer.pyindex c76e4d5a2..dce2b3598 100644--- a/scrapy/spidermiddlewares/referer.py+++ b/scrapy/spidermiddlewares/referer.py@@ -2,8 +2,8 @@RefererMiddleware: populates Request referer field, based on the Response whichoriginated it."""-from six.moves.urllib.parse import urlparseimport warnings+from urllib.parse import urlparsefrom w3lib.url import safe_url_stringdiff --git a/scrapy/squeues.py b/scrapy/squeues.pyindex 30cc926e5..d5d3be67e 100644--- a/scrapy/squeues.py+++ b/scrapy/squeues.py@@ -3,7 +3,7 @@ Scheduler queues"""import marshal-from six.moves import cPickle as pickle+import picklefrom queuelib import queuediff --git a/scrapy/utils/benchserver.py b/scrapy/utils/benchserver.pyindex 5bbda6e27..cdbe21942 100644--- a/scrapy/utils/benchserver.py+++ b/scrapy/utils/benchserver.py@@ -1,5 +1,6 @@import random-from six.moves.urllib.parse import urlencode+from urllib.parse import urlencode+from twisted.web.server import Sitefrom twisted.web.resource import Resourcefrom twisted.internet import reactordiff --git a/scrapy/utils/curl.py b/scrapy/utils/curl.pyindex b3fd0a497..a0a47e473 100644--- a/scrapy/utils/curl.py+++ b/scrapy/utils/curl.py@@ -1,9 +1,9 @@import argparseimport warningsfrom shlex import split+from http.cookies import SimpleCookie+from urllib.parse import urlparse-from six.moves.http_cookies import SimpleCookie-from six.moves.urllib.parse import urlparsefrom six import string_types, iteritemsfrom w3lib.http import basic_auth_headerdiff --git a/scrapy/utils/httpobj.py b/scrapy/utils/httpobj.pyindex b4c929b0e..54ffe086d 100644--- a/scrapy/utils/httpobj.py+++ b/scrapy/utils/httpobj.py@@ -1,8 +1,8 @@"""Helper functions for scrapy.http objects (Request, Response)"""import weakref+from urllib.parse import urlparse-from six.moves.urllib.parse import urlparse_urlparse_cache = weakref.WeakKeyDictionary()def urlparse_cached(request_or_response):diff --git a/scrapy/utils/project.py b/scrapy/utils/project.pyindex 1cbda141a..f28c2eaa1 100644--- a/scrapy/utils/project.py+++ b/scrapy/utils/project.py@@ -1,5 +1,5 @@import os-from six.moves import cPickle as pickle+import pickleimport warningsfrom importlib import import_module@@ -7,8 +7,8 @@ from os.path import join, dirname, abspath, isabs, existsfrom scrapy.utils.conf import closest_scrapy_cfg, get_config, init_envfrom scrapy.settings import Settings-from scrapy.exceptions import NotConfigured-from scrapy.exceptions import ScrapyDeprecationWarning+from scrapy.exceptions import NotConfigured, ScrapyDeprecationWarning+ENVVAR = 'SCRAPY_SETTINGS_MODULE'DATADIR_CFG_SECTION = 'datadir'diff --git a/scrapy/utils/python.py b/scrapy/utils/python.pyindex 974abaeb1..cb8ac3c8e 100644--- a/scrapy/utils/python.py+++ b/scrapy/utils/python.py@@ -65,7 +65,7 @@ def is_listlike(x):True>>> is_listlike((x for x in range(3)))True- >>> is_listlike(six.moves.xrange(5))+ >>> is_listlike(range(5))True"""return hasattr(x, "__iter__") and not isinstance(x, (six.text_type, bytes))diff --git a/scrapy/utils/request.py b/scrapy/utils/request.pyindex 45f1ef17e..c5e877acd 100644--- a/scrapy/utils/request.py+++ b/scrapy/utils/request.py@@ -5,13 +5,13 @@ scrapy.http.Request objectsimport hashlibimport weakref-from six.moves.urllib.parse import urlunparse+from urllib.parse import urlunparsefrom w3lib.http import basic_auth_header-from scrapy.utils.python import to_bytes, to_unicode-from w3lib.url import canonicalize_url+from scrapy.utils.httpobj import urlparse_cached+from scrapy.utils.python import to_bytes, to_unicode_fingerprint_cache = weakref.WeakKeyDictionary()diff --git a/scrapy/utils/sitemap.py b/scrapy/utils/sitemap.pyindex 4742b3e13..2f10cf4de 100644--- a/scrapy/utils/sitemap.py+++ b/scrapy/utils/sitemap.py@@ -5,8 +5,9 @@ Note: The main purpose of this module is to provide support for theSitemapSpider, its API is subject to change without notice."""+from urllib.parse import urljoin+import lxml.etree-from six.moves.urllib.parse import urljoinclass Sitemap(object):diff --git a/scrapy/utils/testsite.py b/scrapy/utils/testsite.pyindex 05d06d53b..6f5c21624 100644--- a/scrapy/utils/testsite.py+++ b/scrapy/utils/testsite.py@@ -1,4 +1,4 @@-from six.moves.urllib.parse import urljoin+from urllib.parse import urljoinfrom twisted.internet import reactorfrom twisted.web import server, resource, static, utildiff --git a/scrapy/utils/url.py b/scrapy/utils/url.pyindex b3a4be007..4b48868fe 100644--- a/scrapy/utils/url.py+++ b/scrapy/utils/url.py@@ -7,7 +7,7 @@ to the w3lib.url module. Always import those from there instead."""import posixpathimport re-from six.moves.urllib.parse import (ParseResult, urldefrag, urlparse, urlunparse)+from urllib.parse import ParseResult, urldefrag, urlparse, urlunparse# scrapy.utils.url was moved to w3lib.url and import * ensures this# move doesn't break old code