Scrapy, a fast high-level web crawling & scraping framework for Python.
Move scrapy/contrib remaining top-level files to scrapy/extensions
Julia Medina9a3e3ba50536
diff --git a/docs/topics/downloader-middleware.rst b/docs/topics/downloader-middleware.rstindex bb969eca3..5cb6c9824 100644--- a/docs/topics/downloader-middleware.rst+++ b/docs/topics/downloader-middleware.rst@@ -349,7 +349,7 @@ when an Internet connection is not available. The goal is to be able toIn order to use this policy, set:-* :setting:`HTTPCACHE_POLICY` to ``scrapy.contrib.httpcache.DummyPolicy``+* :setting:`HTTPCACHE_POLICY` to ``scrapy.extensions.httpcache.DummyPolicy``.. _httpcache-policy-rfc2616:@@ -383,7 +383,7 @@ what is missing:In order to use this policy, set:-* :setting:`HTTPCACHE_POLICY` to ``scrapy.contrib.httpcache.RFC2616Policy``+* :setting:`HTTPCACHE_POLICY` to ``scrapy.extensions.httpcache.RFC2616Policy``.. _httpcache-storage-fs:@@ -395,7 +395,7 @@ File system storage backend is available for the HTTP cache middleware.In order to use this storage backend, set:-* :setting:`HTTPCACHE_STORAGE` to ``scrapy.contrib.httpcache.FilesystemCacheStorage``+* :setting:`HTTPCACHE_STORAGE` to ``scrapy.extensions.httpcache.FilesystemCacheStorage``Each request/response pair is stored in a different directory containingthe following files:@@ -430,7 +430,7 @@ By default, it uses the anydbm_ module, but you can change it with theIn order to use this storage backend, set:-* :setting:`HTTPCACHE_STORAGE` to ``scrapy.contrib.httpcache.DbmCacheStorage``+* :setting:`HTTPCACHE_STORAGE` to ``scrapy.extensions.httpcache.DbmCacheStorage``.. _httpcache-storage-leveldb:@@ -447,7 +447,7 @@ the scrapy shell in parallel for the same spider.In order to use this storage backend:-* set :setting:`HTTPCACHE_STORAGE` to ``scrapy.contrib.httpcache.LeveldbCacheStorage``+* set :setting:`HTTPCACHE_STORAGE` to ``scrapy.extensions.httpcache.LeveldbCacheStorage``* install `LevelDB python bindings`_ like ``pip install leveldb``.. _LevelDB: http://code.google.com/p/leveldb/@@ -536,7 +536,7 @@ Don't cache responses with these URI schemes.HTTPCACHE_STORAGE^^^^^^^^^^^^^^^^^-Default: ``'scrapy.contrib.httpcache.FilesystemCacheStorage'``+Default: ``'scrapy.extensions.httpcache.FilesystemCacheStorage'``The class which implements the cache storage backend.@@ -559,7 +559,7 @@ HTTPCACHE_POLICY.. versionadded:: 0.18-Default: ``'scrapy.contrib.httpcache.DummyPolicy'``+Default: ``'scrapy.extensions.httpcache.DummyPolicy'``The class which implements the cache policy.diff --git a/docs/topics/extensions.rst b/docs/topics/extensions.rstindex 19c296651..d5d985087 100644--- a/docs/topics/extensions.rst+++ b/docs/topics/extensions.rst@@ -35,7 +35,7 @@ your Scrapy settings. In :setting:`EXTENSIONS`, each extension is representedby a string: the full Python path to the extension's class name. For example::EXTENSIONS = {- 'scrapy.contrib.corestats.CoreStats': 500,+ 'scrapy.extensions.corestats.CoreStats': 500,'scrapy.telnet.TelnetConsole': 500,}@@ -69,7 +69,7 @@ included in the :setting:`EXTENSIONS_BASE` setting) you must set its order to``None``. For example::EXTENSIONS = {- 'scrapy.contrib.corestats.CoreStats': None,+ 'scrapy.extensions.corestats.CoreStats': None,}Writing your own extension@@ -158,7 +158,7 @@ General purpose extensionsLog Stats extension~~~~~~~~~~~~~~~~~~~-.. module:: scrapy.contrib.logstats+.. module:: scrapy.extensions.logstats:synopsis: Basic stats logging.. class:: LogStats@@ -168,7 +168,7 @@ Log basic stats like crawled pages and scraped items.Core Stats extension~~~~~~~~~~~~~~~~~~~~-.. module:: scrapy.contrib.corestats+.. module:: scrapy.extensions.corestats:synopsis: Core stats collection.. class:: CoreStats@@ -198,10 +198,10 @@ setting, and the server will listen in the port specified inMemory usage extension~~~~~~~~~~~~~~~~~~~~~~-.. module:: scrapy.contrib.memusage+.. module:: scrapy.extensions.memusage:synopsis: Memory usage extension-.. class:: scrapy.contrib.memusage.MemoryUsage+.. class:: scrapy.extensions.memusage.MemoryUsage.. note:: This extension does not work in Windows.@@ -226,10 +226,10 @@ can be configured with the following settings:Memory debugger extension~~~~~~~~~~~~~~~~~~~~~~~~~-.. module:: scrapy.contrib.memdebug+.. module:: scrapy.extensions.memdebug:synopsis: Memory debugger extension-.. class:: scrapy.contrib.memdebug.MemoryDebugger+.. class:: scrapy.extensions.memdebug.MemoryDebuggerAn extension for debugging memory usage. It collects information about:@@ -242,10 +242,10 @@ info will be stored in the stats.Close spider extension~~~~~~~~~~~~~~~~~~~~~~-.. module:: scrapy.contrib.closespider+.. module:: scrapy.extensions.closespider:synopsis: Close spider extension-.. class:: scrapy.contrib.closespider.CloseSpider+.. class:: scrapy.extensions.closespider.CloseSpiderCloses a spider automatically when some conditions are met, using a specificclosing reason for each condition.@@ -313,17 +313,17 @@ set), spiders won't be closed by number of errors.StatsMailer extension~~~~~~~~~~~~~~~~~~~~~-.. module:: scrapy.contrib.statsmailer+.. module:: scrapy.extensions.statsmailer:synopsis: StatsMailer extension-.. class:: scrapy.contrib.statsmailer.StatsMailer+.. class:: scrapy.extensions.statsmailer.StatsMailerThis simple extension can be used to send a notification e-mail every time adomain has finished scraping, including the Scrapy stats collected. The emailwill be sent to all recipients specified in the :setting:`STATSMAILER_RCPTS`setting.-.. module:: scrapy.contrib.debug+.. module:: scrapy.extensions.debug:synopsis: Extensions for debugging ScrapyDebugging extensions@@ -332,7 +332,7 @@ Debugging extensionsStack trace dump extension~~~~~~~~~~~~~~~~~~~~~~~~~~-.. class:: scrapy.contrib.debug.StackTraceDump+.. class:: scrapy.extensions.debug.StackTraceDumpDumps information about the running process when a `SIGQUIT`_ or `SIGUSR2`_signal is received. The information dumped is the following:@@ -361,7 +361,7 @@ There are at least two ways to send Scrapy the `SIGQUIT`_ signal:Debugger extension~~~~~~~~~~~~~~~~~~-.. class:: scrapy.contrib.debug.Debugger+.. class:: scrapy.extensions.debug.DebuggerInvokes a `Python debugger`_ inside a running Scrapy process when a `SIGUSR2`_signal is received. After the debugger is exited, the Scrapy process continuesdiff --git a/docs/topics/feed-exports.rst b/docs/topics/feed-exports.rstindex 27d601a19..faf9abc1c 100644--- a/docs/topics/feed-exports.rst+++ b/docs/topics/feed-exports.rst@@ -209,7 +209,7 @@ These are the settings used for configuring the feed exports:* :setting:`FEED_STORE_EMPTY`* :setting:`FEED_EXPORT_FIELDS`-.. currentmodule:: scrapy.contrib.feedexport+.. currentmodule:: scrapy.extensions.feedexport.. setting:: FEED_URI@@ -272,11 +272,11 @@ FEED_STORAGES_BASEDefault::{- '': 'scrapy.contrib.feedexport.FileFeedStorage',- 'file': 'scrapy.contrib.feedexport.FileFeedStorage',- 'stdout': 'scrapy.contrib.feedexport.StdoutFeedStorage',- 's3': 'scrapy.contrib.feedexport.S3FeedStorage',- 'ftp': 'scrapy.contrib.feedexport.FTPFeedStorage',+ '': 'scrapy.extensions.feedexport.FileFeedStorage',+ 'file': 'scrapy.extensions.feedexport.FileFeedStorage',+ 'stdout': 'scrapy.extensions.feedexport.StdoutFeedStorage',+ 's3': 'scrapy.extensions.feedexport.S3FeedStorage',+ 'ftp': 'scrapy.extensions.feedexport.FTPFeedStorage',}A dict containing the built-in feed storage backends supported by Scrapy.diff --git a/docs/topics/settings.rst b/docs/topics/settings.rstindex a049f1438..f331b1dba 100644--- a/docs/topics/settings.rst+++ b/docs/topics/settings.rst@@ -536,15 +536,15 @@ EXTENSIONS_BASEDefault::{- 'scrapy.contrib.corestats.CoreStats': 0,+ 'scrapy.extensions.corestats.CoreStats': 0,'scrapy.telnet.TelnetConsole': 0,- 'scrapy.contrib.memusage.MemoryUsage': 0,- 'scrapy.contrib.memdebug.MemoryDebugger': 0,- 'scrapy.contrib.closespider.CloseSpider': 0,- 'scrapy.contrib.feedexport.FeedExporter': 0,- 'scrapy.contrib.logstats.LogStats': 0,- 'scrapy.contrib.spiderstate.SpiderState': 0,- 'scrapy.contrib.throttle.AutoThrottle': 0,+ 'scrapy.extensions.memusage.MemoryUsage': 0,+ 'scrapy.extensions.memdebug.MemoryDebugger': 0,+ 'scrapy.extensions.closespider.CloseSpider': 0,+ 'scrapy.extensions.feedexport.FeedExporter': 0,+ 'scrapy.extensions.logstats.LogStats': 0,+ 'scrapy.extensions.spiderstate.SpiderState': 0,+ 'scrapy.extensions.throttle.AutoThrottle': 0,}The list of available extensions. Keep in mind that some of them need to@@ -689,7 +689,7 @@ MEMUSAGE_ENABLEDDefault: ``False``-Scope: ``scrapy.contrib.memusage``+Scope: ``scrapy.extensions.memusage``Whether to enable the memory usage extension that will shutdown the Scrapyprocess when it exceeds a memory limit, and also notify by email when that@@ -704,7 +704,7 @@ MEMUSAGE_LIMIT_MBDefault: ``0``-Scope: ``scrapy.contrib.memusage``+Scope: ``scrapy.extensions.memusage``The maximum amount of memory to allow (in megabytes) before shutting downScrapy (if MEMUSAGE_ENABLED is True). If zero, no check will be performed.@@ -718,7 +718,7 @@ MEMUSAGE_NOTIFY_MAILDefault: ``False``-Scope: ``scrapy.contrib.memusage``+Scope: ``scrapy.extensions.memusage``A list of emails to notify if the memory limit has been reached.@@ -735,7 +735,7 @@ MEMUSAGE_REPORTDefault: ``False``-Scope: ``scrapy.contrib.memusage``+Scope: ``scrapy.extensions.memusage``Whether to send a memory usage report after each spider has been closed.@@ -748,7 +748,7 @@ MEMUSAGE_WARNING_MBDefault: ``0``-Scope: ``scrapy.contrib.memusage``+Scope: ``scrapy.extensions.memusage``The maximum amount of memory to allow (in megabytes) before sending a warningemail notifying about it. If zero, no warning will be produced.@@ -961,7 +961,7 @@ STATSMAILER_RCPTSDefault: ``[]`` (empty list)Send Scrapy stats after spiders finish scraping. See-:class:`~scrapy.contrib.statsmailer.StatsMailer` for more info.+:class:`~scrapy.extensions.statsmailer.StatsMailer` for more info... setting:: TELNETCONSOLE_ENABLEDdiff --git a/scrapy/downloadermiddlewares/httpcache.py b/scrapy/downloadermiddlewares/httpcache.pyindex 7b4b53f7c..bd112c48d 100644--- a/scrapy/downloadermiddlewares/httpcache.py+++ b/scrapy/downloadermiddlewares/httpcache.py@@ -90,16 +90,3 @@ class HttpCacheMiddleware(object):self.storage.store_response(spider, request, response)else:self.stats.inc_value('httpcache/uncacheable', spider=spider)---from scrapy.contrib.httpcache import FilesystemCacheStorage as _FilesystemCacheStorage-class FilesystemCacheStorage(_FilesystemCacheStorage):-- def __init__(self, *args, **kwargs):- import warnings- from scrapy.exceptions import ScrapyDeprecationWarning- warnings.warn('Importing FilesystemCacheStorage from '- 'scrapy.contrib.downloadermiddlware.httpcache is '- 'deprecated, use scrapy.contrib.httpcache instead.',- category=ScrapyDeprecationWarning, stacklevel=1)- super(FilesystemCacheStorage, self).__init__(*args, **kwargs)diff --git a/scrapy/extensions/__init__.py b/scrapy/extensions/__init__.pynew file mode 100644index 000000000..e69de29bbdiff --git a/scrapy/contrib/closespider.py b/scrapy/extensions/closespider.pysimilarity index 100%rename from scrapy/contrib/closespider.pyrename to scrapy/extensions/closespider.pydiff --git a/scrapy/contrib/corestats.py b/scrapy/extensions/corestats.pysimilarity index 100%rename from scrapy/contrib/corestats.pyrename to scrapy/extensions/corestats.pydiff --git a/scrapy/contrib/debug.py b/scrapy/extensions/debug.pysimilarity index 100%rename from scrapy/contrib/debug.pyrename to scrapy/extensions/debug.pydiff --git a/scrapy/contrib/feedexport.py b/scrapy/extensions/feedexport.pysimilarity index 100%rename from scrapy/contrib/feedexport.pyrename to scrapy/extensions/feedexport.pydiff --git a/scrapy/contrib/httpcache.py b/scrapy/extensions/httpcache.pysimilarity index 100%rename from scrapy/contrib/httpcache.pyrename to scrapy/extensions/httpcache.pydiff --git a/scrapy/contrib/logstats.py b/scrapy/extensions/logstats.pysimilarity index 100%rename from scrapy/contrib/logstats.pyrename to scrapy/extensions/logstats.pydiff --git a/scrapy/contrib/memdebug.py b/scrapy/extensions/memdebug.pysimilarity index 100%rename from scrapy/contrib/memdebug.pyrename to scrapy/extensions/memdebug.pydiff --git a/scrapy/contrib/memusage.py b/scrapy/extensions/memusage.pysimilarity index 100%rename from scrapy/contrib/memusage.pyrename to scrapy/extensions/memusage.pydiff --git a/scrapy/contrib/spiderstate.py b/scrapy/extensions/spiderstate.pysimilarity index 100%rename from scrapy/contrib/spiderstate.pyrename to scrapy/extensions/spiderstate.pydiff --git a/scrapy/contrib/statsmailer.py b/scrapy/extensions/statsmailer.pysimilarity index 100%rename from scrapy/contrib/statsmailer.pyrename to scrapy/extensions/statsmailer.pydiff --git a/scrapy/contrib/throttle.py b/scrapy/extensions/throttle.pysimilarity index 100%rename from scrapy/contrib/throttle.pyrename to scrapy/extensions/throttle.pydiff --git a/scrapy/settings/default_settings.py b/scrapy/settings/default_settings.pyindex a7fe36648..9debaabc3 100644--- a/scrapy/settings/default_settings.py+++ b/scrapy/settings/default_settings.py@@ -113,15 +113,15 @@ except KeyError:EXTENSIONS = {}EXTENSIONS_BASE = {- 'scrapy.contrib.corestats.CoreStats': 0,+ 'scrapy.extensions.corestats.CoreStats': 0,'scrapy.telnet.TelnetConsole': 0,- 'scrapy.contrib.memusage.MemoryUsage': 0,- 'scrapy.contrib.memdebug.MemoryDebugger': 0,- 'scrapy.contrib.closespider.CloseSpider': 0,- 'scrapy.contrib.feedexport.FeedExporter': 0,- 'scrapy.contrib.logstats.LogStats': 0,- 'scrapy.contrib.spiderstate.SpiderState': 0,- 'scrapy.contrib.throttle.AutoThrottle': 0,+ 'scrapy.extensions.memusage.MemoryUsage': 0,+ 'scrapy.extensions.memdebug.MemoryDebugger': 0,+ 'scrapy.extensions.closespider.CloseSpider': 0,+ 'scrapy.extensions.feedexport.FeedExporter': 0,+ 'scrapy.extensions.logstats.LogStats': 0,+ 'scrapy.extensions.spiderstate.SpiderState': 0,+ 'scrapy.extensions.throttle.AutoThrottle': 0,}FEED_URI = None@@ -131,11 +131,11 @@ FEED_STORE_EMPTY = FalseFEED_EXPORT_FIELDS = NoneFEED_STORAGES = {}FEED_STORAGES_BASE = {- '': 'scrapy.contrib.feedexport.FileFeedStorage',- 'file': 'scrapy.contrib.feedexport.FileFeedStorage',- 'stdout': 'scrapy.contrib.feedexport.StdoutFeedStorage',- 's3': 'scrapy.contrib.feedexport.S3FeedStorage',- 'ftp': 'scrapy.contrib.feedexport.FTPFeedStorage',+ '': 'scrapy.extensions.feedexport.FileFeedStorage',+ 'file': 'scrapy.extensions.feedexport.FileFeedStorage',+ 'stdout': 'scrapy.extensions.feedexport.StdoutFeedStorage',+ 's3': 'scrapy.extensions.feedexport.S3FeedStorage',+ 'ftp': 'scrapy.extensions.feedexport.FTPFeedStorage',}FEED_EXPORTERS = {}FEED_EXPORTERS_BASE = {@@ -151,12 +151,12 @@ FEED_EXPORTERS_BASE = {HTTPCACHE_ENABLED = FalseHTTPCACHE_DIR = 'httpcache'HTTPCACHE_IGNORE_MISSING = False-HTTPCACHE_STORAGE = 'scrapy.contrib.httpcache.FilesystemCacheStorage'+HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'HTTPCACHE_EXPIRATION_SECS = 0HTTPCACHE_IGNORE_HTTP_CODES = []HTTPCACHE_IGNORE_SCHEMES = ['file']HTTPCACHE_DBM_MODULE = 'anydbm'-HTTPCACHE_POLICY = 'scrapy.contrib.httpcache.DummyPolicy'+HTTPCACHE_POLICY = 'scrapy.extensions.httpcache.DummyPolicy'HTTPCACHE_GZIP = FalseITEM_PROCESSOR = 'scrapy.pipelines.ItemPipelineManager'diff --git a/scrapy/templates/project/module/settings.py.tmpl b/scrapy/templates/project/module/settings.py.tmplindex 37cbb4d32..11ff804ba 100644--- a/scrapy/templates/project/module/settings.py.tmpl+++ b/scrapy/templates/project/module/settings.py.tmpl@@ -82,4 +82,4 @@ NEWSPIDER_MODULE = '$project_name.spiders'#HTTPCACHE_EXPIRATION_SECS=0#HTTPCACHE_DIR='httpcache'#HTTPCACHE_IGNORE_HTTP_CODES=[]-#HTTPCACHE_STORAGE='scrapy.contrib.httpcache.FilesystemCacheStorage'+#HTTPCACHE_STORAGE='scrapy.extensions.httpcache.FilesystemCacheStorage'diff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txtindex a29b419b0..3d87bcb9a 100644--- a/tests/py3-ignores.txt+++ b/tests/py3-ignores.txt@@ -100,7 +100,9 @@ scrapy/downloadermiddlewares/retry.pyscrapy/downloadermiddlewares/httpproxy.pyscrapy/downloadermiddlewares/cookies.pyscrapy/contrib/statsmailer.py+scrapy/extensions/statsmailer.pyscrapy/contrib/memusage.py+scrapy/extensions/memusage.pyscrapy/commands/deploy.pyscrapy/commands/bench.pyscrapy/mail.pydiff --git a/tests/test_downloadermiddleware_httpcache.py b/tests/test_downloadermiddleware_httpcache.pyindex 9c1678488..ac954cc15 100644--- a/tests/test_downloadermiddleware_httpcache.py+++ b/tests/test_downloadermiddleware_httpcache.py@@ -17,8 +17,8 @@ from scrapy.downloadermiddlewares.httpcache import HttpCacheMiddlewareclass _BaseTest(unittest.TestCase):- storage_class = 'scrapy.contrib.httpcache.DbmCacheStorage'- policy_class = 'scrapy.contrib.httpcache.RFC2616Policy'+ storage_class = 'scrapy.extensions.httpcache.DbmCacheStorage'+ policy_class = 'scrapy.extensions.httpcache.RFC2616Policy'def setUp(self):self.yesterday = email.utils.formatdate(time.time() - 86400)@@ -127,7 +127,7 @@ class DefaultStorageTest(_BaseTest):class DbmStorageTest(DefaultStorageTest):- storage_class = 'scrapy.contrib.httpcache.DbmCacheStorage'+ storage_class = 'scrapy.extensions.httpcache.DbmCacheStorage'class DbmStorageWithCustomDbmModuleTest(DbmStorageTest):@@ -146,7 +146,7 @@ class DbmStorageWithCustomDbmModuleTest(DbmStorageTest):class FilesystemStorageTest(DefaultStorageTest):- storage_class = 'scrapy.contrib.httpcache.FilesystemCacheStorage'+ storage_class = 'scrapy.extensions.httpcache.FilesystemCacheStorage'class FilesystemStorageGzipTest(FilesystemStorageTest):@@ -157,12 +157,12 @@ class FilesystemStorageGzipTest(FilesystemStorageTest):class LeveldbStorageTest(DefaultStorageTest):pytest.importorskip('leveldb')- storage_class = 'scrapy.contrib.httpcache.LeveldbCacheStorage'+ storage_class = 'scrapy.extensions.httpcache.LeveldbCacheStorage'class DummyPolicyTest(_BaseTest):- policy_class = 'scrapy.contrib.httpcache.DummyPolicy'+ policy_class = 'scrapy.extensions.httpcache.DummyPolicy'def test_middleware(self):with self._middleware() as mw:@@ -254,7 +254,7 @@ class DummyPolicyTest(_BaseTest):class RFC2616PolicyTest(DefaultStorageTest):- policy_class = 'scrapy.contrib.httpcache.RFC2616Policy'+ policy_class = 'scrapy.extensions.httpcache.RFC2616Policy'def _process_requestresponse(self, mw, request, response):try:diff --git a/tests/test_contrib_feedexport.py b/tests/test_feedexport.pysimilarity index 99%rename from tests/test_contrib_feedexport.pyrename to tests/test_feedexport.pyindex e6fd38ee3..41913e401 100644--- a/tests/test_contrib_feedexport.py+++ b/tests/test_feedexport.py@@ -16,7 +16,7 @@ from tests.mockserver import MockServerfrom w3lib.url import path_to_file_uriimport scrapy-from scrapy.contrib.feedexport import (+from scrapy.extensions.feedexport import (IFeedStorage, FileFeedStorage, FTPFeedStorage,S3FeedStorage, StdoutFeedStorage)diff --git a/tests/test_contrib_spiderstate.py b/tests/test_spiderstate.pysimilarity index 94%rename from tests/test_contrib_spiderstate.pyrename to tests/test_spiderstate.pyindex 8e5897db7..1ddce4b99 100644--- a/tests/test_contrib_spiderstate.py+++ b/tests/test_spiderstate.py@@ -2,7 +2,7 @@ import osfrom datetime import datetimefrom twisted.trial import unittest-from scrapy.contrib.spiderstate import SpiderState+from scrapy.extensions.spiderstate import SpiderStatefrom scrapy.spider import Spider