Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

mv scrapy/trunk to root as part of svn2hg migration

Daniel Granaba69c29e37cf
diff --git a/scrapy/trunk/AUTHORS b/AUTHORS
similarity index 100%
rename from scrapy/trunk/AUTHORS
rename to AUTHORS
diff --git a/scrapy/trunk/INSTALL b/INSTALL
similarity index 100%
rename from scrapy/trunk/INSTALL
rename to INSTALL
diff --git a/scrapy/trunk/LICENSE b/LICENSE
similarity index 100%
rename from scrapy/trunk/LICENSE
rename to LICENSE
diff --git a/scrapy/branches/cluster-refactor/README b/README
similarity index 100%
rename from scrapy/branches/cluster-refactor/README
rename to README
diff --git a/scrapy/trunk/bin/runtests.sh b/bin/runtests.sh
similarity index 100%
rename from scrapy/trunk/bin/runtests.sh
rename to bin/runtests.sh
diff --git a/scrapy/trunk/docs/Makefile b/docs/Makefile
similarity index 100%
rename from scrapy/trunk/docs/Makefile
rename to docs/Makefile
diff --git a/scrapy/trunk/docs/README b/docs/README
similarity index 100%
rename from scrapy/trunk/docs/README
rename to docs/README
diff --git a/scrapy/trunk/docs/_ext/scrapydocs.py b/docs/_ext/scrapydocs.py
similarity index 100%
rename from scrapy/trunk/docs/_ext/scrapydocs.py
rename to docs/_ext/scrapydocs.py
diff --git a/scrapy/trunk/docs/_static/items_adaptors-sample1.html b/docs/_static/items_adaptors-sample1.html
similarity index 100%
rename from scrapy/trunk/docs/_static/items_adaptors-sample1.html
rename to docs/_static/items_adaptors-sample1.html
diff --git a/scrapy/trunk/docs/_static/scrapydoc.css b/docs/_static/scrapydoc.css
similarity index 100%
rename from scrapy/trunk/docs/_static/scrapydoc.css
rename to docs/_static/scrapydoc.css
diff --git a/scrapy/trunk/docs/_static/selectors-sample1.html b/docs/_static/selectors-sample1.html
similarity index 100%
rename from scrapy/trunk/docs/_static/selectors-sample1.html
rename to docs/_static/selectors-sample1.html
diff --git a/scrapy/trunk/docs/conf.py b/docs/conf.py
similarity index 100%
rename from scrapy/trunk/docs/conf.py
rename to docs/conf.py
diff --git a/scrapy/trunk/docs/faq.rst b/docs/faq.rst
similarity index 100%
rename from scrapy/trunk/docs/faq.rst
rename to docs/faq.rst
diff --git a/scrapy/trunk/docs/index.rst b/docs/index.rst
similarity index 100%
rename from scrapy/trunk/docs/index.rst
rename to docs/index.rst
diff --git a/scrapy/trunk/docs/intro/index.rst b/docs/intro/index.rst
similarity index 100%
rename from scrapy/trunk/docs/intro/index.rst
rename to docs/intro/index.rst
diff --git a/scrapy/trunk/docs/intro/install.rst b/docs/intro/install.rst
similarity index 100%
rename from scrapy/trunk/docs/intro/install.rst
rename to docs/intro/install.rst
diff --git a/scrapy/trunk/docs/intro/overview.rst b/docs/intro/overview.rst
similarity index 100%
rename from scrapy/trunk/docs/intro/overview.rst
rename to docs/intro/overview.rst
diff --git a/scrapy/trunk/docs/intro/tutorial.rst b/docs/intro/tutorial.rst
similarity index 100%
rename from scrapy/trunk/docs/intro/tutorial.rst
rename to docs/intro/tutorial.rst
diff --git a/scrapy/branches/cluster-refactor/docs/scrapy-architecture.dia b/docs/media/scrapy-architecture.dia
similarity index 100%
rename from scrapy/branches/cluster-refactor/docs/scrapy-architecture.dia
rename to docs/media/scrapy-architecture.dia
diff --git a/scrapy/trunk/docs/misc/api-stability.rst b/docs/misc/api-stability.rst
similarity index 100%
rename from scrapy/trunk/docs/misc/api-stability.rst
rename to docs/misc/api-stability.rst
diff --git a/scrapy/trunk/docs/misc/index.rst b/docs/misc/index.rst
similarity index 100%
rename from scrapy/trunk/docs/misc/index.rst
rename to docs/misc/index.rst
diff --git a/scrapy/trunk/docs/proposed/_images/scrapy_architecture.odg b/docs/proposed/_images/scrapy_architecture.odg
similarity index 100%
rename from scrapy/trunk/docs/proposed/_images/scrapy_architecture.odg
rename to docs/proposed/_images/scrapy_architecture.odg
diff --git a/scrapy/trunk/docs/proposed/_images/scrapy_architecture.png b/docs/proposed/_images/scrapy_architecture.png
similarity index 100%
rename from scrapy/trunk/docs/proposed/_images/scrapy_architecture.png
rename to docs/proposed/_images/scrapy_architecture.png
diff --git a/scrapy/trunk/docs/proposed/index.rst b/docs/proposed/index.rst
similarity index 100%
rename from scrapy/trunk/docs/proposed/index.rst
rename to docs/proposed/index.rst
diff --git a/scrapy/trunk/docs/proposed/introduction.rst b/docs/proposed/introduction.rst
similarity index 100%
rename from scrapy/trunk/docs/proposed/introduction.rst
rename to docs/proposed/introduction.rst
diff --git a/scrapy/trunk/docs/proposed/newitem.rst b/docs/proposed/newitem.rst
similarity index 100%
rename from scrapy/trunk/docs/proposed/newitem.rst
rename to docs/proposed/newitem.rst
diff --git a/scrapy/trunk/docs/proposed/spiders.rst b/docs/proposed/spiders.rst
similarity index 100%
rename from scrapy/trunk/docs/proposed/spiders.rst
rename to docs/proposed/spiders.rst
diff --git a/scrapy/trunk/docs/ref/downloader-middleware.rst b/docs/ref/downloader-middleware.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/downloader-middleware.rst
rename to docs/ref/downloader-middleware.rst
diff --git a/scrapy/trunk/docs/ref/email.rst b/docs/ref/email.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/email.rst
rename to docs/ref/email.rst
diff --git a/scrapy/trunk/docs/ref/exceptions.rst b/docs/ref/exceptions.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/exceptions.rst
rename to docs/ref/exceptions.rst
diff --git a/scrapy/trunk/docs/ref/extension-manager.rst b/docs/ref/extension-manager.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/extension-manager.rst
rename to docs/ref/extension-manager.rst
diff --git a/scrapy/trunk/docs/ref/extensions.rst b/docs/ref/extensions.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/extensions.rst
rename to docs/ref/extensions.rst
diff --git a/scrapy/trunk/docs/ref/index.rst b/docs/ref/index.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/index.rst
rename to docs/ref/index.rst
diff --git a/scrapy/trunk/docs/ref/link-extractors.rst b/docs/ref/link-extractors.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/link-extractors.rst
rename to docs/ref/link-extractors.rst
diff --git a/scrapy/trunk/docs/ref/logging.rst b/docs/ref/logging.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/logging.rst
rename to docs/ref/logging.rst
diff --git a/scrapy/trunk/docs/ref/request-response.rst b/docs/ref/request-response.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/request-response.rst
rename to docs/ref/request-response.rst
diff --git a/scrapy/trunk/docs/ref/selectors.rst b/docs/ref/selectors.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/selectors.rst
rename to docs/ref/selectors.rst
diff --git a/scrapy/trunk/docs/ref/settings.rst b/docs/ref/settings.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/settings.rst
rename to docs/ref/settings.rst
diff --git a/scrapy/trunk/docs/ref/signals.rst b/docs/ref/signals.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/signals.rst
rename to docs/ref/signals.rst
diff --git a/scrapy/trunk/docs/ref/spiders.rst b/docs/ref/spiders.rst
similarity index 100%
rename from scrapy/trunk/docs/ref/spiders.rst
rename to docs/ref/spiders.rst
diff --git a/scrapy/trunk/docs/topics/_images/adaptors_diagram.png b/docs/topics/_images/adaptors_diagram.png
similarity index 100%
rename from scrapy/trunk/docs/topics/_images/adaptors_diagram.png
rename to docs/topics/_images/adaptors_diagram.png
diff --git a/scrapy/trunk/docs/topics/_images/adaptors_diagram.svg b/docs/topics/_images/adaptors_diagram.svg
similarity index 100%
rename from scrapy/trunk/docs/topics/_images/adaptors_diagram.svg
rename to docs/topics/_images/adaptors_diagram.svg
diff --git a/scrapy/trunk/docs/topics/_images/firebug1.png b/docs/topics/_images/firebug1.png
similarity index 100%
rename from scrapy/trunk/docs/topics/_images/firebug1.png
rename to docs/topics/_images/firebug1.png
diff --git a/scrapy/trunk/docs/topics/_images/firebug2.png b/docs/topics/_images/firebug2.png
similarity index 100%
rename from scrapy/trunk/docs/topics/_images/firebug2.png
rename to docs/topics/_images/firebug2.png
diff --git a/scrapy/trunk/docs/topics/_images/firebug3.png b/docs/topics/_images/firebug3.png
similarity index 100%
rename from scrapy/trunk/docs/topics/_images/firebug3.png
rename to docs/topics/_images/firebug3.png
diff --git a/scrapy/trunk/docs/topics/_images/scrapy_architecture.odg b/docs/topics/_images/scrapy_architecture.odg
similarity index 100%
rename from scrapy/trunk/docs/topics/_images/scrapy_architecture.odg
rename to docs/topics/_images/scrapy_architecture.odg
diff --git a/scrapy/trunk/docs/topics/_images/scrapy_architecture.png b/docs/topics/_images/scrapy_architecture.png
similarity index 100%
rename from scrapy/trunk/docs/topics/_images/scrapy_architecture.png
rename to docs/topics/_images/scrapy_architecture.png
diff --git a/scrapy/trunk/docs/topics/adaptors.rst b/docs/topics/adaptors.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/adaptors.rst
rename to docs/topics/adaptors.rst
diff --git a/scrapy/trunk/docs/topics/architecture.rst b/docs/topics/architecture.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/architecture.rst
rename to docs/topics/architecture.rst
diff --git a/scrapy/trunk/docs/topics/downloader-middleware.rst b/docs/topics/downloader-middleware.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/downloader-middleware.rst
rename to docs/topics/downloader-middleware.rst
diff --git a/scrapy/trunk/docs/topics/extensions.rst b/docs/topics/extensions.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/extensions.rst
rename to docs/topics/extensions.rst
diff --git a/scrapy/trunk/docs/topics/firebug.rst b/docs/topics/firebug.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/firebug.rst
rename to docs/topics/firebug.rst
diff --git a/scrapy/trunk/docs/topics/firefox.rst b/docs/topics/firefox.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/firefox.rst
rename to docs/topics/firefox.rst
diff --git a/scrapy/trunk/docs/topics/index.rst b/docs/topics/index.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/index.rst
rename to docs/topics/index.rst
diff --git a/scrapy/trunk/docs/topics/item-pipeline.rst b/docs/topics/item-pipeline.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/item-pipeline.rst
rename to docs/topics/item-pipeline.rst
diff --git a/scrapy/trunk/docs/topics/items.rst b/docs/topics/items.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/items.rst
rename to docs/topics/items.rst
diff --git a/scrapy/trunk/docs/topics/link-extractors.rst b/docs/topics/link-extractors.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/link-extractors.rst
rename to docs/topics/link-extractors.rst
diff --git a/scrapy/trunk/docs/topics/robotstxt.rst b/docs/topics/robotstxt.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/robotstxt.rst
rename to docs/topics/robotstxt.rst
diff --git a/scrapy/trunk/docs/topics/selectors.rst b/docs/topics/selectors.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/selectors.rst
rename to docs/topics/selectors.rst
diff --git a/scrapy/trunk/docs/topics/settings.rst b/docs/topics/settings.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/settings.rst
rename to docs/topics/settings.rst
diff --git a/scrapy/trunk/docs/topics/shell.rst b/docs/topics/shell.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/shell.rst
rename to docs/topics/shell.rst
diff --git a/scrapy/trunk/docs/topics/spider-middleware.rst b/docs/topics/spider-middleware.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/spider-middleware.rst
rename to docs/topics/spider-middleware.rst
diff --git a/scrapy/trunk/docs/topics/spiders.rst b/docs/topics/spiders.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/spiders.rst
rename to docs/topics/spiders.rst
diff --git a/scrapy/trunk/docs/topics/stats.rst b/docs/topics/stats.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/stats.rst
rename to docs/topics/stats.rst
diff --git a/scrapy/trunk/docs/topics/webconsole.rst b/docs/topics/webconsole.rst
similarity index 100%
rename from scrapy/trunk/docs/topics/webconsole.rst
rename to docs/topics/webconsole.rst
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/__init__.py b/examples/experimental/googledir/googledir/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/command/commands/__init__.py
rename to examples/experimental/googledir/googledir/__init__.py
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/items.py b/examples/experimental/googledir/googledir/items.py
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/items.py
rename to examples/experimental/googledir/googledir/items.py
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/pipelines.py b/examples/experimental/googledir/googledir/pipelines.py
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/pipelines.py
rename to examples/experimental/googledir/googledir/pipelines.py
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/settings.py b/examples/experimental/googledir/googledir/settings.py
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/settings.py
rename to examples/experimental/googledir/googledir/settings.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/__init__.py b/examples/experimental/googledir/googledir/spiders/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/__init__.py
rename to examples/experimental/googledir/googledir/spiders/__init__.py
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/spiders/google_directory.py b/examples/experimental/googledir/googledir/spiders/google_directory.py
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/spiders/google_directory.py
rename to examples/experimental/googledir/googledir/spiders/google_directory.py
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_basic.tmpl b/examples/experimental/googledir/googledir/templates/spider_basic.tmpl
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_basic.tmpl
rename to examples/experimental/googledir/googledir/templates/spider_basic.tmpl
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_crawl.tmpl b/examples/experimental/googledir/googledir/templates/spider_crawl.tmpl
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_crawl.tmpl
rename to examples/experimental/googledir/googledir/templates/spider_crawl.tmpl
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_csvfeed.tmpl b/examples/experimental/googledir/googledir/templates/spider_csvfeed.tmpl
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_csvfeed.tmpl
rename to examples/experimental/googledir/googledir/templates/spider_csvfeed.tmpl
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_xmlfeed.tmpl b/examples/experimental/googledir/googledir/templates/spider_xmlfeed.tmpl
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/templates/spider_xmlfeed.tmpl
rename to examples/experimental/googledir/googledir/templates/spider_xmlfeed.tmpl
diff --git a/scrapy/trunk/examples/experimental/googledir/scrapy-ctl.py b/examples/experimental/googledir/scrapy-ctl.py
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/scrapy-ctl.py
rename to examples/experimental/googledir/scrapy-ctl.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/__init__.py b/examples/googledir/googledir/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/project_template/__init__.py
rename to examples/googledir/googledir/__init__.py
diff --git a/scrapy/trunk/examples/googledir/googledir/items.py b/examples/googledir/googledir/items.py
similarity index 100%
rename from scrapy/trunk/examples/googledir/googledir/items.py
rename to examples/googledir/googledir/items.py
diff --git a/scrapy/trunk/examples/googledir/googledir/pipelines.py b/examples/googledir/googledir/pipelines.py
similarity index 100%
rename from scrapy/trunk/examples/googledir/googledir/pipelines.py
rename to examples/googledir/googledir/pipelines.py
diff --git a/scrapy/trunk/examples/googledir/googledir/settings.py b/examples/googledir/googledir/settings.py
similarity index 100%
rename from scrapy/trunk/examples/googledir/googledir/settings.py
rename to examples/googledir/googledir/settings.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/spiders/__init__.py b/examples/googledir/googledir/spiders/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/project_template/spiders/__init__.py
rename to examples/googledir/googledir/spiders/__init__.py
diff --git a/scrapy/trunk/examples/googledir/googledir/spiders/google_directory.py b/examples/googledir/googledir/spiders/google_directory.py
similarity index 100%
rename from scrapy/trunk/examples/googledir/googledir/spiders/google_directory.py
rename to examples/googledir/googledir/spiders/google_directory.py
diff --git a/scrapy/trunk/examples/googledir/scrapy-ctl.py b/examples/googledir/scrapy-ctl.py
similarity index 100%
rename from scrapy/trunk/examples/googledir/scrapy-ctl.py
rename to examples/googledir/scrapy-ctl.py
diff --git a/scrapy/branches/cluster-refactor/extras/sql/scraping.sql b/extras/sql/scraping.sql
similarity index 100%
rename from scrapy/branches/cluster-refactor/extras/sql/scraping.sql
rename to extras/sql/scraping.sql
diff --git a/scrapy/trunk/profiling/priorityqueue/pq_classes.py b/profiling/priorityqueue/pq_classes.py
similarity index 100%
rename from scrapy/trunk/profiling/priorityqueue/pq_classes.py
rename to profiling/priorityqueue/pq_classes.py
diff --git a/scrapy/trunk/profiling/priorityqueue/run.py b/profiling/priorityqueue/run.py
similarity index 100%
rename from scrapy/trunk/profiling/priorityqueue/run.py
rename to profiling/priorityqueue/run.py
diff --git a/scrapy/trunk/profiling/priorityqueue/test_cases.py b/profiling/priorityqueue/test_cases.py
similarity index 100%
rename from scrapy/trunk/profiling/priorityqueue/test_cases.py
rename to profiling/priorityqueue/test_cases.py
diff --git a/scrapy/trunk/scrapy/__init__.py b/scrapy/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/__init__.py
rename to scrapy/__init__.py
diff --git a/scrapy/trunk/scrapy/bin/scrapy-admin.py b/scrapy/bin/scrapy-admin.py
similarity index 100%
rename from scrapy/trunk/scrapy/bin/scrapy-admin.py
rename to scrapy/bin/scrapy-admin.py
diff --git a/scrapy/branches/cluster-refactor/INSTALL b/scrapy/branches/cluster-refactor/INSTALL
deleted file mode 100644
index b101fd26f..000000000
--- a/scrapy/branches/cluster-refactor/INSTALL
+++ /dev/null
@@ -1,32 +0,0 @@
-You need:
- * Python 2.5
- * Twisted
- * libxml2 python bindings. version 2.6.28 or above is highly recommended.
- * pyopenssl for HTTPS support
- * for win32: http://webcleaner.sourceforge.net/pyOpenSSL-0.6.win32-py2.5.exe
- * spidermonkey (optional) - required for JSParser
- * simplejson (optional) - required for url2guid web service
-
-The python interpreter should have sys.getdefaultencoding() == 'utf-8'
-If this is not the case, you can add the following lines to a file
-[PYTHON_INSTALL]/site-packages/sitecustomize.py:
-import sys
-sys.setdefaultencoding('utf-8')
-
-
-INSTALLING LIBRARIES
---------------------
-
-The procedure for installing the required third party libraries (twisted,
-libxml2 and pyopenssl) depends on the platform and OS you use.
-
-Visit the project homepages for more information about it:
-
- * Twisted: http://twistedmatrix.com/
- * libxml2: http://xmlsoft.org/
- * releases available here: ftp://xmlsoft.org/libxml2/
- * pyopenssl: http://pyopenssl.sourceforge.net/
-
-
-In Debian/Ubuntu Linux it's as easy as:
-apt-get install python-twisted python-libxml2 python-pyopenssl
diff --git a/scrapy/branches/cluster-refactor/scrapy/__init__.py b/scrapy/branches/cluster-refactor/scrapy/__init__.py
deleted file mode 100644
index 8b3215d1e..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-"""
-Scrapy - a screen scraping framework written in Python
-"""
-
-__version__ = "0.1.0"
-
-import sys, os
-
-if sys.version_info < (2,5):
- print "Scrapy %s requires Python 2.5 or above" % __version__
- sys.exit(1)
-
-# add external python libraries bundled into scrapy
-sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), "xlib"))
-
-# monkey patches to fix external library issues
-from scrapy.patches import monkeypatches
-monkeypatches.apply_patches()
diff --git a/scrapy/branches/cluster-refactor/scrapy/bin/scrapy-admin.py b/scrapy/branches/cluster-refactor/scrapy/bin/scrapy-admin.py
deleted file mode 100755
index f2dc1d5c3..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/bin/scrapy-admin.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-"""Scrapy admin script is used to create new scrapy projects and similar
-tasks"""
-
-import os
-import shutil
-from optparse import OptionParser
-
-import scrapy
-
-usage = """
-scrapy-admin.py [options] [command]
-
-Available commands:
-
- startproject <project_name>
- Starts a new project with name 'project_name'
-"""
-
-def main():
- parser = OptionParser(usage=usage)
- opts, args = parser.parse_args()
-
- if not args:
- parser.print_help()
-
- cmd = args[0]
- if cmd == "startproject":
- if len(args) >= 2:
- project_name = args[1]
- project_tplpath = os.path.join(scrapy.__path__[0], "conf", "project_template")
- shutil.copytree(project_tplpath, project_name)
- else:
- print "scrapy-admin.py: missing project name"
- else:
- print "scrapy-admin.py: unknown command: %s" % cmd
-
-if __name__ == '__main__':
- main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/cmdline.py b/scrapy/branches/cluster-refactor/scrapy/command/cmdline.py
deleted file mode 100644
index 0ef238448..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/cmdline.py
+++ /dev/null
@@ -1,157 +0,0 @@
-from __future__ import with_statement
-
-import sys
-import os
-import optparse
-
-import scrapy
-from scrapy import log
-from scrapy.spider import spiders
-from scrapy.conf import settings
-
-def find_commands(dir):
- try:
- return [f[:-3] for f in os.listdir(dir) if not f.startswith('_') and f.endswith('.py')]
- except OSError:
- return []
-
-def builtin_commands_dict():
- d = {}
- scrapy_dir = scrapy.__path__[0]
- commands_dir = os.path.join(scrapy_dir, 'command', 'commands')
- for cmdname in find_commands(commands_dir):
- modname = 'scrapy.command.commands.%s' % cmdname
- command = getattr(__import__(modname, {}, {}, [cmdname]), 'Command', None)
- if callable(command):
- d[cmdname] = command()
- else:
- print 'WARNING: Builtin command module %s exists but Command class not found' % modname
- return d
-
-def custom_commands_dict():
- d = {}
- cmdsmod = settings['COMMANDS_MODULE']
- if cmdsmod:
- mod = __import__(cmdsmod, {}, {}, [''])
- for cmdname in find_commands(mod.__path__[0]):
- modname = '%s.%s' % (cmdsmod, cmdname)
- command = getattr(__import__(modname, {}, {}, [cmdname]), 'Command', None)
- if callable(command):
- d[cmdname] = command()
- else:
- print 'WARNING: Custom command module %s exists but Command class not found' % modname
- return d
-
-def getcmdname(argv):
- for arg in argv[1:]:
- if not arg.startswith('-'):
- return arg
-
-def usage(argv):
- s = "usage: %s <subcommand> [options] [args]\n" % argv[0]
- s += " %s <subcommand> -h\n\n" % argv[0]
- s += "Built-in subcommands:\n"
-
- builtin_cmds = builtin_commands_dict()
- custom_cmds = custom_commands_dict()
-
- filtered_builtin_cmds = [(name, cls) for name, cls in builtin_cmds.iteritems() if name not in custom_cmds]
-
- for cmdname, cmdclass in filtered_builtin_cmds:
- s += " %s %s\n" % (cmdname, cmdclass.syntax())
- s += " %s\n" % cmdclass.short_desc()
-
- if custom_cmds:
- s += "\n"
- s += "Custom (or overloaded) subcommands:\n"
- for cmdname, cmdclass in custom_cmds.iteritems():
- s += " %s %s\n" % (cmdname, cmdclass.syntax())
- s += " %s\n" % cmdclass.short_desc()
-
- return s
-
-
-def update_defaults(defaults, module):
- settingsdict = vars(module)
- for k, v in settingsdict.iteritems():
- if not k.startswith("_"):
- defaults[k] = v
-
-def command_settings(cmdname):
- try:
- module = __import__('%s.%s' % ('scrapy.conf.commands', cmdname), {}, {}, [''])
- update_defaults(settings.defaults, module)
- except ImportError:
- pass
-
- basepath = settings['COMMANDS_SETTINGS_MODULE']
- if basepath:
- try:
- module = __import__('%s.%s' % (basepath, cmdname), {}, {}, [''])
- update_defaults(settings.defaults, module)
- except ImportError:
- pass
-
-# This dict holds information about the executed command for later use
-command_executed = {}
-
-def execute():
- execute_with_args(sys.argv)
-
-def execute_with_args(argv):
- spiders.load()
- cmds = builtin_commands_dict()
- cmds.update(custom_commands_dict())
-
- cmdname = getcmdname(argv)
- command_settings(cmdname)
-
- if not cmdname:
- print "Scrapy %s\n" % scrapy.__version__
- print usage(argv)
- sys.exit()
-
- parser = optparse.OptionParser()
-
- if cmdname in cmds:
- cmd = cmds[cmdname]
- cmd.add_options(parser)
- parser.usage = "%%prog %s %s" % (cmdname, cmd.syntax())
- parser.description = cmd.long_desc()
- else:
- print "Scrapy %s\n" % scrapy.__version__
- print "Unknown command: %s\n" % cmdname
- print 'Type "%s -h" for help' % argv[0]
- sys.exit()
-
- (opts, args) = parser.parse_args(args=argv[1:])
- del args[0] # args[0] is cmdname
-
- # storing command executed info for later reference
- command_executed['name'] = cmdname
- command_executed['class'] = cmd
- command_executed['args'] = args[:]
- command_executed['opts'] = opts.__dict__.copy()
-
- cmd.process_options(args, opts)
- log.start() # start logging
- if opts.profile:
- log.msg("Profiling enabled. Analyze later with: python -m pstats %s" % opts.profile)
- import cProfile
- loc = locals()
- p = cProfile.Profile()
- p.runctx('ret = cmd.run(args, opts)', globals(), loc)
- p.dump_stats(opts.profile)
- try:
- import lsprofcalltree
- fn = opts.profile + ".cachegrind"
- k = lsprofcalltree.KCacheGrind(p)
- with open(fn, 'w') as f:
- k.output(f)
- except ImportError:
- pass
- ret = loc['ret']
- else:
- ret = cmd.run(args, opts)
- if ret is False:
- parser.print_help()
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/crawl.py b/scrapy/branches/cluster-refactor/scrapy/command/commands/crawl.py
deleted file mode 100644
index 866ce16c9..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/commands/crawl.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from scrapy.command import ScrapyCommand
-from scrapy.core.manager import scrapymanager
-from scrapy.replay import Replay
-from scrapy.conf import settings
-
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "[options] [domain|url] ..."
-
- def short_desc(self):
- return "Run the web scraping engine from the command line"
-
- def add_options(self, parser):
- ScrapyCommand.add_options(self, parser)
- parser.add_option("--nocache", dest="nocache", action="store_true", help="disable HTTP cache")
- parser.add_option("--nopipeline", dest="nopipeline", action="store_true", help="disable scraped item pipeline")
- parser.add_option("--restrict", dest="restrict", action="store_true", help="restrict crawling only to the given urls")
- parser.add_option("--record", dest="record", help="use FILE for recording session (see replay command)", metavar="FILE")
- parser.add_option("--record-dir", dest="recorddir", help="use DIR for recording (instead of file)", metavar="DIR")
-
- def process_options(self, args, opts):
- ScrapyCommand.process_options(self, args, opts)
- if opts.nopipeline:
- settings.overrides['ITEM_PIPELINES'] = []
-
- if opts.nocache:
- settings.overrides['CACHE2_DIR'] = None
-
- if opts.restrict:
- settings.overrides['RESTRICT_TO_URLS'] = args
-
- if opts.record or opts.recorddir:
- # self.replay is used for preventing Replay signals handler from
- # disconnecting since pydispatcher uses weak references
- self.replay = Replay(opts.record or opts.recorddir, mode='record', usedir=bool(opts.recorddir))
- self.replay.record(args=args, opts=opts.__dict__)
-
- def run(self, args, opts):
- scrapymanager.runonce(*args, **opts.__dict__)
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/genspider.py b/scrapy/branches/cluster-refactor/scrapy/command/commands/genspider.py
deleted file mode 100644
index d442c500a..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/commands/genspider.py
+++ /dev/null
@@ -1,64 +0,0 @@
-import os
-import string
-
-from scrapy.spider import spiders
-from scrapy.command import ScrapyCommand
-from scrapy.conf import settings
-
-class Command(ScrapyCommand):
-
- """ Default template file name """
- template_name = 'spider.tmpl'
-
- """ Childs can define custom tvars """
- custom_tvars = {}
-
- def syntax(self):
- return "<spider_name> <spider_domain_name>"
-
- def short_desc(self):
- return "Generate new spider based on predefined template"
-
- def run(self, args, opts):
- if len(args) != 2:
- return False
-
- name = args[0]
- site = args[1]
- spiders_dict = spiders.asdict()
- if not name in spiders_dict.keys():
- self._genspider(name, site)
- else:
- print "Spider '%s' exist" % name
-
- def _genspider(self, name, site):
- """ Generate spider """
- tvars = {
- 'name': name,
- 'site': site,
- 'classname': '%sSpider' % ''.join([s.capitalize() for s in name.split('-')])
- }
- tvars.update(self.custom_tvars)
-
- spiders_module = __import__(settings['NEWSPIDER_MODULE'], {}, {}, [''])
- spidersdir = os.path.abspath(os.path.dirname(spiders_module.__file__))
- if name[0] not in string.letters: # must start with a letter, for valid python modules
- name = "a" + name
- name = name.replace('-', '_') # - are replaced by _, for valid python modules
- self._genfiles(self.template_name, '%s/%s.py' % (spidersdir, name), tvars)
-
- def _genfiles(self, template_name, source_name, tvars):
- """ Generate source from template, substitute variables """
- template_file = os.path.join(settings['TEMPLATES_DIR'], template_name)
- tmpl = open(template_file)
- clines = []
- for l in tmpl.readlines():
- for key, val in tvars.items():
- l = l.replace('@%s@' % key, val)
- clines.append(l)
- tmpl.close()
- source = ''.join(clines)
- if not os.path.exists(source_name):
- sfile = open(source_name, "w")
- sfile.write(source)
- sfile.close()
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/getattr.py b/scrapy/branches/cluster-refactor/scrapy/command/commands/getattr.py
deleted file mode 100644
index ac639bf3d..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/commands/getattr.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from scrapy.command import ScrapyCommand
-from scrapy.fetcher import fetch
-from scrapy.spider import spiders
-from scrapy.item import ScrapedItem
-
-def get_item_attr(pagedata, attr="guid"):
- spider = spiders.fromurl(pagedata.url)
- items = spider.parse(pagedata)
- attrs = [getattr(i, attr) for i in items if isinstance(i, ScrapedItem)]
- return attrs
-
-def get_attr(url, attr="guid"):
- pagedatas = fetch([url])
- if pagedatas:
- return get_item_attr(pagedatas[0], attr)
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "<url> <attribute>"
-
- def short_desc(self):
- return "Print an attribute from the item scraped in the given URL"
-
- def run(self, args, opts):
- print get_attr(args[0], args[1])
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/parse.py b/scrapy/branches/cluster-refactor/scrapy/command/commands/parse.py
deleted file mode 100644
index 79860b9af..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/commands/parse.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from scrapy.command import ScrapyCommand
-from scrapy.fetcher import fetch
-from scrapy.http import Request
-from scrapy.item import ScrapedItem
-from scrapy.spider import spiders
-from scrapy.utils import display
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "[options] <url>"
-
- def short_desc(self):
- return "Parse the URL and print their results"
-
- def add_options(self, parser):
- ScrapyCommand.add_options(self, parser)
- parser.add_option("--nolinks", dest="nolinks", action="store_true", help="don't show extracted links")
- parser.add_option("--noitems", dest="noitems", action="store_true", help="don't show scraped items")
- parser.add_option("--identify", dest="identify", action="store_true", help="try to use identify instead of parse")
- parser.add_option("--nocolour", dest="nocolour", action="store_true", help="avoid using pygments to colorize the output")
-
- def pipeline_process(self, item, opts):
- return item
-
- def run(self, args, opts):
- if not args:
- print "A URL is required"
- return
-
- responses = fetch([args[0]])
- if responses:
- response = responses[0]
- spider = spiders.fromurl(response.url)
- result = spider.parse(response) if not opts.identify else spider.identify(response)
-
- items = [self.pipeline_process(i, opts) for i in result if isinstance(i, ScrapedItem)]
- links = [i for i in result if isinstance(i, Request)]
-
- display.nocolour = opts.nocolour
- if not opts.noitems:
- print "# Scraped Items", "-"*60
- display.pprint(items)
-
- if not opts.nolinks:
- print "# Links", "-"*68
- display.pprint(links)
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/replay.py b/scrapy/branches/cluster-refactor/scrapy/command/commands/replay.py
deleted file mode 100644
index 590f976a9..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/commands/replay.py
+++ /dev/null
@@ -1,184 +0,0 @@
-import os
-
-from scrapy.command import ScrapyCommand
-from scrapy.replay import Replay
-from scrapy.utils import display
-from scrapy.conf import settings
-from scrapy.command import cmdline
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "[options] <replay_file> [action]"
-
- def short_desc(self):
- return "Replay a session previously recorded with crawl --record"
-
- def help(self):
- s = "Replay a session previously recorded with crawl --record\n"
- s += "\n"
- s += "Available actions:\n"
- s += " crawl: just replay the crawl (default if action omitted)\n"
- s += " diff: replay the crawl and show differences in items scraped/passed\n"
- s += " update: replay the crawl and update both scraped and passed items\n"
- s += " showitems: show items stored\n"
- s += " showpages: show all responses downloaded (not only HTML pages)\n"
- return s
-
- def add_options(self, parser):
- ScrapyCommand.add_options(self, parser)
- parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="show verbose output (full items/responses)")
- parser.add_option("-t", "--item-type", dest="itype", help="item type (scraped, passed). default: scraped", metavar="TYPE")
- parser.add_option("--output", dest="outfile", help="write output to FILE. if omitted uses stdout", metavar="FILE")
- parser.add_option("--nocolour", dest="nocolour", action="store_true", help="disable colorized output (for console only)")
- parser.add_option("-i", "--ignore", dest="ignores", action="append", help="item attribute to ignore. can be passed multiple times", metavar="ATTR")
- parser.add_option("--target", dest="targets", action="append", help="crawl TARGET instead of recorded urls/domains. can be passed multiple times")
- # adding option to update
- parser.add_option("--pages", dest="pages", action="store_true", help="update all the pages in the replay file, recording it again.")
- parser.add_option("-q", "--quiet", dest="quiet", action="store_true", help="no verbose mode in option diff.")
-
- def process_options(self, args, opts):
- if args:
- ScrapyCommand.process_options(self, args, opts)
- self.opts = opts
- self.action = args[1] if len(args) > 1 else 'crawl'
- mode = 'update' if self.action == 'update' else 'play'
- usedir = args and os.path.isdir(args[0])
- self.replay = Replay(args[0], mode=mode, usedir=usedir)
- if self.action not in ['crawl', 'diff', 'update']:
- settings.overrides['LOG_ENABLED'] = False
-
- def run(self, args, opts):
- if not args:
- print "A <replay_dir> is required"
- return
-
- display.nocolour = opts.nocolour
-
- if opts.itype == 'passed':
- self.before_db = self.replay.passed_old
- self.now_db = self.replay.passed_new
- else: # default is 'scraped'
- opts.itype = 'scraped'
- self.before_db = self.replay.scraped_old
- self.now_db = self.replay.scraped_new
-
- actionfunc = getattr(self, 'action_%s' % self.action, None)
- if actionfunc:
- rep = actionfunc(opts)
- if rep:
- if opts.outfile:
- f = open(opts.outfile, "w")
- f.write(rep)
- f.close()
- else:
- print rep,
- self.replay.cleanup()
- else:
- print "Unknown replay action: %s" % self.action
-
- def action_crawl(self, opts):
- self.replay.play(args=opts.targets)
-
- def action_update(self, opts):
- self.replay.update(args=opts.targets, opts=opts.__dict__)
- if (opts.pages):
- args = ['scrapy-crawl', 'crawl']
- args.extend(self.replay.options['args'])
- for k in self.replay.options['opts']:
- if self.replay.options['opts'][k]:
- args.append("--%s" % k)
- if self.replay.options['opts'][k] != True:
- args.append(self.replay.options['opts'][k])
- cmdline.execute_with_args(args)
-
- def action_showitems(self, opts):
- s = ""
- s += self._format_items(self.before_db.values())
- s += ">>> Total: %d items %s\n" % (len(self.before_db), opts.itype)
- return s
-
- def action_showpages(self, opts):
- s = ""
- if self.opts.verbose:
- for r in self.replay.responses_old.values():
- s += ">>> %s\n" % str(r)
- s += display.pformat(r)
- else:
- s += "\n".join([str(r) for r in self.replay.responses_old.values()]) + "\n"
- s += ">>> Total: %d responses received\n" % len(self.replay.responses_old)
- return s
-
- def action_diff(self, opts):
- self.action_crawl(opts)
-
- guids_before = set(self.before_db.keys())
- guids_now = set(map(str, self.now_db.keys()))
-
- guids_new = guids_now - guids_before
- guids_missing = guids_before - guids_now
- guids_both = guids_now & guids_before
-
- changed_items, chreport = self._report_differences(self.before_db, self.now_db, guids_both)
-
- ok_items = len(guids_both) - changed_items
- new_items = len(guids_new)
- missing_items = len(guids_missing)
-
- if (new_items - missing_items - changed_items) == 0 and opts.quiet:
- s = ""
- else:
- s = "CRAWLING DIFFERENCES REPORT\n\n"
-
- s += "Total items : %d\n" % (len(guids_both) + new_items + missing_items)
- s += " Items OK : %d\n" % ok_items
- s += " New items : %d\n" % new_items
- s += " Missing items : %d\n" % missing_items
- s += " Changed items : %d\n" % changed_items
-
- s += "\n"
- s += "- NEW ITEMS (%d) -----------------------------------------\n" % new_items
- s += self._format_items([self.now_db[g] for g in guids_new])
-
- s += "\n"
- s += "- MISSING ITEMS (%d) -------------------------------------\n" % missing_items
- s += self._format_items([self.before_db[g] for g in guids_missing])
-
- s += "\n"
- s += "- CHANGED ITEMS (%d) -------------------------------------\n" % changed_items
-
- s += chreport
-
- return s
-
- def _report_differences(self, old_items, new_items, guids):
- items_old = [old_items[g] for g in guids]
- items_new = [new_items[g] for g in guids]
-
- c = 0
- s = ""
- for old, new in zip(items_old, items_new):
- d = self._item_diff(old, new)
- if d:
- c += 1
- s += d
- return c, s
-
- def _item_diff(self, old, new):
- delta = new - old
-
- s = ""
- if delta.diff:
- s += ">>> Item guid=%s name=%s\n" % (old.guid, old.name)
- s += display.pformat(delta.diff) + "\n"
- return s
-
- def _format_items(self, items):
- if self.opts.verbose:
- s = display.pformat(items)
- else:
- s = ""
- for i in items:
- s += "%s\n" % str(i)
- s += " <%s>\n" % i.url
- return s
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/shell.py b/scrapy/branches/cluster-refactor/scrapy/command/commands/shell.py
deleted file mode 100644
index 474b53a08..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/commands/shell.py
+++ /dev/null
@@ -1,158 +0,0 @@
-from twisted.internet import reactor
-
-import scrapy
-from scrapy.command import ScrapyCommand
-from scrapy.spider import spiders
-from scrapy.xpath import XmlXPathSelector, HtmlXPathSelector
-from scrapy.utils.misc import load_class
-from scrapy.extension import extensions
-from scrapy.conf import settings
-from scrapy.core.manager import scrapymanager
-from scrapy.http import Request, Response
-from scrapy.core.downloader.handlers import download_any
-from scrapy.fetcher import get_or_create_spider
-from scrapy.utils.decompressor import Decompressor
-
-#This code comes from twisted 8. We define here while
-#using old twisted version.
-def blockingCallFromThread(reactor, f, *a, **kw):
- """
- Run a function in the reactor from a thread, and wait for the result
- synchronously, i.e. until the callback chain returned by the function
- get a result.
-
- @param reactor: The L{IReactorThreads} provider which will be used to
- schedule the function call.
- @param f: the callable to run in the reactor thread
- @type f: any callable.
- @param a: the arguments to pass to C{f}.
- @param kw: the keyword arguments to pass to C{f}.
-
- @return: the result of the callback chain.
- @raise: any error raised during the callback chain.
- """
- import Queue
- from twisted.python import failure
- from twisted.internet import defer
- queue = Queue.Queue()
- def _callFromThread():
- result = defer.maybeDeferred(f, *a, **kw)
- result.addBoth(queue.put)
- reactor.callFromThread(_callFromThread)
- result = queue.get()
- if isinstance(result, failure.Failure):
- result.raiseException()
- return result
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "[url]"
-
- def short_desc(self):
- return "Interactive scraping console"
-
- def long_desc(self):
- return "Interactive console for scraping the given url. For scraping local files you can use a URL like file://path/to/file.html"
-
- def update_vars(self):
- """ You can use this function to update the local variables that will be available in the scrape console """
- pass
-
- def get_url(self, url, decompress=False):
-
- print "Downloading URL... ",
- r = Request(url)
- spider = get_or_create_spider(url)
- try:
- result = blockingCallFromThread(reactor, download_any, r, spider)
- if isinstance(result, Response):
- print "Done."
- if decompress:
- print "Decompressing response...",
- d = Decompressor()
- result = d.extract(result)
- print "Done."
- result.request = r
- self.generate_vars(url, result)
- return True
- except Exception, e:
- print "Error: %s" % e
-
- def generate_vars(self, url, response):
- itemcls = load_class(settings['DEFAULT_ITEM_CLASS'])
- item = itemcls()
- self.vars['item'] = item
- if url:
- self.vars['xxs'] = XmlXPathSelector(response)
- self.vars['hxs'] = HtmlXPathSelector(response)
- self.vars['url'] = url
- self.vars['response'] = response
- self.vars['spider'] = spiders.fromurl(url)
- self.update_vars()
- self.user_ns.update(self.vars)
- self.print_vars()
-
- def print_vars(self):
- print '-' * 78
- print "Available local variables:"
- for key, val in self.vars.iteritems():
- if isinstance(val, basestring):
- print " %s: %s" % (key, val)
- else:
- print " %s: %s" % (key, val.__class__)
- print "Available commands:"
- print " get <url>: Fetches an url and updates all variables."
- print " getd <url>: Similar to get, but filter with decompress."
- print " scrapehelp: Prints this help."
- print '-' * 78
-
- def run(self, args, opts):
- self.vars = {}
- self.user_ns = {}
- url = None
- if args:
- url = args[0]
-
- print "Scrapy %s - Interactive scraping console\n" % scrapy.__version__
-
- print "Enabling Scrapy extensions...",
- extensions.load()
- print "done"
-
- def _console_thread():
-
- def _get_magic(shell, arg):
- self.get_url(arg.strip())
- def _help_magic(shell, _):
- self.print_vars()
- def _getd_magic(shell, arg):
- self.get_url(arg.strip(), decompress=True)
-
- if url:
- result = self.get_url(url)
- if not result:
- self.generate_vars(None, None)
- else:
- self.generate_vars(None, None)
- try: # use IPython if available
- import IPython
- shell = IPython.Shell.IPShell(argv=[], user_ns=self.user_ns)
- ip = shell.IP.getapi()
- ip.expose_magic("get", _get_magic)
- ip.expose_magic("getd", _getd_magic)
- ip.expose_magic("scrapehelp", _help_magic)
- shell.mainloop()
- reactor.callFromThread(scrapymanager.stop)
- except ImportError:
- import code
- try: # readline module is only available on unix systems
- import readline
- except ImportError:
- pass
- else:
- import rlcompleter
- readline.parse_and_bind("tab:complete")
- code.interact(local=self.vars)
-
- reactor.callInThread(_console_thread)
- scrapymanager.start()
\ No newline at end of file
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/stats.py b/scrapy/branches/cluster-refactor/scrapy/command/commands/stats.py
deleted file mode 100644
index e062ce6a8..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/commands/stats.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import pprint
-from scrapy.command import ScrapyCommand
-from scrapy.conf import settings
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "<domain> [domain ...]"
-
- def short_desc(self):
- return "Show all stats history stored for the given domain(s)"
-
- def add_options(self, parser):
- ScrapyCommand.add_options(self, parser)
- parser.add_option("-p", "--path", dest="path", help="restrict stats to PATH", metavar="PATH")
-
- def run(self, args, opts):
- if not args:
- print "A domain is required"
- return
- if not settings['SCRAPING_DB']:
- print "SCRAPING_DB setting is required for this command"
- return
-
- from scrapy.store.db import DomainDataHistory
- ddh = DomainDataHistory(settings['SCRAPING_DB'], 'domain_data_history')
-
- for domain in args:
- print "# %s" % domain
- pprint.pprint(list(ddh.getall(domain, opts.path)))
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/models.py b/scrapy/branches/cluster-refactor/scrapy/command/models.py
deleted file mode 100644
index b4e247d4b..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/command/models.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""
-Base class for Scrapy commands
-"""
-import os
-from scrapy.conf import settings
-
-class ScrapyCommand(object):
- def syntax(self):
- """
- Command syntax (preferably one-line). Do not include command name.
- """
- return ""
-
- def short_desc(self):
- """
- A short description of the command
- """
- return ""
-
- def long_desc(self):
- """
- A long description of the command. Return short description when not
- available. It cannot contain newlines, since contents will be formatted
- by optparser which removes newlines and wraps text.
- """
- return self.short_desc()
-
- def help(self):
- """
- An extensive help for the command. It will be shown when using the
- "help" command. It can contain newlines, since not post-formatting will
- be applied to its contents.
- """
- return self.long_desc()
-
- def add_options(self, parser):
- """
- Populate option parse with options available for this command
- """
- parser.add_option("-f", "--logfile", dest="logfile", help="logfile to use. if omitted stderr will be used", metavar="FILE")
- parser.add_option("-o", "--loglevel", dest="loglevel", default=None, help="log level")
- parser.add_option("--default-spider", dest="default_spider", default=None, help="default spider (domain) to use if no spider is found")
- parser.add_option("--spider", dest="spider", default=None, help="Force using the given spider when the arguments are urls")
- parser.add_option("--nolog", dest="nolog", action="store_true", help="disable all log messages")
- parser.add_option("--profile", dest="profile", default=None, help="write profiling stats in FILE, to analyze later with: python -m pstats FILE", metavar="FILE")
- parser.add_option("--pidfile", dest="pidfile", help="Write process pid to file FILE", metavar="FILE")
-
- def process_options(self, args, opts):
- if opts.logfile:
- settings.overrides['LOG_ENABLED'] = True
- settings.overrides['LOGFILE'] = opts.logfile
-
- if opts.loglevel:
- settings.overrides['LOG_ENABLED'] = True
- settings.overrides['LOGLEVEL'] = opts.loglevel
-
- if opts.nolog:
- settings.overrides['LOG_ENABLED'] = False
-
- if opts.default_spider:
- from scrapy.spider import spiders
- spiders.default_domain = opts.default_spider
-
- if opts.spider:
- from scrapy.spider import spiders
- spiders.force_domain = opts.spider
-
- if opts.pidfile:
- pid = os.getpid()
- open(opts.pidfile, "w").write(str(pid))
-
- def run(self, args, opts):
- """
- Entry point for running commands
- """
- raise NotImplementedError
-
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/__init__.py b/scrapy/branches/cluster-refactor/scrapy/conf/__init__.py
deleted file mode 100644
index 6bb2f4c6d..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/conf/__init__.py
+++ /dev/null
@@ -1,67 +0,0 @@
-import os
-import cPickle as pickle
-
-SETTINGS_MODULE = os.environ.get('SCRAPYSETTINGS_MODULE', 'scrapy_settings')
-
-class Settings(object):
- """Class to obtain configuration values from settings module
- which can be overriden by environment variables prepended by SCRAPY_"""
-
- # settings in precedence order
- overrides = None
- settings = None
- defaults = None
- core = None
-
- def __init__(self):
- pickled_settings = os.environ.get("SCRAPY_PICKLED_SETTINGS_TO_OVERRIDE")
- self.overrides = pickle.loads(pickled_settings) if pickled_settings else {}
- self.settings = self._import(SETTINGS_MODULE)
- self.defaults = {}
- self.core = self._import('scrapy.conf.core_settings')
-
- def _import(self, modulepath):
- return __import__(modulepath, {}, {}, [''])
-
- def __getitem__(self, opt_name):
- if opt_name in self.overrides:
- return self.overrides[opt_name]
-
- if 'SCRAPY_' + opt_name in os.environ:
- return os.environ['SCRAPY_' + opt_name]
-
- if hasattr(self.settings, opt_name):
- return getattr(self.settings, opt_name)
-
- if opt_name in self.defaults:
- return self.defaults[opt_name]
-
- if hasattr(self.core, opt_name):
- return getattr(self.core, opt_name)
-
- def get(self, name, default=None):
- return self[name] if self[name] is not None else default
-
- def getbool(self, name, default=False):
- """
- True is: 1, '1', True
- False is: 0, '0', False, None
- """
- return bool(int(self.get(name, default)))
-
- def getint(self, name, default=0):
- return int(self.get(name, default))
-
- def getfloat(self, name, default=0.0):
- return float(self.get(name, default))
-
- def getlist(self, name, default=None):
- value = self.get(name)
- if value is None:
- return []
- elif hasattr(value, '__iter__'):
- return value
- else:
- return str(value).split(',')
-
-settings = Settings()
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/core_settings.py b/scrapy/branches/cluster-refactor/scrapy/conf/core_settings.py
deleted file mode 100644
index ad140af03..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/conf/core_settings.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import scrapy
-# Scrapy core settings
-
-BOT_NAME = 'scrapy'
-BOT_VERSION = scrapy.__version__
-
-ENGINE_DEBUG = False
-
-# Download configuration options
-USER_AGENT = '%s/%s' % (BOT_NAME, BOT_VERSION)
-DOWNLOAD_TIMEOUT = 180 # 3mins
-CONCURRENT_DOMAINS = 8 # number of domains to scrape in parallel
-REQUESTS_PER_DOMAIN = 8 # max simultaneous requests per domain
-CACHE2_EXPIRATION_SECS = 48 * 60 * 60 # seconds while cached response is still valid (a negative value means "never expires")
-
-LOG_ENABLED = True #
-LOGLEVEL = 'DEBUG' # default loglevel
-LOGFILE = None # None means sys.stderr by default
-LOG_STDOUT = False #
-
-DEFAULT_ITEM_CLASS = 'scrapy.item.ScrapedItem'
-SCHEDULER = 'scrapy.core.scheduler.Scheduler'
-MEMORYSTORE = 'scrapy.core.scheduler.MemoryStore'
-PRIORITIZER = 'scrapy.core.prioritizers.RandomPrioritizer'
-
-EXTENSIONS = []
-
-# contrib.middleware.retry.RetryMiddleware default settings
-RETRY_TIMES = 3
-RETRY_HTTP_CODES = ['500', '503', '504', '400', '408', '200']
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/items.py b/scrapy/branches/cluster-refactor/scrapy/conf/project_template/items.py
deleted file mode 100644
index d78c4d149..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/items.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# Define here the models for your scraped items
-
-from scrapy.item import ScrapedItem
-
-class MyItem(ScrapedItem):
- pass
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/scrapy-ctl.py b/scrapy/branches/cluster-refactor/scrapy/conf/project_template/scrapy-ctl.py
deleted file mode 100755
index e8e56eaf2..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/scrapy-ctl.py
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env python
-
-from scrapy.command.cmdline import execute
-execute()
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/scrapy_settings.py b/scrapy/branches/cluster-refactor/scrapy/conf/project_template/scrapy_settings.py
deleted file mode 100644
index e3712975c..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/conf/project_template/scrapy_settings.py
+++ /dev/null
@@ -1,95 +0,0 @@
-import $project_name
-
-# ---------------------------------------------------------------------------
-# - Scrapy settings for $project_name -
-# ---------------------------------------------------------------------------
-
-BOT_NAME = 'scrapybot'
-BOT_VERSION = '1.0'
-
-SPIDER_MODULES = ['$project_name.spiders']
-NEWSPIDER_MODULE = '$project_name.spiders'
-TEMPLATES_DIR = '%s/templates' % $project_name.__path__[0]
-ENABLED_SPIDERS_FILE = '%s/conf/enabled_spiders.list' % $project_name.__path__[0]
-DEFAULT_ITEM_CLASS = 'scrapy.item.ScrapedItem'
-USER_AGENT = '%s/%s' % (BOT_NAME, BOT_VERSION)
-DOWNLOAD_TIMEOUT = 600
-
-# uncomment if you want to add your own custom scrapy commands
-#COMMANDS_MODULE = '$project_name.commands'
-#COMMANDS_SETTINGS_MODULE = '$project_name.conf.commands'
-
-#Global timeout between sucessive downloads (can be overrided by spider
-#attribute download_timeout
-#DOWNLOAD_TIMEOUT = 0
-
-MYSQL_CONNECTION_SETTINGS = {"charset": "utf8" }
-MYSQL_CONNECTION_PING_PERIOD = 600
-
-SCHEDULER = 'scrapy.core.scheduler.Scheduler'
-SCHEDULER_ORDER = 'BFO' # available orders: BFO (default), DFO
-
-#CACHE2_DIR = '/tmp/cache2' # if set, enables HTTP cache
-#CACHE2_IGNORE_MISSING = 0 # ignore requests not in cache
-#CACHE2_SECTORIZE = 1 # sectorize domains to distribute storage among servers
-
-#STATS_ENABLED = 1 # enable stats
-#STATS_CLEANUP = 0 # cleanup domain stats when a domain is closed (saves memory)
-#STATS_DEBUG = 0 # log stats on domain closed
-
-EXTENSIONS = (
- 'scrapy.management.web.WebConsole',
- 'scrapy.management.telnet.TelnetConsole',
-)
-
-DOWNLOADER_MIDDLEWARES = (
- # Engine side
- 'scrapy.contrib.downloadermiddleware.errorpages.ErrorPagesMiddleware',
- 'scrapy.contrib.downloadermiddleware.cookies.CookiesMiddleware',
- 'scrapy.contrib.downloadermiddleware.httpauth.HttpAuthMiddleware',
- 'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware',
- 'scrapy.contrib.downloadermiddleware.retry.RetryMiddleware',
- 'scrapy.contrib.downloadermiddleware.common.CommonMiddleware',
- 'scrapy.contrib.downloadermiddleware.redirect.RedirectMiddleware',
- 'scrapy.contrib.downloadermiddleware.compression.CompressionMiddleware',
- 'scrapy.contrib.downloadermiddleware.debug.CrawlDebug',
- 'scrapy.contrib.downloadermiddleware.cache.CacheMiddleware',
- # Downloader side
-)
-
-SPIDER_MIDDLEWARES = (
- # Engine side
- 'scrapy.contrib.spidermiddleware.limit.RequestLimitMiddleware',
- 'scrapy.contrib.spidermiddleware.restrict.RestrictMiddleware',
- 'scrapy.contrib.spidermiddleware.offsite.OffsiteMiddleware',
- 'scrapy.contrib.spidermiddleware.referer.RefererMiddleware',
- 'scrapy.contrib.spidermiddleware.urllength.UrlLengthMiddleware',
- 'scrapy.contrib.spidermiddleware.depth.DepthMiddleware',
- 'scrapy.contrib.spidermiddleware.urlfilter.UrlFilterMiddleware',
- # Spider side
-)
-
-# Item pipelines are usually configured by commands (see conf/commands)
-#ITEM_PIPELINES = (
-#)
-
-#DEPTH_LIMIT = 10 # limit the maximum link depth to follow
-#DEPTH_STATS = 1 # enable depth stats
-
-# Limit URL length. See: http://www.boutell.com/newfaq/misc/urllength.html
-URLLENGTH_LIMIT = 2083
-
-#WEBCONSOLE_ENABLED = 1
-#WEBCONSOLE_PORT = 8060 # if not set uses a dynamic port
-
-#TELNETCONSOLE_ENABLED = 1
-#TELNETCONSOLE_PORT = 2020 # if not set uses a dynamic port
-
-# global mail sending settings
-#MAIL_HOST = 'localhost'
-#MAIL_FROM = 'scrapybot@localhost'
-
-# scrapy webservice
-WS_ENABLED = 0
-
-SPIDERPROFILER_ENABLED = 0
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/adaptorpipeline.py b/scrapy/branches/cluster-refactor/scrapy/contrib/adaptorpipeline.py
deleted file mode 100644
index 9bac76b31..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/adaptorpipeline.py
+++ /dev/null
@@ -1,85 +0,0 @@
-from scrapy.item.adaptors import AdaptorPipe as BaseAdaptorPipe
-from scrapy.utils.serialization import serialize
-
-class DuplicatedAdaptorName(Exception): pass
-
-class _Adaptor(object):
- """
- Adaptors instances should be instantiated and used only
- inside the AdaptorPipe.
- """
- def __init__(self, function, match_function):
- self.basefunction = function
- self.match_function = match_function
- def __repr__(self):
- return self.basefunction.func_name
- def __call__(self, *args):
- return self.basefunction(*args)
-
-class AdaptorPipe(BaseAdaptorPipe):
-
- def __init__(self, attribute_names, adaptors=None):
- """
- If "adaptors" is given, constructs pipeline from this.
- "adaptors" is an ordered tuple of 2-elements tuples, each of which
- has the same parameters you give to the insertadaptor method, except
- 'after' and 'before', because you define the adaptors order in the tuple.
- Example:
- (
- (my_function, lambda x: x in my_list)
- ...
- )
- """
- self.__attribute_names = [ n for n in attribute_names ]
- self.__adaptorspipe = []
- self.pipes = {}
- if adaptors:
- for entry in adaptors:
- self.insertadaptor(compile_pipe=False, *entry)
- self._compile_pipe()
-
- @property
- def adaptors_names(self):
- _adaptors = []
- for a in self.__adaptorspipe:
- _adaptors.append(a.basefunction.func_name)
- return _adaptors
-
- def insertadaptor(self, function, match_function=lambda x: True, compile_pipe=True, after=None, before=None):
- """
- Inserts a "function" as an adaptor that will apply when match_function returns True (by
- default always apply)
- If "after" is given, inserts the adaptor after the already inserted adaptor
- of the name given in this parameter, If "before" is given, inserts it before
- the adaptor of the given name. "name" is the name of the adaptor.
- """
- if function.func_name in self.adaptors_names:
- raise DuplicatedAdaptorName(function.func_name)
- else:
- adaptor = _Adaptor(function, match_function)
- #by default append adaptor at end of pipe
- pos = len(self.adaptors_names)
- if after:
- pos = self.adaptors_names.index(after) + 1
- elif before:
- pos = self.adaptors_names.index(before)
- self.__adaptorspipe.insert(pos, adaptor)
- if compile_pipe:
- self._compile_pipe()
- return pos
-
- def removeadaptor(self, adaptorname):
- pos = self.adaptors_names.index(adaptorname)
- self.__adaptorspipe.pop(pos)
- self._compile_pipe()
-
- def _compile_pipe(self):
- for attrname in self.__attribute_names:
- adaptors_pipe = []
- for adaptor in self.__adaptorspipe:
- if adaptor.match_function(attrname):
- adaptors_pipe.append(adaptor)
- self.pipes[attrname] = adaptors_pipe
-
- def __repr__(self):
- return serialize(self.pipes, "pprint")
\ No newline at end of file
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/closedomain.py b/scrapy/branches/cluster-refactor/scrapy/contrib/closedomain.py
deleted file mode 100644
index bfba4a721..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/closedomain.py
+++ /dev/null
@@ -1,46 +0,0 @@
-"""
-CloseDomain is an extension that forces spiders to be closed after a given
-time has expired.
-
-"""
-import datetime
-import pprint
-
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy import log
-from scrapy.core.engine import scrapyengine
-from scrapy.core.exceptions import NotConfigured
-from scrapy.mail import MailSender
-from scrapy.stats import stats
-from scrapy.conf import settings
-
-class CloseDomain(object):
- def __init__(self):
- self.timeout = settings.getint('CLOSEDOMAIN_TIMEOUT')
- if not self.timeout:
- raise NotConfigured
-
- self.tasks = {}
- self.mail = MailSender()
- self.notify = settings.getlist('CLOSEDOMAIN_NOTIFY')
-
- dispatcher.connect(self.domain_opened, signal=signals.domain_opened)
- dispatcher.connect(self.domain_closed, signal=signals.domain_closed)
-
- def domain_opened(self, domain):
- self.tasks[domain] = scrapyengine.addtask(self.close_domain, self.timeout, args=[domain])
-
- def close_domain(self, domain):
- log.msg("Domain was opened for more than %d seconds, closing it..." % self.timeout, domain=domain)
- scrapyengine.close_domain(domain)
- if self.notify:
- body = "Closed domain %s because it remained opened for more than %s\n\n" % (domain, datetime.timedelta(seconds=self.timeout))
- body += "DOMAIN STATS ------------------------------------------------------\n\n"
- body += pprint.pformat(stats.get(domain, None))
- subj = "Closed domain by timeout: %s" % domain
- self.mail.send(self.notify, subj, body)
-
- def domain_closed(self, domain):
- scrapyengine.removetask(self.tasks[domain])
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/debug.py b/scrapy/branches/cluster-refactor/scrapy/contrib/debug.py
deleted file mode 100644
index 6638960a8..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/debug.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-Extensions for debugging Scrapy
-"""
-import signal
-import traceback
-
-class StackTraceDebug(object):
- def __init__(self):
- try:
- signal.signal(signal.SIGUSR1, self.dump_stacktrace)
- except AttributeError:
- # win32 platforms don't support SIGUSR signals
- pass
-
- def dump_stacktrace(self, signum, frame):
- print "Got signal. Dumping stack trace..."
- traceback.print_stack(frame)
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/cache.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/cache.py
deleted file mode 100644
index 946983361..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/cache.py
+++ /dev/null
@@ -1,194 +0,0 @@
-from __future__ import with_statement
-
-import os
-import sys
-import hashlib
-import datetime
-import urlparse
-import cPickle as pickle
-from pydispatch import dispatcher
-from twisted.internet import defer
-
-from scrapy.core import signals
-from scrapy import log
-from scrapy.core.engine import scrapyengine
-from scrapy.http import Response, Headers
-from scrapy.http.headers import headers_dict_to_raw
-from scrapy.core.exceptions import UsageError, NotConfigured, HttpException, IgnoreRequest
-from scrapy.conf import settings
-
-
-class CacheMiddleware(object):
- def __init__(self):
- if not settings['CACHE2_DIR']:
- raise NotConfigured
- self.cache = Cache(settings['CACHE2_DIR'], sectorize=settings.getbool('CACHE2_SECTORIZE'))
- self.ignore_missing = settings.getbool('CACHE2_IGNORE_MISSING')
- dispatcher.connect(self.open_domain, signal=signals.domain_open)
-
- def open_domain(self, domain):
- self.cache.open_domain(domain)
-
- def process_request(self, request, spider):
- if not is_cacheable(request):
- return
-
- key = request.fingerprint()
- domain = spider.domain_name
- try:
- response = self.cache.retrieve_response(domain, key)
- except:
- log.msg("Corrupt cache for %s" % request.url, log.WARNING)
- response = False
- if response:
- response.cached = True
- if not 200 <= int(response.status) < 300:
- raise HttpException(response.status, None, response)
- return response
- elif self.ignore_missing:
- raise IgnoreRequest("Ignored request not in cache: %s" % request)
-
- def process_response(self, request, response, spider):
- if not is_cacheable(request):
- return response
-
- if isinstance(response, Response) and not response.cached:
- key = request.fingerprint()
- domain = spider.domain_name
- self.cache.store(domain, key, request, response)
-
- return response
-
- def process_exception(self, request, exception, spider):
- if not is_cacheable(request):
- return
-
- if isinstance(exception, HttpException) and isinstance(exception.response, Response):
- key = request.fingerprint()
- domain = spider.domain_name
- self.cache.store(domain,key, request, exception.response)
-
-def is_cacheable(request):
- scheme, _, _, _, _ = urlparse.urlsplit(request.url)
- return scheme in ['http', 'https']
-
-
-class Cache(object):
- DOMAIN_SECTORDIR = 'data'
- DOMAIN_LINKDIR = 'domains'
-
- def __init__(self, cachedir, sectorize=False):
- self.cachedir = cachedir
- self.sectorize = sectorize
-
- self.baselinkpath = os.path.join(self.cachedir, self.DOMAIN_LINKDIR)
- if not os.path.exists(self.baselinkpath):
- os.makedirs(self.baselinkpath)
-
- self.basesectorpath = os.path.join(self.cachedir, self.DOMAIN_SECTORDIR)
- if not os.path.exists(self.basesectorpath):
- os.makedirs(self.basesectorpath)
-
- def domainsectorpath(self, domain):
- sector = hashlib.sha1(domain).hexdigest()[0]
- return os.path.join(self.basesectorpath, sector, domain)
-
- def domainlinkpath(self, domain):
- return os.path.join(self.baselinkpath, domain)
-
- def requestpath(self, domain, key):
- linkpath = self.domainlinkpath(domain)
- return os.path.join(linkpath, key[0:2], key)
-
- def open_domain(self, domain):
- if domain:
- linkpath = self.domainlinkpath(domain)
- if self.sectorize:
- sectorpath = self.domainsectorpath(domain)
- if not os.path.exists(sectorpath):
- os.makedirs(sectorpath)
- if not os.path.exists(linkpath):
- try:
- os.symlink(sectorpath, linkpath)
- except:
- os.makedirs(linkpath) # windows filesystem
- else:
- if not os.path.exists(linkpath):
- os.makedirs(linkpath)
-
- def is_cached(self, domain, key):
- requestpath = self.requestpath(domain, key)
- if os.path.exists(requestpath):
- with open(os.path.join(requestpath, 'pickled_meta'), 'r') as f:
- metadata = pickle.load(f)
- expiration_secs = settings.getint('CACHE2_EXPIRATION_SECS')
- if expiration_secs >= 0:
- if datetime.datetime.utcnow() <= metadata['timestamp'] + datetime.timedelta(seconds=expiration_secs):
- return True
- else:
- log.msg('dropping old cached response from %s' % metadata['timestamp'])
- return False
- else:
- # disabled cache expiration
- return True
- else:
- return False
-
- def retrieve_response(self, domain, key):
- """
- Return response dictionary if request has correspondent cache record;
- return None if not.
- """
- if not self.is_cached(domain, key):
- return None # not cached
-
- requestpath = self.requestpath(domain, key)
- metadata = responsebody = responseheaders = None
- with open(os.path.join(requestpath, 'pickled_meta'), 'r') as f:
- metadata = pickle.load(f)
- with open(os.path.join(requestpath, 'response_body')) as f:
- responsebody = f.read()
- with open(os.path.join(requestpath, 'response_headers')) as f:
- responseheaders = f.read()
-
- url = metadata['url']
- original_url = metadata.get('original_url', url)
- headers = Headers(responseheaders)
- status = metadata['status']
-
- response = Response(domain=domain, url=url, original_url=original_url, headers=headers, status=status, body=responsebody)
- response.cached = True
- return response
-
- def store(self, domain, key, request, response):
- requestpath = self.requestpath(domain, key)
- if not os.path.exists(requestpath):
- os.makedirs(requestpath)
-
- metadata = {
- 'url':request.url,
- 'method': request.method,
- 'status': response.status,
- 'domain': response.domain,
- 'original_url': response.original_url,
- 'timestamp': datetime.datetime.utcnow(),
- }
-
- # metadata
- with open(os.path.join(requestpath, 'meta_data'), 'w') as f:
- f.write(repr(metadata))
- # pickled metadata (to recover without using eval)
- with open(os.path.join(requestpath, 'pickled_meta'), 'w') as f:
- pickle.dump(metadata, f)
- # response
- with open(os.path.join(requestpath, 'response_headers'), 'w') as f:
- f.write(headers_dict_to_raw(response.headers))
- with open(os.path.join(requestpath, 'response_body'), 'w') as f:
- f.write(response.body.get_content())
- # request
- with open(os.path.join(requestpath, 'request_headers'), 'w') as f:
- f.write(headers_dict_to_raw(request.headers))
- if request.body:
- with open(os.path.join(requestpath, 'request_body'), 'w') as f:
- f.write(request.body)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/common.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/common.py
deleted file mode 100644
index 063ea72b7..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/common.py
+++ /dev/null
@@ -1,10 +0,0 @@
-class CommonMiddleware(object):
- """This middleware provides common/basic functionality, and should always
- be enabled"""
-
- def process_request(self, request, spider):
- request.headers.setdefault('Accept-Language', 'en')
- request.headers.setdefault('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
- if request.method == 'POST':
- request.headers.setdefault('Content-Type', 'application/x-www-form-urlencoded')
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/compression.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/compression.py
deleted file mode 100644
index 9b23f33f1..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/compression.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import zlib
-from gzip import GzipFile
-from cStringIO import StringIO
-
-from scrapy.http import Response, ResponseBody
-
-
-class CompressionMiddleware(object):
- """This middleware allows compressed (gzip, deflate) traffic to be
- sent/received from web sites"""
-
- def process_request(self, request, spider):
- request.headers.setdefault('Accept-Encoding', 'gzip,deflate')
-
- def process_response(self, request, response, spider):
- if isinstance(response, Response):
- content_encoding = response.headers.get('Content-Encoding')
- if content_encoding:
- encoding = content_encoding[0].lower()
- raw_body = response.body.get_content()
- declared_encoding = response.body.declared_encoding
- decoded_body = self._decode(raw_body, encoding)
- response.body = ResponseBody(decoded_body, declared_encoding)
- response.headers['Content-Encoding'] = content_encoding[1:]
- return response
-
- def _decode(self, body, encoding):
- if encoding == 'gzip':
- body = GzipFile(fileobj=StringIO(body)).read()
-
- if encoding == 'deflate':
- try:
- body = zlib.decompress(body)
- except zlib.error:
- # ugly hack to work with raw deflate content that may
- # be sent by microsof servers. For more information, see:
- # http://carsten.codimi.de/gzip.yaws/
- # http://www.port80software.com/200ok/archive/2005/10/31/868.aspx
- # http://www.gzip.org/zlib/zlib_faq.html#faq38
- body = zlib.decompress(body, -15)
- return body
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/cookies.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/cookies.py
deleted file mode 100644
index 9816dc521..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/cookies.py
+++ /dev/null
@@ -1,27 +0,0 @@
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy.core.engine import scrapyengine
-from scrapy.utils.misc import dict_updatedefault
-
-class CookiesMiddleware(object):
- """This middleware enables working with sites that need cookies"""
-
- def __init__(self):
- self.cookies = {}
- dispatcher.connect(self.domain_open, signals.domain_open)
- dispatcher.connect(self.domain_closed, signals.domain_closed)
-
- def process_request(self, request, spider):
- dict_updatedefault(request.cookies, self.cookies[spider.domain_name])
-
- def process_response(self, request, response, spider):
- cookies = self.cookies[spider.domain_name]
- cookies.update(request.cookies)
- return response
-
- def domain_open(self, domain):
- self.cookies[domain] = {}
-
- def domain_closed(self, domain):
- del self.cookies[domain]
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/debug.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/debug.py
deleted file mode 100644
index 6e13dc1b8..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/debug.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from scrapy import log
-from scrapy.conf import settings
-
-class CrawlDebug(object):
- def __init__(self):
- self.enabled = settings.getbool('CRAWL_DEBUG')
-
- def process_request(self, request, spider):
- if self.enabled:
- log.msg("Crawling %s" % repr(request), domain=spider.domain_name, level=log.DEBUG)
-
- def process_exception(self, request, exception, spider):
- if self.enabled:
- log.msg("Crawl exception %s in %s" % (exception, repr(request)), domain=spider.domain_name, level=log.DEBUG)
-
- def process_response(self, request, response, spider):
- if self.enabled:
- log.msg("Fetched %s from %s" % (response.info(), repr(request)), domain=spider.domain_name, level=log.DEBUG)
- return response
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/httpauth.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/httpauth.py
deleted file mode 100644
index fcc9ebb8c..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/httpauth.py
+++ /dev/null
@@ -1,8 +0,0 @@
-class HttpAuthMiddleware(object):
- """This middleware allows spiders to use HTTP auth in a cleaner way
- (http_user and http_pass spider class attributes)"""
-
- def process_request(self, request, spider):
- if getattr(spider, 'http_user', None) or getattr(spider, 'http_pass', None):
- request.httpauth(spider.http_user, spider.http_pass)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/redirect.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/redirect.py
deleted file mode 100644
index bc334f08c..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/redirect.py
+++ /dev/null
@@ -1,66 +0,0 @@
-import re
-
-from scrapy import log
-from scrapy.http import Request, Response
-from scrapy.core.exceptions import HttpException
-from scrapy.utils.url import urljoin_rfc as urljoin
-
-class RedirectLoop(Exception):
- pass
-
-META_REFRESH_RE = re.compile(r'<meta[^>]*http-equiv[^>]*refresh[^>].*?(\d+);url=([^"\']+)', re.IGNORECASE)
-# some sites use meta-refresh for redirecting to a session expired page, so we
-# restrict automatic redirection to a maximum delay (in number of seconds)
-META_REFRESH_MAXSEC = 100
-MAX_REDIRECT_LOOP = 10
-
-class RedirectMiddleware(object):
- def process_exception(self, request, exception, spider):
- if isinstance(exception, HttpException):
- status = exception.status
- response = exception.response
-
- if status in ['302', '303']:
- redirected_url = urljoin(request.url, response.headers['location'][0])
- if not getattr(spider, "no_redirect", False):
- redirected = request.copy()
- redirected.url = redirected_url
- redirected.method = 'GET'
- redirected.body = None
- # This is needed to avoid redirection loops with requests that contain dont_filter = True
- # Example (9 May 2008): http://www.55max.com/product/001_photography.asp?3233,0,0,0,Michael+Banks
- if isinstance(redirected.dont_filter, int):
- if not hasattr(redirected, "original_dont_filter"):
- redirected.original_dont_filter = redirected.dont_filter
- if redirected.dont_filter <= -MAX_REDIRECT_LOOP:
- raise RedirectLoop("Exited redirect loop with %s consecutive visits to the same url." % (redirected.original_dont_filter + MAX_REDIRECT_LOOP) )
- redirected.dont_filter -= 1
- else:
- redirected.dont_filter = False
- log.msg("Redirecting (%s) to %s from %s" % (status, redirected, request), level=log.DEBUG, domain=spider.domain_name)
- return redirected
- log.msg("Ignored redirecting (%s) to %s from %s (disabled by spider)" % (status, redirected_url, request), level=log.DEBUG, domain=spider.domain_name)
- return response
-
- if status in ['301', '307']:
- redirected_url = urljoin(request.url, response.headers['location'][0])
- if not getattr(spider, "no_redirect", False):
- redirected = request.copy()
- redirected.url = redirected_url
- # This is needed to avoid redirection loops with requests that contain dont_filter = True
- # Example (9 May 2008): http://www.55max.com/product/001_photography.asp?3233,0,0,0,Michael+Banks
- redirected.dont_filter = False
- log.msg("Redirecting (%s) to %s from %s" % (status, redirected, request), level=log.DEBUG, domain=spider.domain_name)
- return redirected
- log.msg("Ignored redirecting (%s) to %s from %s (disabled by spider)" % (status, redirected_url, request), level=log.DEBUG, domain=spider.domain_name)
- return response
-
- def process_response(self, request, response, spider):
- if isinstance(response, Response):
- m = META_REFRESH_RE.search(response.body.to_string()[0:4096])
- if m and int(m.group(1)) < META_REFRESH_MAXSEC:
- redirected = request.copy()
- redirected.url = urljoin(request.url, m.group(2))
- log.msg("Redirecting (meta refresh) to %s from %s" % (redirected, request), level=log.DEBUG, domain=spider.domain_name)
- return redirected
- return response
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/retry.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/retry.py
deleted file mode 100644
index d21deb160..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/retry.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-An extension to retry failed requests that are potentially caused by temporary
-problems such as a connection timeout or HTTP 500 error.
-
-You can change the behaviour of this moddileware by modifing the scraping settings:
-RETRY_TIMES - how many times to retry a failed page
-RETRY_HTTP_CODES - which HTTP response codes to retry
-
-Failed pages are collected on the scraping process and rescheduled at the end,
-once the spider has finished crawling all regular (non failed) pages. Once
-there is no more failed pages to retry this middleware sends a signal
-(retry_complete), so other extensions could connect to that signal.
-
-Default values are located in scrapy.conf.core_settings
-
-About HTTP errors to consider:
-
-- You may want to remove 400 from RETRY_HTTP_CODES, if you stick to the HTTP
- protocol. It's included by default because it's a common code used to
- indicate server overload, which would be something we want to retry
-- 200 is included by default (and shoudln't be removed) to check for partial
- downloads errors, which means the TCP connection has broken in the middle of
- a HTTP download
-"""
-
-from twisted.internet.error import TimeoutError as ServerTimeoutError, DNSLookupError, \
- ConnectionRefusedError, ConnectionDone, ConnectError
-from twisted.internet.defer import TimeoutError as UserTimeoutError
-
-from scrapy import log
-from scrapy.core.exceptions import HttpException
-from scrapy.conf import settings
-
-class RetryMiddleware(object):
-
- EXCEPTIONS_TO_RETRY = (ServerTimeoutError, UserTimeoutError, DNSLookupError,
- ConnectionRefusedError, ConnectionDone, ConnectError)
-
- def __init__(self):
- self.failed_count = {}
- self.max_retries = settings.getint('RETRY_TIMES')
-
- def process_exception(self, request, exception, spider):
- retry = False
-
- if isinstance(exception, self.EXCEPTIONS_TO_RETRY):
- retry = True
- elif isinstance(exception, HttpException):
- if exception.status in settings.getlist('RETRY_HTTP_CODES'):
- retry = True
-
- if retry:
- fp = request.fingerprint()
- count = self.failed_count[fp] = self.failed_count.get(fp, 0) + 1
-
- if self.failed_count[fp] < self.max_retries:
- log.msg("Retrying %s (failed %d times): %s" % (request, count, exception), level=log.DEBUG, domain=spider.domain_name)
- retryreq = request.copy()
- retryreq.dont_filter = True
- return retryreq
- else:
- log.msg("Discarding %s (failed %d times): %s" % (request, count, exception), domain=spider.domain_name, level=log.DEBUG)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/robots.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/robots.py
deleted file mode 100644
index d4e245eb8..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/robots.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""
-jhis is an expertimental middleware to respect robots.txt policies. The biggest
-problem it has is that it uses urllib directly (in RobotFileParser.read()
-method) and that conflicts with twisted networking, so it should be ported to
-use twisted networking API, but that is not as trivial as it may seem.
-
-This code is left here for future reference, when we resume the work on this
-subject.
-
-"""
-
-import re
-import urlparse
-import robotparser
-
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy import log
-from scrapy.core.exceptions import IgnoreRequest
-from scrapy.conf import settings
-
-BASEURL_RE = re.compile("http://.*?/")
-
-class RobotsMiddleware(object):
-
- def __init__(self):
- self._parsers = {}
- self._spiderdomains = {}
- self._pending = {}
- dispatcher.connect(self.domain_open, signals.domain_open)
- dispatcher.connect(self.domain_closed, signals.domain_closed)
-
- def process_request(self, request, spider):
- agent = getattr(spider, 'user_agent', None) or settings['USER_AGENT']
- rp = self.robot_parser(request.url, spider.domain_name)
- if rp and not rp.can_fetch(agent, request.url):
- raise IgnoreRequest("URL forbidden by robots.txt: %s" % request.url)
-
- def robot_parser(self, url, spiderdomain):
- urldomain = urlparse.urlparse(url).hostname
- if urldomain in self._parsers:
- rp = self._parsers[urldomain]
- else:
- rp = robotparser.RobotFileParser()
- m = BASEURL_RE.search(url)
- if m:
- rp.set_url("%srobots.txt" % m.group())
- rp.read()
- self._parsers[urldomain] = rp
- self._spiderdomains[spiderdomain].add(urldomain)
- return rp
-
- def domain_open(self, domain):
- self._spiderdomains[domain] = set()
-
- def domain_closed(self, domain):
- for urldomain in self._spiderdomains[domain]:
- del self._parsers[urldomain]
- del self._spiderdomains[domain]
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/useragent.py b/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/useragent.py
deleted file mode 100644
index 6bda3e85f..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/useragent.py
+++ /dev/null
@@ -1,7 +0,0 @@
-class UserAgentMiddleware(object):
- """This middleware allows spiders to override the user_agent"""
-
- def process_request(self, request, spider):
- if getattr(spider, 'user_agent', None):
- request.headers.setdefault('User-Agent', spider.user_agent)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/history/middleware.py b/scrapy/branches/cluster-refactor/scrapy/contrib/history/middleware.py
deleted file mode 100644
index 9fae23bdd..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/history/middleware.py
+++ /dev/null
@@ -1,88 +0,0 @@
-import hashlib
-from datetime import datetime
-
-from pydispatch import dispatcher
-
-from scrapy.utils.misc import load_class
-from scrapy.core import signals
-from scrapy import log
-from scrapy.core.exceptions import NotConfigured, IgnoreRequest
-from scrapy.conf import settings
-
-class HistoryMiddleware(object):
- # How often we should re-check links we know about
- MIN_CHECK_DAYS = 4
- # How often we should process pages that have not changed (need to include depth)
- MIN_PROCESS_UNCHANGED_DAYS = 12
-
- def __init__(self):
- historycls = load_class(settings['MEMORYSTORE'])
- if not historycls:
- raise NotConfigured
- self.historydata = historycls()
- dispatcher.connect(self.open_domain, signal=signals.domain_open)
- dispatcher.connect(self.close_domain, signal=signals.domain_closed)
-
- def process_request(self, request, spider):
- key = urlkey(request.url)
- status = self.historydata.status(domain, key)
- if status:
- _url, version, last_checked = status
- d = datetime.now() - last_checked
- if d.days < self.MIN_CHECK_DAYS:
- raise IgnoreRequest("Not scraping %s (scraped %s ago)" % (request.url, d))
- request.context['history_response_version'] = version
-
- def process_response(self, request, response, spider):
- version = request.context.get('history_response_version')
- if version == response.version():
- del request.content['history_response_version']
- hist = self.historydata.version_info(domain, version)
- if hist:
- versionkey, created = hist
- # if versionkey != urlkey(url) this means
- # the same content is available on a different url
- delta = datetime.now() - created
- if delta.days < self.MIN_PROCESS_UNCHANGED_DAYS:
- message = "skipping %s: unchanged for %s" % (response.url, delta)
- raise IgnoreRequest(message)
- self.record_visit(domain, request, response)
- return response
-
- def process_exception(self, request, exception, spider):
- self.record_visit(spider.domain_name, request, None)
-
- def open_domain(self, domain):
- self.historydata.open(domain)
-
- def close_domain(self, domain):
- self.historydata.close_site(domain)
-
- def record_visit(self, domain, request, response):
- """record the fact that the url has been visited"""
- url = request.url
- post_version = hash(request.body)
- key = urlkey(url)
- if response:
- redirect_url = response.url
- parentkey = urlkey(response.request.headers.get('referer')) if response.request else None
- version = response.version()
- else:
- redirect_url, parentkey, version = url, None, None
- self.historydata.store(domain, key, url, parentkey, version, post_version)
-
-
-def urlkey(url):
- """Generate a 'key' for a given url
-
- >>> urlkey("http://www.example.com/")
- '89e6a0649e06d83370cdf2cbfb05f363934a8d0c'
- >>> urlkey("http://www.example.com/") == urlkey("http://www.example.com/?")
- True
- """
- from scrapy.utils.c14n import canonicalize
- return hash(canonicalize(url))
-
-
-def hash(value):
- return hashlib.sha1(value).hexdigest() if value else None
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/history/scheduler.py b/scrapy/branches/cluster-refactor/scrapy/contrib/history/scheduler.py
deleted file mode 100644
index e8f20f032..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/history/scheduler.py
+++ /dev/null
@@ -1,94 +0,0 @@
-from datetime import datetime
-
-from twisted.internet import defer
-
-from scrapy import log
-from scrapy.core.scheduler import Scheduler
-from scrapy.core.exceptions import IgnoreRequest
-
-class RulesScheduler(Scheduler):
- """Scheduler that uses rules to determine if we should follow links
-
- TODO:
- * take into account where in chain of links we are (less depth should
- be crawled more often)
- * Be more strict about scraping product pages that rarely lead to new
- versions of products. The same applies to pages with links. Particularly
- useful for filtering out when there are many urls for the same product.
- (but be careful to also filter out pages that almost always lead to new
- output).
- """
-
- # if these parameters change, then update bin/unavailable.py
-
- # How often we should re-check links we know about
- MIN_CHECK_DAYS = 4
-
- # How often we should process pages that have not changed (need to include depth)
- MIN_PROCESS_UNCHANGED_DAYS = 12
-
- def enqueue_request(self, domain, request, priority=1):
- """Add a page to be scraped for a domain that is currently being scraped.
-
- The url will only be added if we have not checked it already within
- a specified time period.
- """
- requestid = request.fingerprint()
- added = self.groupfilter.add(domain, requestid)
-
- if request.dont_filter or added:
- key = urlkey(request.url) # we can not use fingerprint unless lost crawled history
- status = self.historydata.status(domain, key)
- now = datetime.now()
- version = None
- if status:
- _url, version, last_checked = status
- d = now - last_checked
- if d.days < self.MIN_CHECK_DAYS:
- log.msg("Not scraping %s (scraped %s ago)" % (request.url, d), level=log.DEBUG)
- return
- # put the version in the pending pages to avoid querying DB again
- record = (request, version, now)
- self.pending_requests[domain].put(record, priority)
-
- def next_request(self, domain):
- """Get the next page from the superclass. This will add a callback
- to prevent processing the page unless its content has been
- changed.
-
- In the event that it a page is not processed, the record_visit method
- is called to update the last_checked time.
- """
- pending_list = self.pending_requests.get(domain)
- if not pending_list :
- return None
- request, version, timestamp = pending_list.get_nowait()[1]
- post_version = hash(request.body)
-
- def callback(pagedata):
- """process other callback if we pass the checks"""
- if version == pagedata.version():
- hist = self.historydata.version_info(domain, version)
- if hist:
- versionkey, created = hist
- # if versionkey != urlkey(url) this means
- # the same content is available on a different url
- delta = timestamp - created
- if delta.days < self.MIN_PROCESS_UNCHANGED_DAYS:
- message = "skipping %s: unchanged for %s" % (pagedata.url, delta)
- raise IgnoreRequest(message)
- self.record_visit(domain, request.url, pagedata.url,
- pagedata.parent, pagedata.version(),
- post_version)
- return pagedata
-
- def errback(error) :
- self.record_visit(domain, request.url, request.url, None, None,
- post_version)
- return error
-
- d = defer.Deferred()
- d.addCallbacks(callback, errback)
- request.prepend_callback(d)
-
- return request
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/item/models.py b/scrapy/branches/cluster-refactor/scrapy/contrib/item/models.py
deleted file mode 100644
index 451d90b2a..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/item/models.py
+++ /dev/null
@@ -1,208 +0,0 @@
-"""
-This module contains some extra base models for scraped items which could be
-useful in some Scrapy implementations
-"""
-
-import hashlib
-
-from pprint import PrettyPrinter
-from scrapy.item import ScrapedItem
-from scrapy.core.exceptions import UsageError, DropItem
-
-class ValidationError(DropItem):
- """Indicates a data validation error"""
- def __init__(self,problem,value=None):
- self.problem = problem
- self.value = value
-
- def __str__(self):
- if self.value is not None:
- return '%s "%s"' % (self.problem, self.value)
- else:
- return '%s' % (self.problem)
-
-class ValidationPipeline(object):
- def process_item(self, domain, response, item):
- item.validate()
- return item
-
-class RobustScrapedItem(ScrapedItem):
- """
- A more robust scraped item class with a built-in validation mechanism and
- minimal versioning support
- """
-
- ATTRIBUTES = {
- 'guid': basestring, # a global unique identifier
- 'url': basestring, # the main URL where this item was scraped from
- }
-
- def __init__(self, data=None):
- """
- A scraped item can be initialised with a dictionary that will be
- squirted directly into the object.
- """
- if isinstance(data, dict):
- for attr, value in data.iteritems():
- setattr(self, attr, value)
- elif data is not None:
- raise UsageError("Initialize with dict, not %s" % data.__class__.__name__)
-
- self.__dict__['_version'] = None
-
- def __getattr__(self, attr):
- # Return None for valid attributes not set, raise AttributeError for invalid attributes
- # Note that this method is called only when the attribute is not found in
- # self.__dict__ or the class/instance methods.
- if attr in self.ATTRIBUTES:
- return None
- else:
- raise AttributeError(attr)
-
- def __setattr__(self, attr, value):
- """
- Set an attribute checking it matches the attribute type declared in self.ATTRIBUTES
- """
- if not attr.startswith('_') and attr not in self.ATTRIBUTES:
- raise AttributeError('Attribute "%s" is not a valid attribute name. You must add it to %s.ATTRIBUTES' % (attr, self.__class__.__name__))
-
- if value is None:
- self.__dict__.pop(attr, None)
- return
-
- type1 = self.ATTRIBUTES[attr]
- if hasattr(type1, '__iter__'):
- if not hasattr(value, '__iter__'):
- raise TypeError('Attribute "%s" must be a sequence' % attr)
- type2 = type1[0]
- for i in value:
- if not isinstance(i, type2):
- raise TypeError('Attribute "%s" cannot contain %s, only %s' % (attr, i.__class__.__name__, type2.__name__))
- else:
- if not isinstance(value, type1):
- raise TypeError('Attribute "%s" must be %s, not %s' % (attr, type1.__name__, value.__class__.__name__))
-
- self.__dict__[attr] = value
- self.__dict__['_version'] = None
-
- def __delattr__(self, attr):
- """
- Delete an attribute from the ScrapedItem instance if it exists.
- If not, raise an AttributeError.
- """
- if attr in self.__dict__:
- del self.__dict__[attr]
- self.__dict__['_version'] = None
- else:
- raise AttributeError("Attribute '%s' doesn't exist" % attr)
-
- def __eq__(self, other):
- if isinstance(other, type(self)):
- return self.version == other.version
-
- def __ne__(self, other):
- return self.version != other.version
-
- def __sub__(self, other):
- return RobustItemDelta(other, self)
-
- def __repr__(self):
- # Generate this format so that it can be deserialized easily:
- # ClassName({...})
- reprdict = {}
- for k, v in self.__dict__.iteritems():
- if not k.startswith('_'):
- reprdict[k] = v
- return "%s(%s)" % (self.__class__.__name__, repr(reprdict))
-
- def __str__(self) :
- return "%s: GUID=%s, url=%s" % ( self.__class__.__name__ , self.guid, self.url )
-
- def validate(self):
- """Method used to validate item attributes data"""
- if not self.guid:
- raise ValidationError('A guid is required')
-
- def copy(self):
- """Create a new ScrapedItem object based on the current one"""
- import copy
- return copy.deepcopy(self)
-
- @property
- def version(self):
- """
- Return a (cached) 40 char hash of all the item attributes.
-
- WARNING: This cached version won't work if mutable products are
- modified directly like:
-
- item.features.append('feature')
- """
- if self._version:
- return self._version
- hash_ = hashlib.sha1()
- hash_.update("".join(["".join([n, str(v)]) for n,v in sorted(self.__dict__.iteritems())]))
- return hash_.hexdigest()
-
-
-class RobustItemDelta(object):
- """
- This class represents the difference between
- a pair of RobustScrapedItems.
- """
-
- def __init__(self, old_item, new_item):
- if not isinstance(old_item, RobustScrapedItem) or \
- not isinstance(new_item, RobustScrapedItem):
- raise TypeError("Both arguments must be RobustScrapedItem instances")
-
- if old_item.guid != new_item.guid:
- raise AttributeError("Item GUIDs must be equal in order to create a RobustItemDelta object")
-
- self.old_item = old_item
- self.new_item = new_item
- self.diff = self.do_diff()
-
- def do_diff(self):
- """
- This method should retreive a dictionary
- containing the changes between both items
- as in this example:
-
- >>> delta.do_diff()
- >>> {'attrib': {'new': 'New value', 'old': 'Old value'}, # Common attributes
- 'attrib2': {'new': 'New value 2', 'old': 'Old value 2'},
- 'attrib3': [{'new': 'New list value', 'old': 'Old list value'}, # List attributes
- {'new': 'New list value 2', 'old': 'Old list value 2'}]}
- """
-
- if self.old_item == self.new_item:
- return {}
-
- diff = {}
- for key, value in self.old_item.__dict__.items():
- if key in self.old_item.ATTRIBUTES.keys():
- new_value = getattr(self.new_item, key)
- if value != new_value:
- diff[key] = {'new': new_value, 'old': value}
- for key, value in self.new_item.__dict__.items():
- if value and key in self.new_item.ATTRIBUTES.keys():
- if not getattr(self.old_item, key):
- diff[key] = {'new': value, 'old': None}
- return diff
-
- def __eq__(self, other):
- if isinstance(other, RobustItemDelta):
- if other.old_item == self.old_item and \
- other.new_item == self.new_item and \
- other.diff == self.diff:
- return True
- return False
-
- def __repr__(self):
- if self.diff:
- pp = PrettyPrinter(indent=3)
- return pp.pformat(self.diff)
- else:
- return 'No differences found between the provided items.'
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/memdebug.py b/scrapy/branches/cluster-refactor/scrapy/contrib/memdebug.py
deleted file mode 100644
index a73801a07..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/memdebug.py
+++ /dev/null
@@ -1,69 +0,0 @@
-import pprint
-import gc
-import socket
-
-import libxml2
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy.core.exceptions import NotConfigured
-from scrapy.mail import MailSender
-from scrapy.stats import stats
-from scrapy.extension import extensions
-from scrapy.conf import settings
-
-class MemoryDebugger(object):
-
- def __init__(self):
- if not settings.getbool('MEMDEBUG_ENABLED'):
- raise NotConfigured
-
- self.mail = MailSender()
- self.rcpts = settings.getlist('MEMDEBUG_NOTIFY')
-
- self.domains_scraped = []
- dispatcher.connect(self.domain_opened, signals.domain_opened)
- dispatcher.connect(self.engine_started, signals.engine_started)
- dispatcher.connect(self.engine_stopped, signals.engine_stopped)
-
- def engine_started(self):
- libxml2.debugMemory(1)
-
- def engine_stopped(self):
- figures = self.collect_figures()
- report = self.create_report(figures)
- self.print_or_send_report(report)
-
- def collect_figures(self):
- libxml2.cleanupParser()
- gc.collect()
-
- figures = []
- if 'MemoryUsage' in extensions.enabled:
- memusage = extensions.enabled['MemoryUsage']
- memusage.update()
- figures.append(("Memory usage at startup", int(memusage.data['startup']/1024/1024), "Mb"))
- figures.append(("Maximum memory usage", int(memusage.data['max']/1024/1024), "Mb"))
- figures.append(("Memory usage at shutdown", int(memusage.virtual/1024/1024), "Mb"))
- figures.append(("Objects in gc.garbage", len(gc.garbage), ""))
- figures.append(("libxml2 memory leak", libxml2.debugMemory(1), "bytes"))
- return figures
-
- def create_report(self, figures):
- s = ""
- s += "SCRAPY MEMORY DEBUGGER RESULTS\n\n"
- for f in figures:
- s += "%-30s : %s %s\n" % f
- s += "\n"
- if stats:
- s += "SCRAPING STATS --------------------------------------------------\n\n"
- s += pprint.pformat(stats)
- return s
-
- def print_or_send_report(self, report):
- if self.rcpts:
- self.mail.send(self.rcpts, "Scrapy Memory Debugger results at %s" % socket.gethostname(), report)
- print report
-
- def domain_opened(self, domain):
- self.domains_scraped.append(domain)
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/memusage.py b/scrapy/branches/cluster-refactor/scrapy/contrib/memusage.py
deleted file mode 100644
index 760e92314..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/memusage.py
+++ /dev/null
@@ -1,122 +0,0 @@
-import sys
-import os
-import pprint
-import socket
-
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy import log
-from scrapy.core.manager import scrapymanager
-from scrapy.core.engine import scrapyengine
-from scrapy.core.exceptions import NotConfigured
-from scrapy.mail import MailSender
-from scrapy.stats import stats
-from scrapy.conf import settings
-
-class MemoryUsage(object):
-
- _proc_status = '/proc/%d/status' % os.getpid()
- _scale = {'kB': 1024.0, 'mB': 1024.0*1024.0,
- 'KB': 1024.0, 'MB': 1024.0*1024.0}
-
- def __init__(self):
- if not settings.getbool('MEMUSAGE_ENABLED'):
- raise NotConfigured
- if sys.platform != 'linux2':
- raise NotConfigured("MemoryUsage extension is only available on Linux")
-
- self.warned = False
-
- self.data = {}
- self.data['startup'] = 0
- self.data['max'] = 0
-
- scrapyengine.addtask(self.update, 60.0, now=True)
-
- self.notify_mails = settings.getlist('MEMUSAGE_NOTIFY')
- self.limit = settings.getint('MEMUSAGE_LIMIT_MB')*1024*1024
- self.warning = settings.getint('MEMUSAGE_WARNING_MB')*1024*1024
- self.report = settings.getbool('MEMUSAGE_REPORT')
-
- if self.limit:
- scrapyengine.addtask(self._check_limit, 60.0, now=True)
- if self.warning:
- scrapyengine.addtask(self._check_warning, 60.0, now=True)
-
- self.mail = MailSender()
-
- dispatcher.connect(self.engine_started, signal=signals.engine_started)
-
-
- @property
- def virtual(self):
- return self._vmvalue('VmSize:')
-
- @property
- def resident(self):
- return self._vmvalue('VmRSS:')
-
- @property
- def stacksize(self):
- return self._vmvalue('VmStk:')
-
- def engine_started(self):
- self.data['startup'] = self.virtual
-
- def update(self):
- if self.virtual > self.data['max']:
- self.data['max'] = self.virtual
-
- def _vmvalue(self, VmKey):
- # get pseudo file /proc/<pid>/status
- try:
- t = open(self._proc_status)
- v = t.read()
- t.close()
- except:
- return 0.0 # non-Linux?
- # get VmKey line e.g. 'VmRSS: 9999 kB\n ...'
- i = v.index(VmKey)
- v = v[i:].split(None, 3) # whitespace
- if len(v) < 3:
- return 0.0 # invalid format?
- # convert Vm value to bytes
- return float(v[1]) * self._scale[v[2]]
-
- def _check_limit(self):
- if self.virtual > self.limit:
- mem = self.limit/1024/1024
- log.msg("Memory usage exceeded %dM. Shutting down Scrapy..." % mem, level=log.ERROR)
- if self.notify_mails:
- subj = "%s terminated: memory usage exceeded %dM at %s" % (settings['BOT_NAME'], mem, socket.gethostname())
- self._send_report(self.notify_mails, subj)
- scrapymanager.stop()
-
- def _check_warning(self):
- if self.warned: # warn only once
- return
- if self.virtual > self.warning:
- mem = self.warning/1024/1024
- log.msg("Memory usage reached %dM" % mem, level=log.WARNING)
- if self.notify_mails:
- subj = "%s warning: memory usage reached %dM at %s" % (settings['BOT_NAME'], mem, socket.gethostname())
- self._send_report(self.notify_mails, subj)
- self.warned = True
-
- def _send_report(self, rcpts, subject):
- """send notification mail with some additional useful info"""
- s = "Memory usage at engine startup : %dM\r\n" % (self.data['startup']/1024/1024)
- s += "Maximum memory usage : %dM\r\n" % (self.data['max']/1024/1024)
- s += "Current memory usage : %dM\r\n" % (self.virtual/1024/1024)
-
- s += "ENGINE STATUS ------------------------------------------------------- \r\n"
- s += "\r\n"
- s += scrapyengine.getstatus()
- s += "\r\n"
-
- if stats:
- s += "SCRAPING STATS ------------------------------------------------------ \r\n"
- s += "\r\n"
- s += pprint.pformat(stats)
- self.mail.send(rcpts, subject, s)
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/images.py b/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/images.py
deleted file mode 100644
index e9f06cc03..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/images.py
+++ /dev/null
@@ -1,181 +0,0 @@
-import re
-import os
-import time
-import hashlib
-import urllib
-import urlparse
-from cStringIO import StringIO
-
-import Image
-
-from scrapy import log
-from scrapy.stats import stats
-from scrapy.core.exceptions import DropItem, NotConfigured
-from scrapy.core.exceptions import HttpException
-from scrapy.conf import settings
-
-from scrapy.contrib.pipeline.media import MediaPipeline
-
-# the age at which we download images again
-IMAGE_EXPIRES = settings.getint('IMAGES_EXPIRES', 90)
-
-class NoimagesDrop(DropItem):
- pass
-
-class ImageException(Exception):
- """General image error exception"""
-
-
-class ImagesPipeline(MediaPipeline):
- MEDIA_TYPE = 'image'
- THUMBS = None
-# THUMBS = (
-# ("50", (50, 50)),
-# ("110", (110, 110)),
-# ("270", (270, 270))
-# )
- MIN_WIDTH = 0
- MIN_HEIGHT = 0
-
- def __init__(self):
- if not settings['IMAGES_DIR']:
- raise NotConfigured
-
- self.BASEDIRNAME = settings['IMAGES_DIR']
- self.mkdir(self.BASEDIRNAME)
-
- self.MIN_WIDTH = settings.getint('IMAGES_MIN_WIDTH', 0)
- self.MIN_HEIGHT = settings.getint('IMAGES_MIN_HEIGHT', 0)
- MediaPipeline.__init__(self)
-
- def media_to_download(self, request, info):
- relative, absolute = self._get_paths(request)
- if not should_download(absolute):
- self.inc_stats(info.domain, 'uptodate')
- referer = request.headers.get('Referer')
- log.msg('Image (uptodate): Downloaded %s from %s referred in <%s>' % \
- (self.MEDIA_TYPE, request, referer), level=log.DEBUG, domain=info.domain)
- return relative
-
- def media_downloaded(self, response, request, info):
- mtype = self.MEDIA_TYPE
- referer = request.headers.get('Referer')
-
- if not response or not response.body.to_string():
- msg = 'Image (empty): Empty %s (no content) in %s referred in <%s>: Empty image (no-content)' % (mtype, request, referer)
- log.msg(msg, level=log.WARNING, domain=info.domain)
- raise ImageException(msg)
-
- result = self.save_image(response, request, info) # save and thumbs response
-
- status = 'cached' if getattr(response, 'cached', False) else 'downloaded'
- msg = 'Image (%s): Downloaded %s from %s referred in <%s>' % (status, mtype, request, referer)
- log.msg(msg, level=log.DEBUG, domain=info.domain)
- self.inc_stats(info.domain, status)
- return result
-
- def media_failed(self, failure, request, info):
- referer = request.headers.get('Referer')
- errmsg = str(failure.value) if isinstance(failure.value, HttpException) else str(failure)
- msg = 'Image (http-error): Error downloading %s from %s referred in <%s>: %s' % (self.MEDIA_TYPE, request, referer, errmsg)
- log.msg(msg, level=log.WARNING, domain=info.domain)
- raise ImageException(msg)
-
- def save_image(self, response, request, info):
- mtype = self.MEDIA_TYPE
- relpath, abspath = self._get_paths(request)
- dirname = os.path.dirname(abspath)
- self.mkdir(dirname, info)
-
- try:
- save_image_with_thumbnails(response, abspath, self.THUMBS, self.MIN_WIDTH, self.MIN_HEIGHT)
- except ImageException, ex:
- log.msg(str(ex), level=log.WARNING, domain=info.domain)
- raise ex
- except Exception, ex:
- referer = request.headers.get('Referer')
- msg = 'Image (processing-error): Error thumbnailing %s from %s referred in <%s>: %s' % (mtype, request, referer, ex)
- log.msg(msg, level=log.WARNING, domain=info.domain)
- raise ImageException(msg)
-
- return relpath # success value sent as input result for item_media_downloaded
-
- def _get_paths(self, request):
- relative = image_path(request.url)
- absolute = os.path.join(self.BASEDIRNAME, relative)
- return relative, absolute
-
- def mkdir(self, dirname, info=None):
- already_created = info.extra.setdefault('created_directories', set()) if info else set()
- if dirname not in already_created:
- if not os.path.exists(dirname):
- os.makedirs(dirname)
- already_created.add(dirname)
-
- def inc_stats(self, domain, status):
- stats.incpath('%s/image_count' % domain)
- stats.incpath('%s/image_status_count/%s' % (domain, status))
-
-
-
-def should_download(path):
- """Should the image downloader download the image to the location specified
- """
- try:
- mtime = os.path.getmtime(path)
- age_seconds = time.time() - mtime
- age_days = age_seconds / 60 / 60 / 24
- return age_days > IMAGE_EXPIRES
- except:
- return True
-
-_MULTIPLE_SLASHES_REGEXP = re.compile(r"\/{2,}")
-_FINAL_SLASH_REGEXP = re.compile(r"\/$")
-def image_path(url):
- """Return the relative path on the target filesystem for an image to be
- downloaded to.
- """
- _, netloc, urlpath, query, _ = urlparse.urlsplit(url)
- urlpath = _MULTIPLE_SLASHES_REGEXP.sub('/', urlpath)
- urlpath = _FINAL_SLASH_REGEXP.sub('.jpg', urlpath)
- if os.sep != '/':
- urlpath.replace('/', os.sep)
- if query:
- img_path = os.path.join(netloc, hashlib.sha1(url).hexdigest())
- else:
- img_path = os.path.join(netloc, urlpath[1:])
- return urllib.unquote(img_path)
-
-
-def thumbnail_name(image, sizestr):
- """Get the name of a thumbnail image given the name of the original file.
-
- There will can be many types of thumbnails, so we will have a "name" for
- each type.
- """
- return os.path.splitext(image)[0] + '_' + sizestr + '.jpg'
-
-def save_scaled_image(image, img_path, name, size):
- thumb = image.copy() if image.mode == 'RGB' else image.convert('RGB')
- thumb.thumbnail(size, Image.ANTIALIAS)
- filename = thumbnail_name(img_path, name)
- thumb.save(filename, 'JPEG')
-
-def save_image_with_thumbnails(response, path, thumbsizes, min_width=0, min_height=0):
- memoryfile = StringIO(response.body.to_string())
- im = Image.open(memoryfile)
- if im.mode != 'RGB':
- log.msg("Found non-RGB image during scraping %s" % path, level=log.WARNING)
- for name, size in thumbsizes or []:
- save_scaled_image(im, path, name, size)
- try:
- im.save(path)
- except Exception, ex:
- log.msg("Image (processing-error): cannot process %s, so writing direct file: Error: %s" % (path, ex))
- f = open(path, 'wb')
- f.write(response.body.to_string())
- f.close()
- width, height = im.size
- if width < min_width or height < min_height:
- raise ImageException("Image too small (%dx%d < %dx%d): %s" % (width, height, min_width, min_height, response.url))
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/media.py b/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/media.py
deleted file mode 100644
index 0c5c59d2c..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/media.py
+++ /dev/null
@@ -1,179 +0,0 @@
-from twisted.internet import defer
-
-from scrapy.utils.defer import mustbe_deferred, defer_result
-from scrapy import log
-from scrapy.core.engine import scrapyengine
-from scrapy.spider import spiders
-
-
-class DomainInfo(object):
- def __init__(self, domain):
- self.domain = domain
- self.spider = spiders.fromdomain(domain)
- self.downloading = {}
- self.downloaded = {}
- self.waiting = {}
- self.extra = {}
-
-
-class MediaPipeline(object):
- def __init__(self):
- self.domaininfo = {}
-
- def open_domain(self, domain):
- self.domaininfo[domain] = DomainInfo(domain)
-
- def close_domain(self, domain):
- del self.domaininfo[domain]
-
- def process_item(self, domain, response, item):
- info = self.domaininfo[domain]
- requests = self.get_media_requests(item, info)
- assert requests is None or hasattr(requests, '__iter__'), \
- 'get_media_requests should return None or iterable'
-
- def _bugtrap(_failure, request):
- log.msg('Unhandled ERROR in MediaPipeline.item_media_{downloaded,failed} for %s: %s' % (request, _failure), log.ERROR, domain=domain)
-
- lst = []
- for request in requests or ():
- dfd = self._enqueue(request, info)
- dfd.addCallbacks(
- callback=self.item_media_downloaded,
- callbackArgs=(item, request, info),
- errback=self.item_media_failed,
- errbackArgs=(item, request, info),
- )
- dfd.addErrback(_bugtrap, request)
- lst.append(dfd)
-
- dlst = defer.DeferredList(lst, consumeErrors=False)
- dlst.addBoth(lambda _: self.item_completed(item, info))
- return dlst
-
- def _enqueue(self, request, info):
- wad = request.deferred or defer.Deferred()
-
- fp = request.fingerprint()
- if fp in info.downloaded:
- cached = info.downloaded[fp]
- defer_result(cached).chainDeferred(wad)
- else:
- info.waiting.setdefault(fp, []).append(wad)
- if fp not in info.downloading:
- self._download(request, info, fp)
-
- return wad
-
- def _download(self, request, info, fp):
- def _bugtrap(_failure):
- log.msg('Unhandled ERROR in MediaPipeline._downloaded: %s' % (_failure), log.ERROR, domain=info.domain)
-
- result = self.media_to_download(request, info)
- if result is not None:
- dwld = defer_result(result)
- else:
- dwld = mustbe_deferred(self.download, request, info)
- dwld.addCallbacks(
- callback=self.media_downloaded,
- callbackArgs=(request, info),
- errback=self.media_failed,
- errbackArgs=(request, info),
- )
-
- dwld.addBoth(self._downloaded, info, fp)
- dwld.addErrback(_bugtrap)
- info.downloading[fp] = (request, dwld)
-
- def _downloaded(self, result, info, fp):
- info.downloaded[fp] = result # cache result
- waiting = info.waiting[fp] # client list
- del info.waiting[fp]
- del info.downloading[fp]
- for wad in waiting:
- defer_result(result).chainDeferred(wad)
-
-
- ### Overradiable Interface
- def download(self, request, info):
- """ Defines how to request the download of media
-
- Default gives high priority to media requests and use scheduler,
- shouldn't be necessary to override.
-
- This methods is called only if result for request isn't cached,
- request fingerprint is used as cache key.
-
- """
- return scrapyengine.schedule(request, info.spider, priority=0)
-
- def media_to_download(self, request, info):
- """ Ongoing request hook pre-cache
-
- This method is called every time a media is requested for download, and
- only once for the same request because return value is cached as media
- result.
-
- returning a non-None value implies:
- - the return value is cached and piped into `item_media_downloaded` or `item_media_failed`
- - prevents downloading, this means calling `download` method.
- - `media_downloaded` or `media_failed` isn't called.
-
- """
-
- def get_media_requests(self, item, info):
- """ Return a list of Request objects to download for this item
-
- Should return None or an iterable
-
- Defaults return None (no media to download)
-
- """
-
- def media_downloaded(self, response, request, info):
- """ Method called on success download of media request
-
- Return value is cached and used as input for `item_media_downloaded` method.
- Default implementation returns None.
-
- WARNING: returning the response object can eat your memory.
-
- """
-
- def media_failed(self, failure, request, info):
- """ Method called when media request failed due to any kind of download error.
-
- Return value is cached and used as input for `item_media_failed` method.
- Default implementation returns same Failure object.
- """
- return failure
-
- def item_media_downloaded(self, result, item, request, info):
- """ Method to handle result of requested media for item.
-
- result is the return value of `media_downloaded` hook, or the non-Failure instance
- returned by `media_failed` hook.
-
- return value of this method isn't important and is recommended to return None.
- """
-
- def item_media_failed(self, failure, item, request, info):
- """ Method to handle failed result of requested media for item.
-
- result is the returned Failure instance of `media_failed` hook, or Failure instance
- of an exception raised by `media_downloaded` hook.
-
- return value of this method isn't important and is recommended to return None.
- """
-
- def item_completed(self, item, info):
- """ Method called when all media requests for a single item has returned a result or failure.
-
- The return value of this method is used as output of pipeline stage.
-
- `item_completed` can return item itself or raise DropItem exception.
-
- Default returns item
- """
- return item
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/s3images.py b/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/s3images.py
deleted file mode 100644
index 573daf294..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/s3images.py
+++ /dev/null
@@ -1,154 +0,0 @@
-import time
-import hashlib
-import rfc822
-from cStringIO import StringIO
-
-import Image
-import boto
-
-from scrapy import log
-from scrapy.stats import stats
-from scrapy.core.exceptions import DropItem, NotConfigured
-from scrapy.core.exceptions import HttpException
-from scrapy.contrib.pipeline.media import MediaPipeline
-from scrapy.conf import settings
-
-class NoimagesDrop(DropItem):
- """Product with no images exception"""
-
-class ImageException(Exception):
- """General image error exception"""
-
-class S3ImagesPipeline(MediaPipeline):
- MEDIA_TYPE = 'image'
- THUMBS = (
- ("50", (50, 50)),
- ("110", (110, 110)),
- ("270", (270, 270))
- )
-
- def __init__(self):
- if not settings['S3_IMAGES']:
- raise NotConfigured
-
- # days to wait before redownloading images
- self.image_refresh_days = settings.getint('IMAGES_REFRESH_DAYS', 90)
-
- self.bucket_name = settings['S3_BUCKET']
- self.prefix = settings['S3_PREFIX']
- access_key = settings['AWS_ACCESS_KEY_ID']
- secret_key = settings['AWS_SECRET_ACCESS_KEY']
- conn = boto.connect_s3(access_key, secret_key)
- self.bucket = conn.get_bucket(self.bucket_name)
-
- MediaPipeline.__init__(self)
-
- def media_to_download(self, request, info):
- key = self.s3_image_key(request.url)
- if not self.s3_should_download(request.url):
- self.inc_stats(info.domain, 'uptodate')
- referer = request.headers.get('Referer')
- log.msg('Image (uptodate) type=%s at <%s> referred from <%s>' % \
- (self.MEDIA_TYPE, request.url, referer), level=log.DEBUG, domain=info.domain)
- return key
-
- def media_downloaded(self, response, request, info):
- mtype = self.MEDIA_TYPE
- referer = request.headers.get('Referer')
-
- if not response or not response.body.to_string():
- msg = 'Image (empty): Empty %s (no content) in %s referred in <%s>: Empty image (no-content)' % (mtype, request, referer)
- log.msg(msg, level=log.WARNING, domain=info.domain)
- raise ImageException(msg)
-
- result = self.save_image(response, request, info) # save and thumbs response
-
- status = 'cached' if getattr(response, 'cached', False) else 'downloaded'
- msg = 'Image (%s): Downloaded %s from %s referred in <%s>' % (status, mtype, request, referer)
- log.msg(msg, level=log.DEBUG, domain=info.domain)
- self.inc_stats(info.domain, status)
- return result
-
- def media_failed(self, failure, request, info):
- referer = request.headers.get('Referer')
- errmsg = str(failure.value) if isinstance(failure.value, HttpException) else str(failure)
- msg = 'Image (http-error): Error downloading %s from %s referred in <%s>: %s' % (self.MEDIA_TYPE, request, referer, errmsg)
- log.msg(msg, level=log.WARNING, domain=info.domain)
- raise ImageException(msg)
-
- def save_image(self, response, request, info):
- try:
- key = self.s3_image_key(request.url)
- self.s3_store_image(response, request.url)
- except ImageException, ex:
- log.msg(str(ex), level=log.WARNING, domain=info.domain)
- raise ex
- except Exception, ex:
- log.msg(str(ex), level=log.WARNING, domain=info.domain)
- raise ex
-
- return key # success value sent as input result for item_media_downloaded
-
- def inc_stats(self, domain, status):
- stats.incpath('%s/image_count' % domain)
- stats.incpath('%s/image_status_count/%s' % (domain, status))
-
- def s3_image_key(self, url):
- """Return the relative path on the target filesystem for an image to be
- downloaded to.
- """
- image_guid = hashlib.sha1(url).hexdigest()
- return '%s/full/%s.jpg' % (self.prefix, image_guid)
-
- def s3_thumb_key(self, url, thumb_id):
- """Return the relative path on the target filesystem for an image to be
- downloaded to.
- """
- image_guid = hashlib.sha1(url).hexdigest()
- return '%s/thumbs/%s/%s.jpg' % (self.prefix, thumb_id, image_guid)
-
- def s3_should_download(self, url):
- """Return if the image should be downloaded by checking if it's already in
- the S3 storage and not too old"""
- key = self.s3_image_key(url)
- k = self.bucket.get_key(key)
- if k is None:
- return True
- modified_tuple = rfc822.parsedate_tz(k.last_modified)
- modified_stamp = int(rfc822.mktime_tz(modified_tuple))
- age_seconds = time.time() - modified_stamp
- age_days = age_seconds / 60 / 60 / 24
- return age_days > self.image_refresh_days
-
- def s3_store_image(self, response, url):
- """Upload image to S3 storage"""
- buf = StringIO(response.body.to_string())
- image = Image.open(buf)
- key = self.s3_image_key(url)
- self._s3_put_image(image, key)
- self.s3_store_thumbnails(image, url)
-
- def s3_store_thumbnails(self, image, url):
- """Upload image thumbnails to S3 storage"""
- for thumb_id, size in self.THUMBS or []:
- thumb = image.copy() if image.mode == 'RGB' else image.convert('RGB')
- thumb.thumbnail(size, Image.ANTIALIAS)
- key = self.s3_thumb_key(url, thumb_id)
- self._s3_put_image(thumb, key)
-
- def s3_public_url(self, key):
- return "http://%s.s3.amazonaws.com/%s" % (self.bucket_name, key)
-
- def _s3_put_image(self, image, key):
- buf = StringIO()
- try:
- image.save(buf, 'JPEG')
- except Exception, ex:
- raise ImageException("Cannot process image. Error: %s" % ex)
-
- buf.seek(0)
- k = self.bucket.new_key(key)
- k.content_type = 'image/jpeg'
- k.set_contents_from_file(buf, policy='public-read')
- log.msg("Uploaded to S3: %s" % self.s3_public_url(key), level=log.DEBUG)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/shoveitem.py b/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/shoveitem.py
deleted file mode 100644
index e4050bf88..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/shoveitem.py
+++ /dev/null
@@ -1,37 +0,0 @@
-"""
-A pipeline to persist objects using shove.
-
-New is a "new generation" shelve. For more information see:
-http://pypi.python.org/pypi/shove
-"""
-
-from string import Template
-
-from shove import Shove
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy.conf import settings
-
-class ShoveItemPipeline(object):
-
- def __init__(self):
- self.uritpl = settings['SHOVEITEM_STORE_URI']
- if not self.uritpl:
- raise NotConfigured
- self.opts = settings['SHOVEITEM_STORE_OPT'] or {}
- self.stores = {}
-
- dispatcher.connect(self.domain_open, signal=signals.domain_open)
- dispatcher.connect(self.domain_closed, signal=signals.domain_closed)
-
- def process_item(self, domain, response, item):
- self.stores[domain][str(item.guid)] = item
- return item
-
- def domain_open(self, domain):
- uri = Template(self.uritpl).substitute(domain=domain)
- self.stores[domain] = Shove(uri, **self.opts)
-
- def domain_closed(self, domain):
- self.stores[domain].sync()
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/show.py b/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/show.py
deleted file mode 100644
index f08234be6..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/show.py
+++ /dev/null
@@ -1,15 +0,0 @@
-"""
-Pipeline to print Items
-"""
-from scrapy import log
-from scrapy.core.exceptions import NotConfigured
-from scrapy.conf import settings
-
-class ShowItemPipeline(object):
- def __init__(self):
- if not settings['DEBUG_SHOWITEM']:
- raise NotConfigured
-
- def process_item(self, domain, response, item):
- log.msg("Scraped: \n%s" % repr(item), log.DEBUG, domain=domain)
- return item
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/response/soup.py b/scrapy/branches/cluster-refactor/scrapy/contrib/response/soup.py
deleted file mode 100644
index 9708b21fe..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/response/soup.py
+++ /dev/null
@@ -1,26 +0,0 @@
-"""
-The ResponseSoup extension causes the Response objects to grow a new method
-("getsoup") which returns a (cached) BeautifulSoup object of its body, and a
-"soup" attribute with the same effect. The soup argument is provided for
-convenience, but you cannot pass any BeautifulSoup constructor arguments (which
-you can do with the getsoup() method).
-
-For more information about BeautifulSoup see:
-http://www.crummy.com/software/BeautifulSoup/documentation.html
-"""
-
-from BeautifulSoup import BeautifulSoup
-
-from scrapy.http import Response
-
-
-class ResponseSoup(object):
- def __init__(self):
- setattr(Response, 'getsoup', getsoup)
- setattr(Response, 'soup', property(getsoup))
-
-def getsoup(response, **kwargs):
- if not hasattr(response, '_soup'):
- body = response.body.to_string() if response.body is not None else ""
- setattr(response, '_soup', BeautifulSoup(body, **kwargs))
- return response._soup
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/depth.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/depth.py
deleted file mode 100644
index 1727052c2..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/depth.py
+++ /dev/null
@@ -1,36 +0,0 @@
-"""
-DepthMiddleware is a scrape middleware used for tracking the depth of each
-Request inside the site being scraped. It can be used to limit the maximum
-depth to scrape or things like that
-"""
-
-from scrapy import log
-from scrapy.http import Request
-from scrapy.stats import stats
-from scrapy.conf import settings
-
-class DepthMiddleware(object):
-
- def __init__(self):
- self.maxdepth = settings.getint('DEPTH_LIMIT')
- self.stats = settings.getbool('DEPTH_STATS')
- if self.stats and self.maxdepth:
- stats.setpath('_envinfo/request_depth_limit', self.maxdepth)
-
- def process_result(self, response, result, spider):
- def _filter(request):
- if isinstance(request, Request):
- request.depth = response.request.depth + 1
- if self.maxdepth and request.depth > self.maxdepth:
- log.msg("Ignoring link (depth > %d): %s " % (self.maxdepth, request.url), level=log.DEBUG, domain=spider.domain_name)
- return False
- elif self.stats:
- stats.incpath('%s/request_depth_count/%s' % (spider.domain_name, request.depth))
- if request.depth > stats.getpath('%s/request_depth_max' % spider.domain_name, 0):
- stats.setpath('%s/request_depth_max' % spider.domain_name, request.depth)
- return True
-
- if self.stats and response.request.depth == 0: # otherwise we loose stats for depth=0
- stats.incpath('%s/request_depth_count/0' % spider.domain_name)
-
- return (r for r in result or () if _filter(r))
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/limit.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/limit.py
deleted file mode 100644
index fedc7d2d1..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/limit.py
+++ /dev/null
@@ -1,37 +0,0 @@
-"""
-RequestLimitMiddleware: Limits the scheduler request queue from the point of
-view of the spider. That is, if the scheduler queue contains an equal or
-greater ammount of requests than the specified limit, the new requests
-(generated by the spider) will be ignored.
-
-The limit is setted from the spider attribute "requests_queue_size". If not
-found, from the scrapy setting "REQUESTS_QUEUE_SIZE". If not found, no limit
-will be applied. If given a value of 0, no limit will be applied.
-"""
-
-from scrapy.core.engine import scrapyengine
-from scrapy.conf import settings
-from scrapy.http import Request
-from scrapy import log
-
-class RequestLimitMiddleware(object):
- #_last_queue_size = 0
- def process_result(self, response, result, spider):
- requests = []
- other = []
- [requests.append(r) if isinstance(r, Request) else other.append(r) for r in result]
-
- max_pending = spider.requests_queue_size if hasattr(spider,"requests_queue_size") else settings.getint("REQUESTS_QUEUE_SIZE")
- if not max_pending:
- accepted = requests
- else:
- free_slots = max_pending - len(scrapyengine.scheduler.pending_requests[spider.domain_name])
- accepted = requests[:free_slots]
- dropped = set(requests) - set(accepted)
- if dropped:
- for r in dropped:
- log.msg("Ignoring link (max schedule queue size reached): %s " % r.url, level=log.WARNING, domain=spider.domain_name)
- #actual_size = len(scrapyengine.scheduler.pending_requests[spider.domain_name])
- #log.msg("queue size: %d (%+d)" % (actual_size, actual_size - self._last_queue_size) )
- #self._last_queue_size = actual_size
- return accepted + other
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/offsite.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/offsite.py
deleted file mode 100644
index 7a0644d04..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/offsite.py
+++ /dev/null
@@ -1,18 +0,0 @@
-"""
-OffsiteMiddleware: Filters out Requests for URLs outside the domains covered by
-the spider.
-"""
-
-from scrapy import log
-from scrapy.http import Request
-from scrapy.utils.url import url_is_from_spider
-
-class OffsiteMiddleware(object):
- def process_result(self, response, result, spider):
- def _filter(r):
- if isinstance(r, Request) and not url_is_from_spider(r.url, spider):
- log.msg("Ignoring link (offsite): %s " % r.url, level=log.DEBUG, domain=spider.domain_name)
- return False
- return True
- return (r for r in result or () if _filter(r))
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/referer.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/referer.py
deleted file mode 100644
index ee05f6918..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/referer.py
+++ /dev/null
@@ -1,15 +0,0 @@
-"""
-RefererMiddleware: populates Request referer field, based on the Response which
-originated it.
-"""
-
-from scrapy.http import Request
-
-class RefererMiddleware(object):
- def process_result(self, response, result, spider):
- def _set_referer(r):
- if isinstance(r, Request):
- r.headers.setdefault('Referer', response.url)
- return r
- return (_set_referer(r) for r in result or ())
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/restrict.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/restrict.py
deleted file mode 100644
index b4eceef31..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/restrict.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""
-RestrictMiddleware: restricts crawling to fixed set of particular URLs
-"""
-
-from scrapy.http import Request
-from scrapy.core.exceptions import NotConfigured
-from scrapy.conf import settings
-
-class RestrictMiddleware(object):
- def __init__(self):
- self.allowed_urls = set(settings.getlist('RESTRICT_TO_URLS'))
- if not self.allowed_urls:
- raise NotConfigured
-
- def process_result(self, response, result, spider):
- def _filter(r):
- if isinstance(r, Request) and r.url not in self.allowed_urls:
- return False
- return True
- return (r for r in result or () if _filter(r))
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/urlfilter.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/urlfilter.py
deleted file mode 100644
index 1034f747d..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/urlfilter.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-UrlFilterMiddleware: canonicalizes URLs to filter out duplicated ones
-"""
-
-from scrapy.http import Request
-from scrapy.utils.url import canonicalize_url
-
-class UrlFilterMiddleware(object):
- def process_result(self, response, result, spider):
- disabled = getattr(spider, 'urlfilter_disabled', False)
- for r in result:
- if isinstance(r, Request) and not disabled:
- curl = canonicalize_url(r.url)
- # only assign if different to avoid re-calculating fingerprint
- if curl != r.url:
- r.url = curl
- yield r
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/urllength.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/urllength.py
deleted file mode 100644
index cfca458ef..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/urllength.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""
-UrlLengthMiddleware: Filters out requests with URLs longer than URLLENGTH_LIMIT
-"""
-
-from scrapy import log
-from scrapy.http import Request
-from scrapy.core.exceptions import NotConfigured
-from scrapy.conf import settings
-
-class UrlLengthMiddleware(object):
- def __init__(self):
- self.maxlength = settings.getint('URLLENGTH_LIMIT')
- if not self.maxlength:
- raise NotConfigured
-
- def process_result(self, response, result, spider):
- def _filter(request):
- if isinstance(request, Request) and len(request.url) > self.maxlength:
- log.msg("Ignoring link (url length > %d): %s " % (self.maxlength, request.url), level=log.DEBUG, domain=spider.domain_name)
- return False
- else:
- return True
-
- return (r for r in result or () if _filter(r))
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spiders.py b/scrapy/branches/cluster-refactor/scrapy/contrib/spiders.py
deleted file mode 100644
index e03a86cde..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/spiders.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""
-This module contains BasicSpider, a spider class which provides support for
-basic crawling.
-"""
-
-from scrapy.http import Request
-from scrapy.spider import BaseSpider
-from scrapy.core.exceptions import UsageError
-
-class BasicSpider(BaseSpider):
- """BasicSpider extends BaseSpider by providing support for simple crawling
- by following links contained in web pages.
-
- With BasicSpider you can write a basic spider very easily and quickly. For
- more information refer to the Scrapy tutorial"""
-
- def __init__(self):
- super(BaseSpider, self).__init__()
-
- self._links_callback = []
-
- for attr in dir(self):
- if attr.startswith('links_'):
- suffix = attr.split('_', 1)[1]
- value = getattr(self, attr)
- try:
- callback = getattr(self, 'parse_%s' % suffix)
- except AttributeError:
- raise UsageError("%s defines links_%s but doesn't provide a parse_%s method" % \
- (type(self).__name__, suffix, suffix))
- self._links_callback.append((value, callback))
-
- def parse(self, response):
- """This function is called by the core for all the start_urls. Do not
- override this function, override parse_start_url instead."""
- return self._parse_wrapper(response, self.parse_start_url)
-
- def parse_start_url(self, response):
- """Callback function for processing start_urls. It must return a list
- of ScrapedItems and/or Requests."""
- return []
-
- def _links_to_follow(self, response):
- res = []
- links_to_follow = {}
- for lx, callback in self._links_callback:
- for url, link_text in lx.extract_urls(response).iteritems():
- links_to_follow[url] = (callback, link_text)
-
- for url, cb_link in links_to_follow.iteritems():
- request = Request(url=url, link_text=link_text)
- request.append_callback(self._parse_wrapper, callback)
- res.append(request)
- return res
-
- def _parse_wrapper(self, response, callback):
- res = self._links_to_follow(response)
- res += callback(response) or ()
- return res
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/livestats.py b/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/livestats.py
deleted file mode 100644
index cf38e24a0..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/livestats.py
+++ /dev/null
@@ -1,82 +0,0 @@
-"""
-Live statistics extension
-"""
-from datetime import datetime
-from pydispatch import dispatcher
-from scrapy.core import signals
-from scrapy.core.engine import scrapyengine
-from scrapy.management.web import banner
-
-class SpiderStats(object):
- def __init__(self):
- self.scraped = 0
- self.crawled = 0
- self.started = None
- self.finished = None
-
-class LiveStats(object):
- webconsole_id = 'livestats'
- webconsole_name = 'Spider live statistics of current run'
-
- def __init__(self):
- self.domains = {}
- dispatcher.connect(self.domain_open, signal=signals.domain_open)
- dispatcher.connect(self.domain_closed, signal=signals.domain_closed)
- dispatcher.connect(self.item_scraped, signal=signals.item_scraped)
- dispatcher.connect(self.response_downloaded, signal=signals.response_downloaded)
-
- from scrapy.management.web import webconsole_discover_module
- dispatcher.connect(self.webconsole_discover_module, signal=webconsole_discover_module)
-
- def domain_open(self, domain, spider):
- pstats = SpiderStats()
- self.domains[spider.domain_name] = pstats
- pstats.started = datetime.now()
- pstats.finished = None
-
- def domain_closed(self, domain, spider):
- self.domains[spider.domain_name].finished = datetime.now()
-
- def item_scraped(self, item, spider):
- self.domains[spider.domain_name].scraped += 1
-
- def response_downloaded(self, response, spider):
- #sometimes we download responses without opening/closing domains,
- #for example from scrapy shell
- if self.domains.get(spider.domain_name):
- self.domains[spider.domain_name].crawled += 1
-
- def webconsole_render(self, wc_request):
- sch = scrapyengine.scheduler
- dwl = scrapyengine.downloader
-
- totdomains = totscraped = totcrawled = totscheduled = totactive = totpending = 0
- s = banner(self)
- s += "<table border='1'>\n"
- s += "<tr><th>Domain</th><th>Items<br>Scraped</th><th>Pages<br>Crawled</th><th>Scheduler<br>Pending</th><th>Downloader<br/>Pending</th><th>Downloader<br/>Active</th><th>Start time</th><th>Finish time</th><th>Run time</th></tr>\n"
- for d in sorted(self.domains.keys()):
- scheduled = len(sch.pending_requests[d]) if d in sch.pending_requests else 0
- active, pending = len(dwl.active_requests(d)), len(dwl.request_queue(d))
- stats = self.domains[d]
- runtime = stats.finished - stats.started if stats.finished else datetime.now() - stats.started
-
- s += '<tr><td>%s</td><td align="right">%d</td><td align="right">%d</td><td align="right">%d</td><td align="right">%d</td><td align="right">%d</td><td>%s</td><td>%s</td><td>%s</td></tr>\n' % \
- (d, stats.scraped, stats.crawled, scheduled, pending, active, str(stats.started), str(stats.finished), str(runtime))
-
- totdomains += 1
- totscraped += stats.scraped
- totcrawled += stats.crawled
- totscheduled += scheduled
- totactive += active
- totpending += pending
- s += '<tr><td><b>%d domains</b></td><td align="right"><b>%d</b></td><td align="right"><b>%d</b></td><td align="right"><b>%d</b></td><td align="right"><b>%d</b></td><td align="right"><b>%d</b></td><td/><td/></tr>\n' % \
- (totdomains, totscraped, totcrawled, totscheduled, totactive, totpending)
- s += "</table>\n"
-
- s += "</body>\n"
- s += "</html>\n"
-
- return s
-
- def webconsole_discover_module(self):
- return self
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/schedstats.py b/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/schedstats.py
deleted file mode 100644
index 36a207bf3..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/schedstats.py
+++ /dev/null
@@ -1,41 +0,0 @@
-"""
-Scheduler information module for Scrapy webconsole
-"""
-from pydispatch import dispatcher
-from scrapy.core import signals
-from scrapy.core.engine import scrapyengine
-from scrapy.spider import spiders
-from scrapy.management.web import banner
-
-class SchedulerStats(object):
- webconsole_id = 'scheduler'
- webconsole_name = 'Scheduler queue'
-
- def __init__(self):
- from scrapy.management.web import webconsole_discover_module
- dispatcher.connect(self.webconsole_discover_module, signal=webconsole_discover_module)
-
- def webconsole_render(self, wc_request):
- s = banner(self)
- s += "<ul>\n"
- for domain, requests in scrapyengine.scheduler.pending_requests.iteritems():
- s += "<li>\n"
- s += "%s (<b>%s</b> pages)\n" % (domain, len(requests))
- s += "<ul>\n"
- # requests is a tuple of request and deffered now, as I understand
- for r, d in requests:
- if hasattr(r, 'url'):
- s += "<li><a href='%s'>%s</a></li>\n" % (r.url, r.url)
- #else:
- # s += "<li>%s</li>\n" % (repr(r))
- s += "</ul>\n"
- s += "</li>\n"
- s += "</ul>\n"
-
- s += "</body>\n"
- s += "</html>\n"
-
- return s
-
- def webconsole_discover_module(self):
- return self
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/spiderctl.py b/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/spiderctl.py
deleted file mode 100644
index ac93defac..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/spiderctl.py
+++ /dev/null
@@ -1,208 +0,0 @@
-"""
-Extensions for allowing spider control from web console
-"""
-
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy.core.manager import scrapymanager
-from scrapy.core.engine import scrapyengine
-from scrapy.spider import spiders
-from scrapy.management.web import banner
-from scrapy.conf import settings
-
-class Spiderctl(object):
- webconsole_id = 'spiderctl'
- webconsole_name = 'Spider control panel'
-
- def __init__(self):
- self.running = set()
- self.finished = set()
- dispatcher.connect(self.domain_open, signal=signals.domain_open)
- dispatcher.connect(self.domain_closed, signal=signals.domain_closed)
-
- from scrapy.management.web import webconsole_discover_module
- dispatcher.connect(self.webconsole_discover_module, signal=webconsole_discover_module)
-
- def domain_open(self, domain, spider):
- self.running.add(domain)
-
- def domain_closed(self, domain, spider):
- if domain in self.running:
- self.running.remove(domain)
- self.finished.add(domain)
-
- def webconsole_render(self, wc_request):
- if wc_request.args:
- changes = self.webconsole_control(wc_request)
-
- enabled_domains = spiders.asdict(include_disabled=False).keys()
- self.scheduled = set(scrapyengine.scheduler.pending_domains_count)
- self.not_scheduled = [d for d in enabled_domains if d not in self.scheduled
- and d not in self.running
- and d not in self.finished]
-
- s = banner(self)
- s += '<p><a href="?reloadspiders=1">Reload spiders</a></p>\n'
- s += '<table border=1">\n'
- s += "<tr><th>Running (%d/%d)</th><th>Scheduled (%d)</th><th>Finished (%d)</th><th>Not scheduled (%d)</th></tr>\n" % \
- (len(self.running),
- settings['CONCURRENT_DOMAINS'],
- len(self.scheduled),
- len(self.finished),
- len(self.not_scheduled))
- s += "<tr>\n"
-
- # running
- s += "<td valign='top'>\n"
- s += '<form method="post" action=".">\n'
- s += '<select name="stop_running_domains" multiple="multiple">\n'
- for domain in sorted(self.running):
- s += "<option>%s</option>\n" % domain
- s += '</select><br>\n'
- s += '<br />'
- s += '<input type="submit" value="Stop selected">\n'
- s += '</form>\n'
- s += "</td>\n"
-
- # scheduled
- s += "<td valign='top'>\n"
- s += '<form method="post" action=".">\n'
- s += '<select name="remove_pending_domains" multiple="multiple">\n'
- for domain in sorted(self.scheduled):
- s += "<option>%s</option>\n" % domain
- s += '</select><br>\n'
- s += '<br />'
- s += '<input type="submit" value="Remove selected">\n'
- s += '</form>\n'
-
- s += "</td>\n"
-
- # finished
- s += "<td valign='top'>\n"
- s += '<form method="post" action=".">\n'
- s += '<select name="rerun_finished_domains" multiple="multiple">\n'
- for domain in sorted(self.finished):
- s += "<option>%s</option>\n" % domain
- s += '</select><br>\n'
- s += '<br />'
- s += '<input type="submit" value="Re-schedule selected">\n'
- s += '</form>\n'
- s += "</td>\n"
-
- # not scheduled
- s += "<td valign='top'>\n"
- s += '<form method="post" action=".">\n'
- s += '<select name="add_pending_domains" multiple="multiple">\n'
- for domain in sorted(self.not_scheduled):
- s += "<option>%s</option>\n" % domain
- s += '</select><br>\n'
- s += '<br />'
- s += '<input type="submit" value="Schedule selected">\n'
- s += '</form>\n'
- s += "</td>\n"
-
- s += "</tr>\n"
- s += "<tr>\n"
-
- s += "<td>&nbsp;</td>\n"
-
- s += "<td>\n"
- s += '<form method="post" action=".">\n'
- s += "<textarea name='bulk_remove_domains' rows='10' cols='25'></textarea>\n"
- s += '<br>\n'
- s += '<input type="submit" value="Bulk remove domains">\n'
- s += '</form>\n'
- s += '</td>\n'
-
- s += "<td>&nbsp;</td>\n"
-
- s += "<td>\n"
- s += '<form method="post" action=".">\n'
- s += "<textarea name='bulk_schedule_domains' rows='10' cols='25'></textarea>\n"
- s += '<br>\n'
- s += '<input type="submit" value="Bulk schedule domains">\n'
- s += '</form>\n'
- s += "</td>\n"
-
- s += "</tr>\n"
-
- s += "</table>\n"
-
- if wc_request.args:
- s += changes
-
- s += "</body>\n"
- s += "</html>\n"
-
- return s
-
- def webconsole_control(self, wc_request):
- args = wc_request.args
- s = "<hr />\n"
- if "reloadspiders" in args:
- scrapymanager.reload_spiders()
- s += "<p><b>Spiders reloaded</b></p>\n"
- return s
-
- if "stop_running_domains" in args:
- s += "<p>"
- s += "Stopped spiders: <ul><li>%s</li></ul>" % "</li><li>".join(args["stop_running_domains"])
- for domain in args["stop_running_domains"]:
- scrapyengine.close_domain(domain)
- s += "</p>"
- if "remove_pending_domains" in args:
- removed = []
- for domain in args["remove_pending_domains"]:
- if scrapyengine.scheduler.remove_pending_domain(domain):
- removed.append(domain)
- if removed:
- s += "<p>"
- s += "Removed scheduled spiders: <ul><li>%s</li></ul>" % "</li><li>".join(args["remove_pending_domains"])
- s += "</p>"
- if "bulk_remove_domains" in args:
- scheduled = []
- to_remove = set([d.strip() for d in args["bulk_remove_domains"][0].split("\n")])
- removed = set([d for d in scrapyengine.scheduler.pending_domains if d in to_remove])
- scrapyengine.scheduler.pending_domains = [d for d in execengine.scheduler.pending_domains if d not in removed]
- if removed:
- s += "<p>"
- s += "Removed: <ul><li>%s</li></ul>" % "</li><li>".join(removed)
- s += "</p>"
- s += "<p>"
- s += "Not removed: <ul><li>%s</li></ul>" % "</li><li>".join(to_remove - removed)
- s += "</p>"
- if "add_pending_domains" in args:
- for domain in args["add_pending_domains"]:
- if domain not in scrapyengine.scheduler.pending_domains_count:
- scrapymanager.crawl(domain)
- s += "<p>"
- s += "Scheduled spiders: <ul><li>%s</li></ul>" % "</li><li>".join(args["add_pending_domains"])
- s += "</p>"
- if "bulk_schedule_domains" in args:
- to_schedule = set([d.strip() for d in args["bulk_schedule_domains"][0].split("\n")])
- scheduled = set()
- for domain in to_schedule:
- if domain in enabled_domains and domain not in scrapyengine.scheduler.pending_domains_count:
- scrapymanager.crawl(domain)
- scheduled.add(domain)
- if scheduled:
- s += "<p>"
- s += "Scheduled: <ul><li>%s</li></ul>" % "</li><li>".join(scheduled)
- s += "</p>"
- s += "<p>"
- s += "Not scheduled: <ul><li>%s</li></ul>" % "</li><li>".join(to_schedule - scheduled)
- s += "</p>"
- if "rerun_finished_domains" in args:
- for domain in args["rerun_finished_domains"]:
- if domain not in scrapyengine.scheduler.pending_domains_count:
- scrapymanager.crawl(domain)
- self.finished.remove(domain)
- s += "<p>"
- s += "Re-scheduled finished spiders: <ul><li>%s</li></ul>" % "</li><li>".join(args["rerun_finished_domains"])
- s += "</p>"
-
- return s
-
- def webconsole_discover_module(self):
- return self
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/downloader/handlers.py b/scrapy/branches/cluster-refactor/scrapy/core/downloader/handlers.py
deleted file mode 100644
index e63e501c4..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/downloader/handlers.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""
-Download handlers for different schemes
-"""
-from __future__ import with_statement
-
-import os
-import urlparse
-
-from twisted.web.client import HTTPClientFactory
-from twisted.internet import defer, reactor
-from twisted.web import error as web_error
-
-from scrapy.core import signals
-from scrapy.http import Request, Response, Headers
-from scrapy.core.exceptions import UsageError, HttpException
-from scrapy.utils.defer import defer_succeed
-from scrapy.conf import settings
-
-def download_any(request, spider):
- u = urlparse.urlparse(request.url)
- if u.scheme == 'file':
- return download_file(request, spider)
- elif u.scheme in ('http', 'https'):
- return download_http(request, spider)
- else:
- raise UsageError("Unsupported scheme '%s' in URL: <%s>" % (u.scheme, request.url))
-
-def download_http(request, spider):
- """This functions handles http/https downloads"""
- url = urlparse.urldefrag(request.url)[0]
-
- agent = request.headers.get('user-agent', settings.get('USER_AGENT'))
- request.headers.pop('user-agent', None) # remove user-agent if already present
- factory = HTTPClientFactory(url=str(url), # never pass unicode urls to twisted
- method=request.method,
- postdata=request.body,
- headers=request.headers,
- agent=agent,
- cookies=request.cookies,
- timeout=getattr(spider, "download_timeout", None) or settings.getint('DOWNLOAD_TIMEOUT'),
- followRedirect=False)
-
- def _response(body):
- body = body or ''
- status = factory.status
- headers = Headers(factory.response_headers)
- r = Response(domain=spider.domain_name, url=request.url, headers=headers, status=status, body=body)
- signals.send_catch_log(signal=signals.request_uploaded, sender='download_http', request=request, spider=spider)
- signals.send_catch_log(signal=signals.response_downloaded, sender='download_http', response=r, spider=spider)
- return r
-
- def _on_success(body):
- return _response(body)
-
- def _on_error(_failure):
- ex = _failure.value
- if isinstance(ex, web_error.Error): # HttpException
- raise HttpException(ex.status, ex.message, _response(ex.response))
- return _failure
-
- factory.noisy = False
- factory.deferred.addCallbacks(_on_success, _on_error)
-
- u = urlparse.urlparse(request.url)
- if u.scheme == 'https' :
- from twisted.internet import ssl
- contextFactory = ssl.ClientContextFactory()
- reactor.connectSSL(u.hostname, u.port or 443, factory, contextFactory)
- else:
- reactor.connectTCP(u.hostname, u.port or 80, factory)
- return factory.deferred
-
-def download_file(request, spider) :
- """Return a deferred for a file download."""
- filepath = request.url.split("file://")[1]
- with open(filepath) as f:
- response = Response(domain=spider.domain_name, url=request.url, body=f.read())
- return defer_succeed(response)
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/downloader/manager.py b/scrapy/branches/cluster-refactor/scrapy/core/downloader/manager.py
deleted file mode 100644
index ce8130687..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/downloader/manager.py
+++ /dev/null
@@ -1,196 +0,0 @@
-"""
-Download web pages using asynchronous IO
-"""
-
-import datetime
-
-from twisted.internet import reactor, defer
-
-from scrapy.core.exceptions import IgnoreRequest
-from scrapy.spider import spiders
-from scrapy.core.downloader.handlers import download_any
-from scrapy.core.downloader.middleware import DownloaderMiddlewareManager
-from scrapy import log
-from scrapy.conf import settings
-from scrapy.utils.defer import chain_deferred, mustbe_deferred
-
-
-class SiteDetails(object):
- """This is a simple data record that encapsulates the details we hold on
- each domain which we are scraping.
- """
- def __init__(self, download_delay=None, max_concurrent_requests=2):
- self.download_delay = download_delay
- self.max_concurrent_requests = max_concurrent_requests if not download_delay else 1
-
- self.queue = []
- self.active = set()
- self.downloading = set()
- self.closed = False
- self.lastseen = None
-
- def is_idle(self):
- return not (self.active or self.downloading)
-
- def capacity(self):
- return self.max_concurrent_requests - len(self.downloading)
-
-
-class Downloader(object):
- """Maintain many concurrent downloads and provide an HTTP abstraction
- We will have a limited number of connections per domain and scrape many domains in
- parallel.
-
- request(..) should be called to request resources using http, https or file
- protocols.
- """
-
- def __init__(self) :
- self.sites = {}
- self.middleware = DownloaderMiddlewareManager()
- self.middleware.download_function = self.enqueue
- self.download_function = download_any
-
- def fetch(self, request, spider):
- """ Main method to use to request a download
-
- This method includes middleware mangling. Middleware can returns a
- Response object, then request never reach downloader queue, and it will
- not be downloaded from site.
- """
- domain = spider.domain_name
- site = self.sites[domain]
- if not site or site.closed:
- raise IgnoreRequest('Unable to fetch (domain already closed): %s' % request)
-
- site.active.add(request)
- def _deactivate(_):
- site.active.remove(request)
- return _
- dwld = self.middleware.download(request, spider)
- dwld.addBoth(_deactivate)
- return dwld
-
- def enqueue(self, request, spider):
- """ Enqueue a Request for a effective download from site
- """
- domain = spider.domain_name
- site = self.sites.get(domain)
- if not site or site.closed:
- raise IgnoreRequest('Trying to enqueue %s from closed site %s' % (request, domain))
-
- deferred = defer.Deferred()
- site.queue.append((request, deferred))
- self.process_queue(spider)
- return deferred
-
- def process_queue(self, spider):
- """ Effective download requests from site queue
- """
- domain = spider.domain_name
- site = self.sites.get(domain)
- if not site:
- return
-
- # download delay handling
- now = datetime.datetime.now()
- if site.download_delay and site.lastseen:
- delta = now - site.lastseen
- penalty = site.download_delay - delta.seconds
- if penalty > 0:
- reactor.callLater(penalty, self.process_queue, spider=spider)
- return
- site.lastseen = now
-
- while site.queue and site.capacity()>0:
- request, deferred = site.queue.pop(0)
- self._download(request, spider, deferred)
-
- if site.closed and site.is_idle():
- # XXX: Remove scrapyengine reference
- del self.sites[domain]
- from scrapy.core.engine import scrapyengine
- scrapyengine.closed_domain(domain=domain)
-
- def _download(self, request, spider, deferred):
- log.msg('Activating %s' % request.traceinfo(), log.TRACE)
- domain = spider.domain_name
- site = self.sites.get(domain)
- site.downloading.add(request)
-
- def _remove(result):
- log.msg('Deactivating %s' % request.traceinfo(), log.TRACE)
- site.downloading.remove(request)
- return result
-
- def _finish(result):
- self.process_queue(spider)
-
- dwld = mustbe_deferred(self.download_function, request, spider)
- dwld.addBoth(_remove)
- chain_deferred(dwld, deferred)
- dwld.addBoth(_finish)
-
- def open_domain(self, domain):
- """Allocate resources to begin processing a domain"""
- spider = spiders.fromdomain(domain)
- if domain in self.sites: # reopen
- self.sites[domain].closed = False
- return
-
- # Instanciate site specific handling based on info provided by spider
- delay = getattr(spider, 'download_delay', None) or settings.getint("DOWNLOAD_DELAY", 0)
- maxcr = getattr(spider, 'max_concurrent_requests', settings.getint('REQUESTS_PER_DOMAIN'))
- site = SiteDetails(download_delay=delay, max_concurrent_requests=maxcr)
- self.sites[domain] = site
-
- def close_domain(self, domain):
- """Free any resources associated with the given domain"""
- log.msg("Downloader closing domain %s" % domain, log.TRACE, domain=domain)
- site = self.sites.get(domain)
- if site:
- site.closed = True
- spider = spiders.fromdomain(domain)
- self.process_queue(spider)
- else:
- log.msg('Domain %s already closed' % domain, log.TRACE, domain=domain)
-
- # Most of the following functions must be reviewed to decide if are really needed
- def domain_is_open(self, domain):
- return domain in self.sites
-
- def lastseen(self, domain):
- if domain in self.sites:
- return self.sites[domain].lastseen
-
- def outstanding(self, domain):
- """The number of outstanding requests for a domain
- This includes both active requests and pending requests.
- """
- site = self.sites.get(domain)
- if site:
- return len(site.active) + len(site.queue)
-
- def domain_is_idle(self, domain):
- return not self.outstanding(domain)
-
- def request_queue(self, domain):
- site = self.sites.get(domain)
- return site.queue if site else []
-
- def active_requests(self, domain):
- site = self.sites.get(domain)
- return site.active if site else []
-
- def has_capacity(self):
- """Does the downloader have capacity to handle more domains"""
- return len(self.sites) < settings.getint('CONCURRENT_DOMAINS')
-
- def is_idle(self):
- return not self.sites
-
- # deprecated
- def clear_requests(self, domain):
- log.msg("Downloader clearing request for domain %s" % domain, log.TRACE, domain=domain)
- self.sites[domain].queue = []
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/downloader/middleware.py b/scrapy/branches/cluster-refactor/scrapy/core/downloader/middleware.py
deleted file mode 100644
index 32081e66f..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/downloader/middleware.py
+++ /dev/null
@@ -1,173 +0,0 @@
-"""
-request-response middleware extension
-"""
-from scrapy.core import signals
-from scrapy import log
-from scrapy.http import Request, Response
-from scrapy.core.exceptions import NotConfigured
-from scrapy.utils.misc import load_class
-from scrapy.utils.defer import mustbe_deferred
-from scrapy.core.downloader.handlers import download_any
-from scrapy.conf import settings
-
-class DownloaderMiddlewareManager(object):
- """Request-Response Middleware Manager
-
- Middleware is a framework of hooks into Scrapy's request/response
- processing. It's a light, low-level "spider" system for globally altering
- Scrapy's input and/or output.
-
- Middleware is heavily based on Django middleware system, at the point that
- it tries to mimic Django middleware behaviour. For Scrapy, the Django's
- view function has the same meaning of the final download handler function
- to use for the request's url.
-
- To activate a middleware component, add it to the DOWNLOADER_MIDDLEWARES list
- in your Scrapy settings. In DOWNLOADER_MIDDLEWARES, each middleware component
- is represented by a string: the full Python path to the middleware's class
- name. For example:
-
- DOWNLOADER_MIDDLEWARES = (
- 'scrapy.contrib.middleware.common.SpiderMiddleware',
- 'scrapy.contrib.middleware.common.CommonMiddleware',
- 'scrapy.contrib.middleware.redirect.RedirectMiddleware',
- 'scrapy.contrib.middleware.cache.CacheMiddleware',
- )
-
- Writing your own middleware is easy. Each middleware component is a single
- Python class that defines one or more of the following methods:
-
-
- process_request(self, request, spider)
-
- `request` is a Request object.
- `spider` is a BaseSpider object
-
- This method is called in each request until scrapy decides which
- download function to use.
-
- process_request() should return either None, Response or Request.
-
- If returns None, Scrapy will continue processing this request,
- executing any other middleware and, then, the appropiate download
- function.
-
- If returns a Response object, Scrapy won't bother calling ANY other
- request or exception middleware, or the appropiate download function;
- it'll return that Response. Response middleware is always called on
- every response.
-
- If returns a Request object, returned request is used to instruct a
- redirection. Redirection is handled inside middleware scope, and
- original request don't finish until redirected request is completed.
-
-
- process_response(self, request, response, spider):
-
- `request` is a Request object
- `response` is a Response object
- `spider` is a BaseSpider object
-
- process_response MUST return a Response object. It could alter the given
- response, or it could create a brand-new Response.
-
-
- process_exception(self, request, exception, spider)
-
- `request` is a Request object.
- `exception` is an Exception object
- `spider` is a BaseSpider object
-
- Scrapy calls process_exception() when a download handler or
- process_request middleware raises an exception.
-
- process_exception() should return either None, Response or Request object.
-
- if it returns None, Scrapy will continue processing this exception,
- executing any other exception middleware, until no middleware left and
- default exception handling kicks in.
-
- If it returns a Response object, the response middleware kicks in, and
- won't bother calling ANY other exception middleware.
-
- If it returns a Request object, returned request is used to instruct a
- immediate redirection. Redirection is handled inside middleware scope,
- and original request don't finish until redirected request is
- completed. This stop process_exception middleware as returning
- Response does.
-
- """
- def __init__(self):
- self.loaded = False
- self.request_middleware = []
- self.response_middleware = []
- self.exception_middleware = []
- self.load()
- self.download_function = download_any
-
- def _add_middleware(self, mw):
- if hasattr(mw, 'process_request'):
- self.request_middleware.append(mw.process_request)
- if hasattr(mw, 'process_response'):
- self.response_middleware.insert(0, mw.process_response)
- if hasattr(mw, 'process_exception'):
- self.exception_middleware.insert(0, mw.process_exception)
-
- def load(self):
- """Load middleware defined in settings module
- """
- mws = []
- for mwpath in settings.getlist('DOWNLOADER_MIDDLEWARES') or ():
- cls = load_class(mwpath)
- if cls:
- try:
- mw = cls()
- self._add_middleware(mw)
- mws.append(mw)
- except NotConfigured:
- pass
- log.msg("Enabled downloader middlewares: %s" % ", ".join([type(m).__name__ for m in mws]))
- self.loaded = True
-
- def download(self, request, spider):
- def process_request(request):
- for method in self.request_middleware:
- response = method(request=request, spider=spider)
- assert response is None or isinstance(response, (Response, Request)), \
- 'Middleware %s.process_request must return None, Response or Request, got %s' % \
- (method.im_self.__class__.__name__, response.__class__.__name__)
- if response:
- return response
- return self.download_function(request=request, spider=spider)
-
- def process_response(response):
- assert response is not None, 'Received None in process_response'
- if isinstance(response, Request):
- return response
-
- for method in self.response_middleware:
- response = method(request=request, response=response, spider=spider)
- assert isinstance(response, (Response, Request)), \
- 'Middleware %s.process_response must return Response or Request, got %s' % \
- (method.im_self.__class__.__name__, type(response))
- if isinstance(response, Request):
- signals.send_catch_log(signal=signals.response_received, sender=self.__class__, response=response, spider=spider)
- return response
- signals.send_catch_log(signal=signals.response_received, sender=self.__class__, response=response, spider=spider)
- return response
-
- def process_exception(_failure):
- exception = _failure.value
- for method in self.exception_middleware:
- response = method(request=request, exception=exception, spider=spider)
- assert response is None or isinstance(response, (Response, Request)), \
- 'Middleware %s.process_exception must return None, Response or Request, got %s' % \
- (method.im_self.__class__.__name__, type(response))
- if response:
- return response
- return _failure
-
- deferred = mustbe_deferred(process_request, request)
- deferred.addErrback(process_exception)
- deferred.addCallback(process_response)
- return deferred
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/engine.py b/scrapy/branches/cluster-refactor/scrapy/core/engine.py
deleted file mode 100644
index 325a97dbb..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/engine.py
+++ /dev/null
@@ -1,549 +0,0 @@
-"""
-Core execution engine for the web crawling framework. This controls the
-scheduler, downloader and spiders.
-"""
-from datetime import datetime
-
-from twisted.internet import defer, reactor, task
-from twisted.python.failure import Failure
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy import log
-from scrapy.core.scheduler import Scheduler
-from scrapy.core.downloader import Downloader
-from scrapy.http import Response, Request
-from scrapy.core.exceptions import IgnoreRequest, HttpException, DontCloseDomain
-from scrapy.item import ScrapedItem
-from scrapy.item.pipeline import ItemPipeline
-from scrapy.spider import spiders
-from scrapy.spider.middleware import SpiderMiddlewareManager
-from scrapy.utils.defer import chain_deferred, defer_succeed, mustbe_deferred, deferred_degenerate
-from scrapy.conf import settings
-
-
-class ExecutionEngine(object):
- """
- The Execution Engine controls execution of the scraping process.
-
- The process begins with the _mainloop() method, which is called
- periodically to add more domains to scrape. It adds the first page for a
- domain to the scheduler by calling _schedule_page and calls
- process_scheduled_requests, which starts the scraping process for a domain.
-
- The process_scheduled_requests method asks the scheduler for the next
- available page for a given domain and requests it from the downloader. The
- downloader will execute a callback function that was added in the
- _schedule_page method. This callback with process the output from the
- spider and then call process_scheduled_requests to continue the scraping
- process for that domain.
- """
-
- # back off downloading more pages if we exceed this backlog size
- DOWNLOADER_BACKLOG = 10
-
- def __init__(self):
- self.configured = False
- self.keep_alive = False
- self.domain_close_delay = settings.getint('DOMAIN_CLOSE_DELAY') # seconds after an idle domain will be closed
- self.initializing = set() # domais in intialization state
- self.cancelled = set() # domains in cancelation state
- self.debug_mode = settings.getbool('ENGINE_DEBUG')
- self.tasks = []
- self.ports = []
- self.running = False
- self.paused = False
-
- def configure(self, scheduler=None, downloader=None):
- """
- Configure execution engine with the given scheduling policy and downloader.
- """
- self.scheduler = scheduler or Scheduler()
- self.downloader = downloader or Downloader()
- self.spidermiddleware = SpiderMiddlewareManager()
- self._scraping = {}
- self.pipeline = ItemPipeline()
- # key dictionary of per domain lists of initial requests to scrape
- self.starters = {}
-
- self.configured = True
-
- def addtask(self, function, interval, args=None, kwargs=None, now=False):
- """
- Adds a looping task. Use this instead of twisted task.LooopingCall to
- make sure the reactor is left in a clean state after the engine is
- stopped.
- """
- if not args:
- args = []
- if not kwargs:
- kwargs = {}
- tsk = task.LoopingCall(function, *args, **kwargs)
- self.tasks.append((tsk, interval, now))
- if self.running:
- tsk.start(interval, now)
- return tsk
-
- def removetask(self, tsk):
- """Remove a looping task previously added with addtask() method"""
- self.tasks = [(t, i, n) for (t, i, n) in self.tasks if t is not tsk]
- if tsk.running:
- tsk.stop()
-
- def listenTCP(self, *args, **kwargs):
- if self.running:
- self.ports.append(reactor.listenTCP(*args, **kwargs))
- else:
- self.ports.append((args, kwargs))
-
- def clean_reactor(self):
- """Leaves the reactor in a clean state by removing all pending tasks
- and listening ports. It can only be called when the engine is not
- running.
- """
- if not self.running:
- for tsk, _, _ in self.tasks:
- if tsk.running:
- tsk.stop()
- self.tasks = []
- for p in [p for p in self.ports if not isinstance(p, tuple)]:
- p.stopListening()
- self.ports = []
-
- def start(self):
- """Start the execution engine"""
- if not self.running:
- reactor.callWhenRunning(self._mainloop)
- self.start_time = datetime.now()
- signals.send_catch_log(signal=signals.engine_started, sender=self.__class__)
- self.addtask(self._mainloop, 5.0)
- for tsk, interval, now in self.tasks:
- tsk.start(interval, now)
- for args, kwargs in [t for t in self.ports if isinstance(t, tuple)]:
- reactor.listenTCP(*args, **kwargs)
- self.running = True
- reactor.run() # blocking call
-
- def stop(self):
- """Stop the execution engine"""
- if self.running:
- self.running = False
- for domain in self.open_domains:
- spider = spiders.fromdomain(domain)
- signals.send_catch_log(signal=signals.domain_closed, sender=self.__class__, domain=domain, spider=spider, status='cancelled')
- for tsk, _, _ in self.tasks: # stop looping calls
- if tsk.running:
- tsk.stop()
- self.tasks = []
- for p in [p for p in self.ports if not isinstance(p, tuple)]:
- p.stopListening()
- if reactor.running:
- reactor.stop()
- signals.send_catch_log(signal=signals.engine_stopped, sender=self.__class__)
-
- def pause(self):
- """Pause the execution engine"""
- self.paused = True
-
- def resume(self):
- """Resume the execution engine"""
- self.paused = False
-
- def is_idle(self):
- return self.scheduler.is_idle() and self.pipeline.is_idle() and self.downloader.is_idle() and not self._scraping
-
- def next_domain(self):
- domain = self.scheduler.next_domain()
- if domain:
- spider = spiders.fromdomain(domain)
- self.open_domain(domain, spider)
- return domain
-
- def next_request(self, spider, breakloop=True):
- """Scrape the next request for the domain passed.
-
- The next request to be scraped is retrieved from the scheduler and
- requested from the downloader.
-
- The domain is closed if there are no more pages to scrape.
- """
- if self.paused:
- return reactor.callLater(5, self.next_request, spider)
-
- if breakloop:
- # delaying make reentrant call to next_request safe
- return reactor.callLater(0, self.next_request, spider, breakloop=False)
-
- domain = spider.domain_name
-
- # check that the engine is still running and domain is open
- if not self.running:
- return
-
- # outstanding requests in downloader queue
- outstanding = self.downloader.outstanding(domain)
- if outstanding > self.DOWNLOADER_BACKLOG:
- return
-
- # Next pending request from scheduler
- request, deferred = self.scheduler.next_request(domain)
- if request:
- try:
- dwld = self.download(request, spider)
- except IgnoreRequest, ex:
- log.msg(ex.message, log.WARNING, domain=domain)
- except Exception, ex:
- log.exc("Bug in download code: %s" % request, domain=domain)
- self._domain_idle(domain)
- else:
- chain_deferred(dwld, deferred)
- else:
- if self.domain_is_idle(domain):
- self._domain_idle(domain)
-
- def domain_is_idle(self, domain):
- scraping = self._scraping.get(domain)
- pending = self.scheduler.domain_has_pending(domain)
- downloading = not self.downloader.domain_is_idle(domain)
- haspipe = not self.pipeline.domain_is_idle(domain)
- oninit = domain in self.initializing
- if pending or downloading or haspipe or oninit or scraping:
- return False
- elif self.domain_close_delay:
- lastseen = self.downloader.lastseen(domain)
- if not lastseen: # domain not yet started
- return False
- now = datetime.now()
- delta = now - lastseen
- return (delta.seconds >= self.domain_close_delay)
- else:
- return True
-
- def domain_is_open(self, domain):
- return domain in self.downloader.sites
-
- @property
- def open_domains(self):
- return self.downloader.sites.keys()
-
- def crawl(self, request, spider, priority=1, domain_priority=1):
- domain = spider.domain_name
-
- def _process(response):
- assert isinstance(response, (Response, Exception))
-
- def _onpipelinefinish(pipe_result, item):
- # _ can only be an item or a DropItem failure, since other
- # failures are caught in ItemPipeine (item/pipeline.py)
- if isinstance(pipe_result, Failure):
- signals.send_catch_log(signal=signals.item_dropped, sender=self.__class__, item=item, spider=spider, response=response, exception=pipe_result.value)
- else:
- signals.send_catch_log(signal=signals.item_passed, sender=self.__class__, item=item, spider=spider, response=response, pipe_output=pipe_result)
- self.next_request(spider)
-
- def _onsuccess_per_item(item):
- if isinstance(item, ScrapedItem):
- log.msg("Scraped %s in <%s>" % (item, request.url), log.DEBUG, domain=domain)
- signals.send_catch_log(signal=signals.item_scraped, sender=self.__class__, item=item, spider=spider, response=response)
- piped = self.pipeline.pipe(item, spider, response) # TODO: remove response
- piped.addBoth(_onpipelinefinish, item)
- elif isinstance(item, Request):
- signals.send_catch_log(signal=signals.request_received, sender=self.__class__, request=item, spider=spider, response=response)
- self.crawl(request=item, spider=spider, priority=priority)
- else:
- log.msg('Garbage found in spider output while processing %s, got type %s' % (request, type(item)), log.TRACE, domain=domain)
-
- class _ResultContainer(object):
- def append(self, item):
- _onsuccess_per_item(item)
-
- def _onsuccess(result):
- return deferred_degenerate(result, _ResultContainer())
-
- def _onerror(_failure):
- if not isinstance(_failure.value, IgnoreRequest):
- referer = None if not isinstance(response, Response) else response.request.headers.get('Referer', None)
- log.msg("Error while spider was processing <%s> from <%s>: %s" % (request.url, referer, _failure), log.ERROR, domain=domain)
-
- def _bugtrap(_failure):
- log.msg('FRAMEWORK BUG processing %s: %s' % (request, _failure), log.ERROR, domain=domain)
-
-
- scd = self.scrape(request, response, spider)
- scd.addCallbacks(_onsuccess, _onerror)
- scd.addErrback(_bugtrap)
-
- self._scraping[domain].add(response)
- scd.addBoth(lambda _: self._scraping[domain].remove(response))
- return scd
-
- def _cleanfailure(_failure):
- ex = _failure.value
- if not isinstance(ex, IgnoreRequest):
- log.msg("Unknown error propagated in %s: %s" % (request, _failure), log.ERROR, domain=domain)
- request.deferred.addErrback(lambda _:None)
- request.deferred.errback(_failure) #TODO: merge into spider middleware.
-
- schd = self.schedule(request, spider, priority, domain_priority)
- schd.addCallbacks(_process, _cleanfailure)
- return schd
-
- def scrape(self, request, response, spider):
- return self.spidermiddleware.scrape(request, response, spider)
-
- def schedule(self, request, spider, priority=1, domain_priority=1):
- domain = spider.domain_name
- if not self.scheduler.domain_is_open(domain):
- if self.debug_mode:
- log.msg('Scheduling %s (delayed)' % request.traceinfo(), log.TRACE)
- return self._add_starter(request, spider, domain_priority)
- if self.debug_mode:
- log.msg('Scheduling %s (now)' % request.traceinfo(), log.TRACE)
- schd = self.scheduler.enqueue_request(domain, request, priority)
- self.next_request(spider)
- return schd
-
- def _mainloop(self):
- """Add more domains to be scraped if the downloader has the capacity.
-
- If there is nothing else scheduled then stop the execution engine.
- """
- if not self.running or self.paused:
- return
-
- # main domain starter loop
- while self.running and self.downloader.has_capacity():
- if not self.next_domain():
- return self._stop_if_idle()
-
- # purge idle domains - (domain_close_delay support)
- if self.domain_close_delay:
- for domain in self.downloader.sites:
- if self.domain_is_idle(domain):
- self._domain_idle(domain)
-
- def _add_starter(self, request, spider, domain_priority):
- domain = spider.domain_name
- if not self.scheduler.is_pending(domain):
- self.scheduler.add_domain(domain, priority=domain_priority)
- self.starters[domain] = []
- deferred = defer.Deferred()
- self.starters[domain] += [(request, deferred)]
- return deferred
-
- def _run_starters(self, spider):
- domain = spider.domain_name
- starters = self.starters.get(domain, [])
- while starters:
- request, deferred = starters.pop(0)
- schd = self.schedule(request, spider)
- chain_deferred(schd, deferred)
- del self.starters[domain]
-
- def download(self, request, spider):
- log.msg('Downloading %s' % request.traceinfo(), log.TRACE)
- domain = spider.domain_name
-
- def _on_success(response):
- """handle the result of a page download"""
- assert isinstance(response, (Response, Request))
- log.msg("Requested %s" % request.traceinfo(), level=log.TRACE, domain=domain)
- if isinstance(response, Response):
- response.request = request # tie request to obtained response
- cached = 'cached' if response.cached else 'live'
- log.msg("Crawled %s <%s> from <%s>" % (cached, response.url, request.headers.get('referer')), level=log.DEBUG, domain=domain)
- return response
- elif isinstance(response, Request):
- redirected = response # proper alias
- schd = self.schedule(redirected, spider, priority=4)
- chain_deferred(schd, redirected.deferred)
- return schd
-
- def _on_error(_failure):
- """handle an error processing a page"""
- ex = _failure.value
- if isinstance(ex, IgnoreRequest):
- log.msg(_failure.getErrorMessage(), level=log.DEBUG, domain=domain)
- return _failure
- referer = request.headers.get('Referer', None)
- errmsg = str(ex) if isinstance(ex, HttpException) else str(_failure)
- log.msg("Downloading <%s> from <%s>: %s" % (request.url, referer, errmsg), log.ERROR, domain=domain)
- return Failure(IgnoreRequest(str(ex)))
-
- def _on_complete(_):
- self.next_request(spider)
-
- dwld = self.downloader.fetch(request, spider)
- dwld.addCallbacks(_on_success, _on_error)
- deferred = defer.Deferred()
- chain_deferred(dwld, deferred)
- dwld.addBoth(_on_complete)
- return deferred
-
- def initialize(self, spider):
- domain = spider.domain_name
- if not hasattr(spider, 'init_domain'):
- return defer_succeed(True)
-
- def _initialize(req):
- if isinstance(req, Request):
- _response = None
- def _referer(response):
- req.deferred.addCallback(_setreferer, response)
- return response
-
- def _setreferer(result, response):
- if isinstance(result, Request):
- result.headers.setdefault('Referer', response.url)
- return result
-
- def _onerror(_failure):
- ex = _failure.value
- if isinstance(ex, IgnoreRequest):
- log.msg(ex.message, log.DEBUG, domain=domain)
- else:
- return _failure
-
- schd = self.schedule(req, spider)
- schd.addCallback(_referer)
- chain_deferred(schd, req.deferred)
- schd.addErrback(_onerror)
- schd.addBoth(_initialize)
- return schd
- return req
-
- def _bugtrap(_failure):
- log.msg("Bug in %s init_domain code: %s" % (domain, _failure), log.ERROR, domain=domain)
-
- def _state(state):
- self.initializing.remove(domain)
- if state is True:
- log.msg('Succeded initialization for %s' % domain, log.INFO, domain=domain)
- else:
- log.msg('Failed initialization for %s' % domain, log.INFO, domain=domain)
- return state
-
- log.msg('Started initialization for %s' % domain, log.INFO, domain=domain)
- self.initializing.add(domain)
- req = spider.init_domain()
- deferred = mustbe_deferred(_initialize, req)
- deferred.addErrback(_bugtrap)
- deferred.addCallback(_state)
- return deferred
-
- def open_domain(self, domain, spider=None):
- log.msg("Domain opened", domain=domain)
- spider = spider or spiders.fromdomain(domain)
-
- self.scheduler.open_domain(domain)
- self.downloader.open_domain(domain)
- self.pipeline.open_domain(domain)
- self._scraping[domain] = set()
- signals.send_catch_log(signals.domain_open, sender=self.__class__, domain=domain, spider=spider)
-
- # init_domain
- dfd = self.initialize(spider)
- def _state(state):
- if state is True:
- signals.send_catch_log(signals.domain_opened, sender=self.__class__, domain=domain, spider=spider)
- self._run_starters(spider)
- else:
- self._domain_idle(domain)
- dfd.addCallback(_state)
-
- def close_domain(self, domain):
- """Close (cancel) domain and clear all its outstanding requests"""
- if domain not in self.cancelled:
- self.cancelled.add(domain)
- self._close_domain(domain)
-
- def _close_domain(self, domain):
- self.downloader.close_domain(domain)
-
- def _domain_idle(self, domain):
- """
- Called when a domain gets idle. This function is called when there are no
- remaining pages to download or scheduled. It can be called multiple
- times. If the some extensions raises a DontCloseDomain exception the
- domain won't be closed and this function is garanteed to be called
- again (at least once) for this domain.
- """
- # we get a callback from the downloader which completes closing
- #log.msg("Finishing scraping %s" % domain, domain=domain)
- #from traceback import print_stack; print_stack()
-
- spider = spiders.fromdomain(domain)
- try:
- dispatcher.send(signal=signals.domain_idle, sender=self.__class__, domain=domain, spider=spider)
- except DontCloseDomain:
- return
- except:
- log.exc("Exception catched on domain_idle signal dispatch")
-
- if self.domain_is_idle(domain):
- self._close_domain(domain)
-
- def _stop_if_idle(self):
- """Call the stop method if the system has no outstanding tasks. """
- if self.is_idle() and not self.keep_alive:
- self.stop()
-
- def closed_domain(self, domain):
- """
- This function is called after the domain has been closed, and throws
- the domain_closed signal which is meant to be used for cleaning up
- purposes. In contrast to domain_idle, this function is called only
- ONCE for each domain run.
- """
- spider = spiders.fromdomain(domain)
- self.scheduler.close_domain(domain)
- self.pipeline.close_domain(domain)
- del self._scraping[domain]
- status = 'cancelled' if domain in self.cancelled else 'finished'
- signals.send_catch_log(signal=signals.domain_closed, sender=self.__class__, domain=domain, spider=spider, status=status)
- log.msg("Domain closed (%s)" % status, domain=domain)
- self.cancelled.discard(domain)
- self._mainloop()
-
- def getstatus(self):
- """
- Return a report of the current engine status
- """
- s = "Execution engine status\n\n"
-
- global_tests = [
- "datetime.now()-self.start_time",
- "self.is_idle()",
- "self.scheduler.is_idle()",
- "len(self.scheduler.pending_domains_count)",
- "self.downloader.is_idle()",
- "len(self.downloader.sites)",
- "self.downloader.has_capacity()",
- "self.pipeline.is_idle()",
- "len(self.pipeline.domaininfo)",
- ]
- domain_tests = [
- "self.domain_is_idle(domain)",
- "self.scheduler.domain_has_pending(domain)",
- "len(self.scheduler.pending_requests[domain])",
- "self.downloader.outstanding(domain)",
- "len(self.downloader.request_queue(domain))",
- "len(self.downloader.active_requests(domain))",
- "self.pipeline.domain_is_idle(domain)",
- "len(self.pipeline.domaininfo[domain])",
- ]
-
- for test in global_tests:
- s += "%-47s : %s\n" % (test, eval(test))
- s += "\n"
- for domain in self.downloader.sites:
- s += "%s\n" % domain
- for test in domain_tests:
- s += " %-45s : %s\n" % (test, eval(test))
-
- return s
-
- def st(self): # shortcut for printing engine status (useful in telnet console)
- print self.getstatus()
-
-scrapyengine = ExecutionEngine()
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/exceptions.py b/scrapy/branches/cluster-refactor/scrapy/core/exceptions.py
deleted file mode 100644
index bf4fd7fd5..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/exceptions.py
+++ /dev/null
@@ -1,47 +0,0 @@
-"""
-Scrapy core exceptions
-"""
-
-# Internal
-
-class UsageError(Exception):
- """Incorrect usage of the core API"""
- pass
-
-class NotConfigured(Exception):
- """Indicates a missing configuration situation"""
- pass
-
-# HTTP and crawling
-
-class IgnoreRequest(Exception):
- """Indicates a decision was made not to process a request"""
- pass
-
-class DontCloseDomain(Exception):
- """Request the domain not to be closed yet"""
- pass
-
-class HttpException(Exception):
- def __init__(self, status, message, response):
- if not message:
- from twisted.web import http
- message = http.responses.get(int(status))
-
- self.status = status
- self.message = message
- self.response = response
- Exception.__init__(self, status, message, response)
-
- def __str__(self):
- return '%s %s' % (self.status, self.message)
-
-# Items
-
-class DropItem(Exception):
- """Drop item from the item pipeline"""
- pass
-
-class NotSupported(Exception):
- """Indicates a feature or method is not supported"""
- pass
\ No newline at end of file
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/manager.py b/scrapy/branches/cluster-refactor/scrapy/core/manager.py
deleted file mode 100644
index 7872b784e..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/manager.py
+++ /dev/null
@@ -1,149 +0,0 @@
-import signal
-
-from scrapy.extension import extensions
-from scrapy import log
-from scrapy.http import Request
-from scrapy.core.engine import scrapyengine
-from scrapy.spider import spiders
-from scrapy.utils.misc import load_class
-from scrapy.utils.url import is_url
-from scrapy.conf import settings
-
-class ExecutionManager(object):
- """Process a list of sites or urls.
-
- This class should be used in a main for process a list of sites/urls.
-
- It extracts products and could be used to store results in a database or
- just for testing spiders.
- """
- def __init__(self):
- self.interrupted = False
- self.configured = False
-
- def configure(self, *args, **opts):
- self._install_signals()
-
- extensions.load()
- log.msg("Enabled extensions: %s" % ", ".join(extensions.enabled.iterkeys()))
-
- scheduler = load_class(settings['SCHEDULER'])()
-
- scrapyengine.configure(scheduler=scheduler)
-
- self.prioritizer_class = load_class(settings['PRIORITIZER'])
-
- requests = self._parse_args(args)
- self.priorities = self.prioritizer_class(requests.keys())
-
- def crawl(self, *args):
- """Schedule the given args for crawling. args is a list of urls or domains"""
-
- requests = self._parse_args(args)
- # schedule initial requets to be scraped at engine start
- for domain in requests or ():
- spider = spiders.fromdomain(domain)
- priority = self.priorities.get_priority(domain)
- for request in requests[domain]:
- scrapyengine.crawl(request, spider, domain_priority=priority)
-
- def runonce(self, *args, **opts):
- """Run the engine until it finishes scraping all domains and then exit"""
- self.configure(*args, **opts)
- self.crawl(*args)
- scrapyengine.start()
-
- def start(self, **opts):
- """Start the scrapy server, without scheduling any domains"""
- self.configure(**opts)
- scrapyengine.keep_alive = True
- scrapyengine.start()# blocking call
- self.stop()
-
- def stop(self):
- """Stop the scrapy server, shutting down the execution engine"""
- self.interrupted = True
- scrapyengine.stop()
- log.log_level = -999 # disable logging
- signal.signal(signal.SIGTERM, signal.SIG_IGN)
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- if hasattr(signal, "SIGBREAK"):
- signal.signal(signal.SIGBREAK, signal.SIG_IGN)
-
- def reload_spiders(self):
- """
- Reload all enabled spiders except for the ones that are currently
- running.
-
- """
- spiders.reload(skip_domains=scrapyengine.open_domains)
- # reload priorities for the new domains
- self.priorities = self.prioritizer_class(spiders.asdict(include_disabled=False).keys())
-
- def _install_signals(self):
- def sig_handler_terminate(signalinfo, param):
- log.msg('Received shutdown request, waiting for deferreds to finish...', log.INFO)
- self.stop()
-
- signal.signal(signal.SIGTERM, sig_handler_terminate)
- # only handle SIGINT if there isn't already a handler (e.g. for Pdb)
- if signal.getsignal(signal.SIGINT) == signal.default_int_handler:
- signal.signal(signal.SIGINT, sig_handler_terminate)
- # Catch Ctrl-Break in windows
- if hasattr(signal, "SIGBREAK"):
- signal.signal(signal.SIGBREAK, sig_handler_terminate)
-
- def _parse_args(self, args):
- """ Parse crawl arguments and return a dict domains -> [requests] """
- if not args:
- args = [p.domain_name for p in spiders.enabled]
-
- requests, urls, sites = set(), set(), set()
- for a in args:
- if isinstance(a, Request):
- requests.add(a)
- elif is_url(a):
- urls.add(a)
- else:
- sites.add(a)
-
- perdomain = {}
- def _add(domain, request):
- if domain not in perdomain:
- perdomain[domain] = []
- perdomain[domain] += [request]
-
- # sites
- for domain in sites:
- spider = spiders.fromdomain(domain)
- if not spider:
- log.msg('Could not found spider for %s' % domain, log.ERROR)
- continue
- for url in self._start_urls(spider):
- request = Request(url, callback=spider.parse, dont_filter=True)
- _add(domain, request)
- # urls
- for url in urls:
- spider = spiders.fromurl(url)
- if spider:
- request = Request(url=url, callback=spider.parse, dont_filter=True)
- _add(spider.domain_name, request)
- else:
- log.msg('Could not found spider for <%s>' % url, log.ERROR)
-
- # requests
- for request in requests:
- if request.domain:
- spider = spiders.fromdomain(request.domain)
- else:
- spider = spiders.fromurl(request.url)
- if not spider:
- log.msg('Could not found spider for %s' % request, log.ERROR)
- continue
- _add(spider.domain_name, request)
- return perdomain
-
- def _start_urls(self, spider):
- return spider.start_urls if hasattr(spider.start_urls, '__iter__') else [spider.start_urls]
-
-scrapymanager = ExecutionManager()
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/scheduler/__init__.py b/scrapy/branches/cluster-refactor/scrapy/core/scheduler/__init__.py
deleted file mode 100644
index 1027c0382..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/scheduler/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from scrapy.core.scheduler.schedulers import Scheduler
-from scrapy.core.scheduler.filter import GroupFilter
-from scrapy.core.scheduler.store import MemoryStore
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/scheduler/filter.py b/scrapy/branches/cluster-refactor/scrapy/core/scheduler/filter.py
deleted file mode 100644
index 9008a4d03..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/scheduler/filter.py
+++ /dev/null
@@ -1,19 +0,0 @@
-class GroupFilter(dict):
- """Filter groups of keys"""
- def open(self, group):
- self[group] = set()
-
- def close(self, group):
- del self[group]
-
- def add(self, group, key):
- """Add a key to the group if an equivalent key has not already been added.
- This method will return true if the key was added and false otherwise.
- """
- if key not in self[group]:
- self[group].add(key)
- return True
- return False
-
- def has(self, group, key):
- return key in self[group]
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/scheduler/schedulers.py b/scrapy/branches/cluster-refactor/scrapy/core/scheduler/schedulers.py
deleted file mode 100644
index 81d2c9f82..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/scheduler/schedulers.py
+++ /dev/null
@@ -1,173 +0,0 @@
-"""
-The Scrapy Scheduler
-"""
-
-from twisted.internet import defer
-
-from scrapy.core.scheduler.filter import GroupFilter
-from scrapy import log
-from scrapy.core.exceptions import IgnoreRequest
-from scrapy.utils.datatypes import PriorityQueue, PriorityStack
-from scrapy.utils.defer import defer_fail
-from scrapy.conf import settings
-
-
-class Scheduler(object) :
- """
- The scheduler decides what to scrape, how fast, and in what order.
- The scheduler schedules websites and pages to be scraped. Individual
- web pages that are to be scraped are batched up into a "run" for a website.
- As the domain is being scraped, pages that are discovered are added to the
- scheduler. The scheduler must not allow the same page to be requested
- multiple times within the same batch.
-
- Typical usage:
-
- * next_availble_domain() called to find out when there is something to do
- * begin_domain() called to commence scraping a website
- * enqueue_request() called multiple times when new links found
- * next_request() called multiple times when there is capacity to process urls
- * close_domain() called when there are no more pages or upon error
-
- Note a couple things:
- 1) The order in which you get back the list of pages to scrape is not
- necesarily the order you put them in.
- 2) A canonical URL is calculated for each url for each domain to check that
- it is unique, however the actual url passed in is returned when
- get_next_page is called.
- This is for two main reasons:
- * To be nice to the screen scraped site just incase the specific
- format of the url is significant.
- * To take advantage of any caching that uses the URL/URI as a key
-
- all_domains contains the names of all domains that are to be scheduled.
-
- Two crawling orders are available by default, which can be set with the
- SCHEDULER_ORDER settings:
-
- * BFO - breath-first order (default). Consumes more memory than DFO but reaches
- most relevant pages faster.
- * DFO - depth-first order. Consumes less memory than BFO but usually takes
- longer to reach the most relevant pages.
- """
-
- def __init__(self):
- self.pending_domains_count = {}
- self.domains_queue = PriorityQueue()
- self.pending_requests = {}
- self.groupfilter = GroupFilter()
- self.dfo = settings.get('SCHEDULER_ORDER', '').upper() == 'DFO'
-
- def domain_is_open(self, domain):
- return domain in self.pending_requests
-
- def is_pending(self, domain):
- return domain in self.pending_domains_count
-
- def domain_has_pending(self, domain):
- if domain in self.pending_requests:
- return not self.pending_requests[domain].empty()
-
- def next_domain(self) :
- """
- Return next domain available to scrape and remove it from available domains queue
- """
- if self.pending_domains_count:
- priority, domain = self.domains_queue.get_nowait()
- if self.pending_domains_count[domain] == 1:
- del self.pending_domains_count[domain]
- else:
- self.pending_domains_count[domain] -= 1
- return domain
- return None
-
- def add_domain(self, domain, priority=1):
- """
- This functions schedules a new domain to be scraped, with the given
- priority. It doesn't check if the domain is already scheduled. A
- domain can be scheduled twice, either with the same or with different
- priority.
- """
- self.domains_queue.put(domain, priority=priority)
- if domain not in self.pending_domains_count:
- self.pending_domains_count[domain] = 1
- else:
- self.pending_domains_count[domain] += 1
-
- def open_domain(self, domain):
- """
- Allocates resources for maintaining a schedule for domain.
- """
- if self.dfo:
- self.pending_requests[domain] = PriorityStack()
- else:
- self.pending_requests[domain] = PriorityQueue()
-
- self.groupfilter.open(domain)
-
- def enqueue_request(self, domain, request, priority=1):
- """
- Add a page to be scraped for a domain that is currently being scraped.
- """
- requestid = request.fingerprint()
- added = self.groupfilter.add(domain, requestid)
-
- if request.dont_filter or added:
- deferred = defer.Deferred()
- self.pending_requests[domain].put((request, deferred), priority)
- return deferred
- else:
- return defer_fail(IgnoreRequest('Skipped (already visited): %s' % request))
-
- def request_seen(self, domain, request):
- """
- Returns True if the given Request was scheduled before for the given
- domain
- """
- return self.groupfilter.has(domain, request.fingerprint())
-
- def next_request(self, domain):
- """
- Get the next request to be scraped.
-
- None should be returned if there are no more request pending for the domain passed.
- """
- pending_list = self.pending_requests.get(domain)
- if pending_list and not pending_list.empty():
- return pending_list.get_nowait()[1]
- else:
- return (None, None)
-
- def close_domain(self, domain) :
- """
- Called once we are finished scraping a domain. The scheduler will
- free any resources associated with the domain.
- """
- try :
- del self.pending_requests[domain]
- except Exception, inst:
- msg = "Could not clear pending pages for domain %s, %s" % (domain, inst)
- log.msg(msg, level=log.WARNING)
-
- try :
- self.groupfilter.close(domain)
- except Exception, inst:
- msg = "Could not clear url filter for domain %s, %s" % (domain, inst)
- log.msg(msg, level=log.WARNING)
-
- def remove_pending_domain(self, domain):
- """
- Remove a pending domain not yet started. If the domain was enqueued
- several times, all those instances are removed.
-
- Returns the number of times the domain was enqueued. 0 if domains was
- not pending.
-
- If domain is open (not pending) it is not removed and returns None. You
- need to call close_domain for open domains.
- """
- if not self.domain_is_open(domain):
- return self.pending_domains_count.pop(domain, 0)
-
- def is_idle(self):
- return not self.pending_requests
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/signals.py b/scrapy/branches/cluster-refactor/scrapy/core/signals.py
deleted file mode 100644
index d84d702b3..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/core/signals.py
+++ /dev/null
@@ -1,73 +0,0 @@
-"""
-Scrapy core signals
-"""
-from pydispatch import dispatcher
-
-from scrapy import log
-
-# After the execution engine has started
-# args: None
-engine_started = object()
-
-# After the execution engine has stopped
-# args: None
-engine_stopped = object()
-
-# Before opening a new domain for crawling
-# args: domain, spider
-domain_open = object()
-
-# After a domain has been opened for crawling
-# args: domain, spider
-domain_opened = object()
-
-# When a domain has no remaining requests to process
-# args: domain, spider
-domain_idle = object()
-
-# After a domain has been closed
-# args: domain, spider, status
-# status is a string and its possible values are: "finished" or "cancelled"
-domain_closed = object()
-
-# domain has been initialized (successful or not)
-# args: domain, spider, status
-domain_initialized = object()
-
-# New request received from spiders
-# args: request, spider, response
-# response is the response (fed to the spider) which generated the request
-request_received = object()
-
-# When request is sent in the downloader
-# args: request, spider
-request_uploaded = object()
-
-# When new response is received (by the engine) from the downloader (middleware)
-# args: response, spider
-response_received = object()
-
-# When response arrives from the downloader
-# args: response, spider
-response_downloaded = object()
-
-# After item is returned from spiders
-# args: item, spider, response
-item_scraped = object()
-
-# After item is processed by pipeline and pass all its stages
-# args: item, spider, response, pipe_output
-item_passed = object()
-
-# After item is dropped by pipeline
-# args: item, spider, response, exception
-item_dropped = object()
-
-def send_catch_log(signal, sender=None, **kwargs):
- """
- Send a signal and log any exceptions raised by its listeners
- """
- try:
- dispatcher.send(signal=signal, sender=sender, **kwargs)
- except:
- log.exc("Exception catched on signal dispatch")
diff --git a/scrapy/branches/cluster-refactor/scrapy/extension/__init__.py b/scrapy/branches/cluster-refactor/scrapy/extension/__init__.py
deleted file mode 100644
index dc96e1194..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/extension/__init__.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""
-This module contains the ExtensionManager which takes care of loading and
-keeping track of all enabled extensions. It also contains an instantiated
-ExtensionManager (extensions) to be used as singleton.
-"""
-from scrapy.core.exceptions import NotConfigured
-from scrapy.utils.misc import load_class
-from scrapy import log
-from scrapy.conf import settings
-
-class ExtensionManager(object):
-
- def __init__(self):
- self.loaded = False
- self.enabled = {}
- self.disabled = {}
-
- def load(self):
- """
- Load enabled extensions in settings module
- """
-
- self.loaded = False
- self.enabled.clear()
- self.disabled.clear()
- for extension_path in settings.getlist('EXTENSIONS'):
- try:
- cls = load_class(extension_path)
- self.enabled[cls.__name__] = cls()
- except NotConfigured, e:
- self.disabled[cls.__name__] = extension_path
- if e.args:
- log.msg(e)
- self.loaded = True
-
- def reload(self):
- self.load()
-
-extensions = ExtensionManager()
diff --git a/scrapy/branches/cluster-refactor/scrapy/http/__init__.py b/scrapy/branches/cluster-refactor/scrapy/http/__init__.py
deleted file mode 100644
index d9fef2626..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/http/__init__.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""
-Module containing all HTTP related classes
-
-Use this module (instead of the more specific ones) when importing Headers,
-Request, Response, ResponseBody and Url outside this module.
-"""
-
-from scrapy.http.url import Url
-from scrapy.http.headers import Headers
-from scrapy.http.request import Request
-from scrapy.http.response import Response, ResponseBody
diff --git a/scrapy/branches/cluster-refactor/scrapy/http/headers.py b/scrapy/branches/cluster-refactor/scrapy/http/headers.py
deleted file mode 100644
index 54d74a9ef..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/http/headers.py
+++ /dev/null
@@ -1,97 +0,0 @@
-from scrapy.utils.datatypes import CaselessDict
-
-def headers_raw_to_dict(headers_raw):
- """
- Convert raw headers (single multi-line string)
- to the dictionary.
-
- For example:
- >>> headers_raw_to_dict("Content-type: text/html\\n\\rAccept: gzip\\n\\n")
- {'Content-type': ['text/html'], 'Accept': ['gzip']}
-
- Incorrect input:
- >>> headers_raw_to_dict("Content-typt gzip\\n\\n")
- {}
-
- Argument is None:
- >>> headers_raw_to_dict(None)
- """
- if headers_raw is None:
- return None
- return dict([
- (header_item[0].strip(), [header_item[1].strip()])
- for header_item
- in [
- header.split(':', 1)
- for header
- in headers_raw.splitlines()]
- if len(header_item) == 2])
-
-def headers_dict_to_raw(headers_dict):
- """
- Returns a raw HTTP headers representation of headers
-
- For example:
- >>> headers_dict_to_raw({'Content-type': 'text/html', 'Accept': 'gzip'})
- 'Content-type: text/html\\r\\nAccept: gzip'
- >>> from twisted.python.util import InsensitiveDict
- >>> td = InsensitiveDict({'Content-type': ['text/html'], 'Accept': ['gzip']})
- >>> headers_dict_to_raw(td)
- 'Content-type: text/html\\r\\nAccept: gzip'
-
- Argument is None:
- >>> headers_dict_to_raw(None)
-
- """
- if headers_dict is None:
- return None
- raw_lines = []
- for key, value in headers_dict.items():
- if isinstance(value, (str, unicode)):
- raw_lines.append("%s: %s" % (key, value))
- elif isinstance(value, (list, tuple)):
- for v in value:
- raw_lines.append("%s: %s" % (key, v))
- return '\r\n'.join(raw_lines)
-
-class Headers(CaselessDict):
- def __init__(self, dictorstr=None, fromdict=None, fromstr=None, encoding='utf-8'):
- self.encoding = encoding
-
- if dictorstr is not None:
- if isinstance(dictorstr, dict):
- d = dictorstr
- elif isinstance(dictorstr, basestring):
- d = headers_raw_to_dict(dictorstr)
- elif fromdict is not None:
- d = fromdict
- elif fromstr is not None:
- d = headers_raw_to_dict(fromstr)
- else:
- d = {}
-
- # can't use CaselessDict.__init__(self, d) because it doesn't call __setitem__
- for k,v in d.iteritems():
- self.__setitem__(k.lower(), v)
-
- def normkey(self, key):
- return key.title()
-
- def __setitem__(self, key, value):
- """Headers must not be unicode"""
- if isinstance(key, unicode):
- key = key.encode(self.encoding)
- if isinstance(value, unicode):
- value = value.encode(self.encoding)
- super(Headers, self).__setitem__(key, value)
-
- def tostring(self):
- return headers_dict_to_raw(self)
-
- def rawsize(self):
- """Estimated size of raw HTTP headers, in bytes"""
- # For each header line you have 4 extra chars: ": " and CRLF
- return sum([len(k)+len(v)+4 for k, v in self.iteritems()])
-
- def to_string(self):
- return headers_dict_to_raw(self)
diff --git a/scrapy/branches/cluster-refactor/scrapy/http/request.py b/scrapy/branches/cluster-refactor/scrapy/http/request.py
deleted file mode 100644
index 5b9e5841a..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/http/request.py
+++ /dev/null
@@ -1,188 +0,0 @@
-import urllib
-import warnings
-import hashlib
-from copy import copy
-from base64 import urlsafe_b64encode
-
-from twisted.internet import defer
-
-from scrapy.http.url import Url
-from scrapy.http.headers import Headers
-from scrapy.utils.url import safe_url_string
-from scrapy.utils.c14n import canonicalize
-from scrapy.utils.defer import chain_deferred
-
-class Request(object):
- def __init__(self, url, callback=None, context=None, method=None, body=None, headers=None, cookies=None,
- referer=None, url_encoding='utf-8', link_text='', http_user='', http_pass='', dont_filter=None,
- fingerprint_params=None, domain=None):
-
- self.encoding = url_encoding # this one has to be set first
- self.set_url(url)
-
- # method
- if method is None and body is not None:
- method = 'POST' # backwards compatibility
- self.method = method.upper() if method else 'GET'
- assert isinstance(self.method, basestring), 'Request method argument must be str or unicode, got %s: %s' % (type(method), method)
-
- # body
- if isinstance(body, dict):
- body = urllib.urlencode(body)
- self.body = body
-
- # callback / deferred
- if callable(callback):
- callback = defer.Deferred().addCallback(callback)
- self.deferred = callback or defer.Deferred()
-
- # request cookies
- self.cookies = cookies or {}
- # request headers
- self.headers = Headers(headers or {}, encoding=url_encoding)
- # persistent context across requests
- self.context = context or {}
- # dont_filter be filtered by scheduler
- self.dont_filter = dont_filter
- # fingerprint parameters
- self.fingerprint_params = fingerprint_params or {}
- self._fingerprint = None
- # shortcut for setting referer
- if referer is not None:
- self.headers['referer'] = referer
- # http auth
- if http_user or http_pass:
- self.httpauth(http_user, http_pass)
- self.depth = 0
- self.link_text = link_text
- #allows to directly specify the spider for the request
- self.domain = domain
-
- def append_callback(self, callback, *args, **kwargs):
- if isinstance(callback, defer.Deferred):
- return chain_deferred(self.deferred, callback)
- return self.deferred.addCallback(callback, *args, **kwargs)
-
- def prepend_callback(self, func, *args, **kwargs):
- if callable(func):
- func = defer.Deferred().addCallback(func, *args, **kwargs)
- assert isinstance(func, defer.Deferred), 'prepend_callback expects a callable or defer.Deferred instance, got %s' % type(func)
- self.deferred = chain_deferred(func, self.deferred)
- return self.deferred
-
- def set_url(self, url):
- assert isinstance(url, basestring), 'Request url argument must be str or unicode, got %s:' % type(url).__name__
- decoded_url = url if isinstance(url, unicode) else url.decode(self.encoding)
- self._url = Url(safe_url_string(decoded_url, self.encoding))
- self._fingerprint = None # invalidate cached fingerprint
- url = property(lambda x: x._url, set_url)
-
- def httpauth(self, http_user, http_pass):
- if not http_user:
- http_user = ''
- if not http_pass:
- http_pass = ''
- self.headers['Authorization'] = 'Basic ' + urlsafe_b64encode("%s:%s" % (http_user, http_pass))
-
- def __getitem__(self, key):
- warnings.warn("Request tuples have been deprecated, Request objects are now used. Index mappings: 0 -> r.url, 1 -> r.body, 2 -> r.deferred, 3 -> r.options ", DeprecationWarning)
- return (self.url, self.body, self.deferred, {})[key]
-
- def __str__(self):
- if self.method != 'GET':
- return "<(%s) %s>" % (self.method, self.url)
- return "<%s>" % self.url
-
- def __len__(self):
- """Return raw HTTP request size"""
- return len(self.to_string())
-
- def traceinfo(self):
- fp = self.fingerprint()
- version = '%s..%s' % (fp[:4], fp[-4:])
- return "<Request: %s %s (%s)>" % (self.method, self.url, version)
-
- def __repr__(self):
- d = {
- 'method': self.method,
- 'url': self.url,
- 'headers': self.headers,
- 'cookies': self.cookies,
- 'body': self.body,
- 'context': self.context
- }
- return "%s(%s)" % (self.__class__.__name__, repr(d))
-
- def copy(self):
- """Clone request except `context` attribute"""
- new = copy(self)
- for att in self.__dict__:
- if att not in ['context', 'url', 'deferred', '_fingerprint']:
- value = getattr(self, att)
- setattr(new, att, copy(value))
- new.deferred = defer.Deferred()
- new.context = self.context # requests shares same context dictionary
- new._fingerprint = None # reset fingerprint
- return new
-
- def fingerprint(self):
- """Returns unique resource fingerprint with caching support"""
- if not self._fingerprint or self.fingerprint_params:
- self.update_fingerprint()
- return self._fingerprint
-
- def update_fingerprint(self):
- """Update request fingerprint, based on its current data. A request
- fingerprint is a hash which uniquely identifies the HTTP resource"""
-
- headers = {}
- if self.fingerprint_params:
- if 'tamperfunc' in self.fingerprint_params:
- tamperfunc = self.fingerprint_params['tamperfunc']
- assert callable(tamperfunc)
- req = tamperfunc(self.copy())
- assert isinstance(req, Request)
- try:
- del req.fingerprint_params['tamperfunc']
- except KeyError:
- pass
- return req.fingerprint()
-
- if self.headers:
- if 'include_headers' in self.fingerprint_params:
- keys = [k.lower() for k in self.fingerprint_params['include_headers']]
- headers = dict([(k, v) for k, v in self.headers.items() if k.lower() in keys])
- elif 'exclude_headers' in self.fingerprint_params:
- keys = [k.lower() for k in self.fingerprint_params['exclude_headers']]
- headers = dict([(k, v) for k, v in self.headers.items() if k.lower() not in keys])
-
- # fingerprint generation
- fp = hashlib.sha1()
- fp.update(canonicalize(self.url))
- fp.update(self.method)
-
- if self.body and self.method in ['POST', 'PUT']:
- fp.update(self.body)
-
- if headers:
- for k, v in sorted([(k.lower(), v) for k, v in headers.items()]):
- fp.update(k)
- fp.update(v)
-
- self._fingerprint = fp.hexdigest()
-
- def to_string(self):
- """ Return raw HTTP request representation (as string). This is
- provided only for reference since it's not the actual stream of bytes
- that will be send when performing the request (that's controlled by
- Twisted).
- """
-
- s = "%s %s HTTP/1.1\r\n" % (self.method, self.url)
- s += "Host: %s\r\n" % self.url.hostname
- s += self.headers.to_string() + "\r\n"
- s += "\r\n"
- if self.body:
- s += self.body
- s += "\r\n"
- return s
diff --git a/scrapy/branches/cluster-refactor/scrapy/http/response.py b/scrapy/branches/cluster-refactor/scrapy/http/response.py
deleted file mode 100644
index 0ec3a2f4b..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/http/response.py
+++ /dev/null
@@ -1,194 +0,0 @@
-import re
-import hashlib
-import copy
-
-from BeautifulSoup import UnicodeDammit
-
-from scrapy.http.url import Url
-from scrapy.http.headers import Headers
-
-from twisted.web import http
-reason_phrases = http.RESPONSES
-
-class Response(object) :
- """HTTP responses
-
- Arguments:
- * Domain - the spider domain for the page
- * url - the final url for the resource
- * original_url - the url requested
- * headers - HTTP headers
- * status - HTTP status code
- * body - Body object containing the content of the response
- """
- _ENCODING_RE = re.compile(r'charset=([\w-]+)', re.I)
-
- def __init__(self, domain, url, original_url=None, headers=None, status=200, body=None):
- self.domain = domain
- self.url = Url(url)
- self.original_url = Url(original_url) if original_url else url # different if redirected or escaped
- self.headers = Headers(headers or {})
- self.status = status
- if isinstance(body, str):
- self.body = ResponseBody(body, self.headers_encoding())
- else:
- self.body = body
- self.cached = False
- self.request = None # request which originated this response
-
- def version(self):
- """A hash of the contents of this response"""
- if not hasattr(self, '_version'):
- self._version = hashlib.sha1(self.body.to_string()).hexdigest()
- return self._version
-
- def headers_encoding(self):
- content_type = self.headers.get('Content-Type')
- if content_type:
- encoding = self._ENCODING_RE.search(content_type[0])
- if encoding:
- return encoding.group(1)
-
- def __repr__(self):
- return "Response(domain=%s, url=%s, original_url=%s, headers=%s, status=%s, body=%s)" % \
- (repr(self.domain), repr(self.url), repr(self.original_url), repr(self.headers), repr(self.status), repr(self.body))
-
- def __str__(self):
- version = '%s..%s' % (self.version()[:4], self.version()[-4:])
- return "<Response: %s %s (%s)>" % (self.status, self.url, version)
-
- def __len__(self):
- """Return raw HTTP response size"""
- return len(self.to_string())
-
- def info(self):
- return "<Response status=%s domain=%s url=%s headers=%s" % (self.status, self.domain, self.url, self.headers)
-
- def copy(self):
- """Create a new Response based on the current one"""
- return self.replace()
-
- def replace(self, **kw):
- """Create a new Response with the same attributes except for those given new values.
-
- Example: newresp = oldresp.replace(body="New body")
- """
- def sameheaders():
- return copy.deepcopy(self.headers)
- def samebody():
- return copy.deepcopy(self.body)
- newresp = Response(kw.get('domain', self.domain),
- kw.get('url', self.url),
- original_url=kw.get('original_url', self.original_url),
- headers=kw.get('headers', sameheaders()),
- status=kw.get('status', self.status),
- body=kw.get('body', samebody()))
- return newresp
-
- def to_string(self):
- """
- Return raw HTTP response representation (as string). This is provided
- only for reference, since it's not the exact stream of bytes that was
- received (that's not exposed by Twisted).
- """
-
- s = "HTTP/1.1 %s %s\r\n" % (self.status, reason_phrases[int(self.status)])
- s += self.headers.to_string() + "\r\n"
- s += "\r\n"
- if self.body:
- s += self.body.to_string()
- s += "\r\n"
- return s
-
-class ResponseBody(object):
- """The body of an HTTP response
-
- This handles conversion to unicode and various character encodings.
- """
-
- _template = r'''%s\s*=\s*["']?\s*%s\s*["']?'''
-
- _httpequiv_re = _template % ('http-equiv', 'Content-Type')
- _content_re = _template % ('content', r'(?P<mime>[^;]+);\s*charset=(?P<charset>[\w-]+)')
- _encoding_re = _template % ('encoding', r'(?P<charset>[\w-]+)')
-
- XMLDECL_RE = re.compile(r'<\?xml\s.*?%s' % _encoding_re, re.I)
-
- METATAG_RE = re.compile(r'<meta\s+%s\s+%s' % (_httpequiv_re, _content_re), re.I)
- METATAG_RE2 = re.compile(r'<meta\s+%s\s+%s' % (_content_re, _httpequiv_re), re.I)
-
- def __init__(self, content, declared_encoding=None):
- self._content = content
- self._unicode_content = None
- self.declared_encoding = declared_encoding
- self._expected_encoding = None
- self._actual_encoding = None
-
- def to_string(self, encoding=None):
- """Get the body as a string. If an encoding is specified, the
- body will be encoded using that encoding.
- """
- if encoding in (None, self.declared_encoding, self._actual_encoding):
- return self._content
- # should we cache this decode?
- return self.to_unicode().encode(encoding)
-
- def to_unicode(self):
- """Return body as unicode string"""
- if self._unicode_content:
- return self._unicode_content
- proposed = self.get_expected_encoding()
- dammit = UnicodeDammit(self._content, [proposed])
- self._actual_encoding = dammit.originalEncoding
- # FIXME sometimes dammit.unicode fails, even when it recognizes the encoding correctly
- self._unicode_content = dammit.unicode
- return self._unicode_content
-
- def get_content(self):
- """Return original content bytes"""
- return self._content
-
- def get_declared_encoding(self):
- """Get the value of the declared encoding passed to the
- constructor.
- """
- return self.declared_encoding
-
- def get_real_encoding(self):
- """Get the real encoding, by trying first the expected and then the
- actual encoding.
- """
- if self.get_expected_encoding():
- result = self.get_expected_encoding()
- else:
- self.to_unicode()
- result = self._actual_encoding
- return result
-
- def get_expected_encoding(self):
- """Get the expected encoding for the page. This is the declared
- encoding, or the meta tag encoding.
- """
- if self._expected_encoding:
- return self._expected_encoding
- proposed = self.declared_encoding
- if not proposed:
- chunk = self._content[:5000]
- match = self.XMLDECL_RE.search(chunk) or self.METATAG_RE.search(chunk) or self.METATAG_RE2.search(chunk)
- if match:
- proposed = match.group("charset")
- self._expected_encoding = proposed
- return proposed
-
- def __repr__(self):
- return "ResponseBody(content=%s, declared_encoding=%s)" % (repr(self._content), repr(self.declared_encoding))
-
- def __str__(self):
- return self.to_string()
-
- def __unicode__(self):
- return self.to_unicode()
-
- def __len__(self):
- return len(self._content)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/item/__init__.py b/scrapy/branches/cluster-refactor/scrapy/item/__init__.py
deleted file mode 100644
index 35982e691..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/item/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from scrapy.item.models import ScrapedItem
diff --git a/scrapy/branches/cluster-refactor/scrapy/item/adaptors.py b/scrapy/branches/cluster-refactor/scrapy/item/adaptors.py
deleted file mode 100644
index 17cd58644..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/item/adaptors.py
+++ /dev/null
@@ -1,241 +0,0 @@
-import re
-
-from traceback import format_exc
-
-from scrapy.xpath.selector import XPathSelector, XPathSelectorList
-from scrapy.utils.python import unique, flatten
-from scrapy.utils.markup import replace_tags, remove_entities
-from scrapy.utils.misc import extract_regex
-
-class AdaptorPipe:
- def __init__(self, adaptors_pipe=None):
- """
- Receives a dictionary that maps attribute_name to a list of adaptor functions
- """
- self.pipes = adaptors_pipe or {}
-
- def append_adaptor(self, attrname, adaptor):
- """
- Add an adaptor at the end of the provided attribute's pipeline
- """
- if callable(adaptor):
- if self.pipes.get(attrname):
- self.pipes[attrname].append(adaptor)
- else:
- self.pipes[attrname] = [adaptor]
-
- def execute(self, attrname, value, debug=False):
- """
- Execute pipeline for attribute name "attrname" and value "value".
- """
- for function in self.pipes.get(attrname, []):
- try:
- if debug:
- print " %07s | input >" % function.func_name, repr(value)
- value = function(value)
- if debug:
- print " %07s | output>" % function.func_name, repr(value)
-
- except Exception, e:
- print "Error in '%s' adaptor. Traceback text:" % function.func_name
- print format_exc()
- return
-
- return value
-
-
-############
-# Adaptors #
-############
-def extract(location):
- """
- This adaptor extracts a list of strings
- from 'location', which can be either a list (or tuple),
- or an XPathSelector.
-
- This function *always* returns a list.
- """
- if not location:
- return []
- elif isinstance(location, XPathSelectorList):
- return flatten([extract(o) for o in location])
- elif isinstance(location, XPathSelector):
- return location.extract()
- elif isinstance(location, (list, tuple)):
- return flatten(location)
- elif isinstance(location, basestring):
- return [location]
-
-def _absolutize_links(rel_links, current_url, base_url):
- abs_links = []
- for link in rel_links:
- if link.startswith('/'):
- abs_links.append('%s%s' % (base_url, link))
- elif link.startswith('http://'):
- abs_links.append(link)
- else:
- abs_links.append('%s/%s' % (current_url, link))
- return abs_links
-
-def extract_links(locations):
- """
- This adaptor receives either an XPathSelector containing
- the desired locations for finding urls, or a tuple like (xpath, regexp)
- containing the xpath locations to look in, and a regular expression
- to parse those locations.
-
- In any case, this adaptor returns a list of absolute urls extracted.
- """
- ret = []
- if locations:
- regexp = None
- if isinstance(locations, XPathSelector):
- locations = XPathSelectorList([locations])
- elif isinstance(locations, tuple):
- locations, regexp = locations
-
- if isinstance(locations, XPathSelectorList):
- if regexp:
- ret = locations.re(regexp)
- else:
- for selector in locations:
- if selector.xmlNode.type == 'element':
- if selector.xmlNode.name == 'a':
- children = selector.x('child::*')
- if len(children) > 1:
- ret.extend(selector.x('.//@href'))
- ret.extend(selector.x('.//@src'))
- elif len(children) == 1 and children[0].xmlNode.name == 'img':
- ret.extend(children.x('@src'))
- else:
- ret.extend(selector.x('@href'))
- elif selector.xmlNode.name == 'img':
- ret.extend(selector.x('@src'))
- else:
- ret.extend(selector.x('.//@href'))
- ret.extend(selector.x('.//@src'))
- elif selector.xmlNode.type == 'attribute' and selector.xmlNode.name in ['href', 'src']:
- ret.append(selector)
- ret = [selector.extract() for selector in ret]
- current_url, base_url = re.search(r'((http://(?:www\.)?[\w\d\.-]+?)(?:/|$).*)', locations[0].response.url).groups()
- ret = _absolutize_links(ret, current_url, base_url)
- return ret
-
-def to_unicode(value):
- """
- Receives a list of strings, converts
- it to unicode, and returns a new list.
- """
- if isinstance(value, (list, tuple)):
- return [ unicode(v) for v in value ]
- else:
- raise TypeError('to_unicode adaptor must receive a list or a tuple.')
-
-def regex(expr):
- """
- This factory function returns a ready-to-use
- adaptor for the specified regular expression.
- This adaptor will accept either an XPathSelectorList
- or a list of strings, and will apply the provided regular
- expression to each of its members.
-
- This adaptor always returns a list of strings.
- """
- def _regex(value):
- if isinstance(value, (XPathSelector, XPathSelectorList)):
- return value.re(expr)
- elif isinstance(value, list) and value:
- return flatten([extract_regex(expr, string, 'utf-8') for string in value])
- return value
- return _regex
-
-def unquote_all(value):
- """
- Receives a list of strings, removes all of the
- entities the strings may have, and returns
- a new list
- """
- return [ remove_entities(v) for v in value ]
-
-def unquote(value):
- """
- Receives a list of strings, removes all of the entities
- the strings may have (except for &lt; and &amp;), and
- returns a new list
- """
- return [ remove_entities(v, keep=['lt', 'amp']) for v in value ]
-
-def remove_tags(value):
- return [ replace_tags(v) for v in value ]
-
-_remove_root_re = re.compile(r'^\s*<.*?>(.*)</.*>\s*$', re.DOTALL)
-def _remove_root(value):
- m = _remove_root_re.search(value)
- if m:
- value = m.group(1)
- return value
-
-def remove_root(value):
- return [ _remove_root(v) for v in value ]
-
-_clean_spaces_re = re.compile("\s+", re.U)
-def remove_multispaces(value):
- return [ _clean_spaces_re.sub(' ', v) for v in value ]
-
-def strip(value):
- return [ v.strip() for v in value ]
-
-def drop_empty_elements(value):
- return [ v for v in value if v ]
-
-def delist(value):
- return ' '.join(value)
-
-
-
-#############
-# Pipelines #
-#############
-"""
-The following methods automatically generate adaptor pipelines
-for some basic datatypes, according to the parameters you pass them.
-"""
-def single_pipeline(remove_root=True, remove_tags=True, do_unquote=True):
- pipe = [ extract,
- unique,
- to_unicode,
- drop_empty_elements,
- remove_multispaces,
- strip,
- ]
- if remove_root:
- pipe.insert(4, remove_root)
- if remove_tags:
- pipe.insert(5, remove_tags)
- if do_unquote:
- pipe.append(unquote)
- return pipe + [delist]
-
-def url_pipeline():
- return [ extract_links,
- unique,
- to_unicode,
- drop_empty_elements,
- ]
-
-def list_pipeline(do_extract=True):
- pipe = []
- if do_extract:
- pipe.append(extract)
- return pipe + [ unique,
- to_unicode,
- drop_empty_elements,
- unquote,
- remove_tags,
- remove_root,
- strip,
- ]
-
-def list_join_pipeline(delimiter='\t'):
- return list_pipeline() + [delimiter.join]
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/item/models.py b/scrapy/branches/cluster-refactor/scrapy/item/models.py
deleted file mode 100644
index a68568104..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/item/models.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from scrapy.item.adaptors import AdaptorPipe
-
-class ScrapedItem(object):
- """
- This is the base class for all scraped items.
- 'guid' attribute is required, and is an attribute
- that identifies uniquely the given scraped item.
- """
-
- def setadaptors(self, adaptors_pipe):
- """
- Set adaptors to use for this item. Receives a dict of adaptors and
- returns the item itself.
- """
- object.__setattr__(self, '_adaptors_pipe', AdaptorPipe(adaptors_pipe))
- return self
-
- def append_adaptor(self, attrname, adaptor):
- self._adaptors_pipe.append_adaptor(attrname, adaptor)
-
- def attribute(self, attrname, value):
- value = self._adaptors_pipe.execute(attrname, value)
- if not hasattr(self, attrname) or not getattr(self, attrname):
- setattr(self, attrname, value)
diff --git a/scrapy/branches/cluster-refactor/scrapy/item/pipeline.py b/scrapy/branches/cluster-refactor/scrapy/item/pipeline.py
deleted file mode 100644
index 5adc0555e..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/item/pipeline.py
+++ /dev/null
@@ -1,101 +0,0 @@
-from scrapy import log
-from scrapy.core.exceptions import DropItem, NotConfigured
-from scrapy.item import ScrapedItem
-from scrapy.utils.misc import load_class
-from scrapy.utils.defer import defer_succeed, mustbe_deferred
-from scrapy.conf import settings
-
-class ItemPipeline(object):
-
- def __init__(self):
- self.loaded = False
- self.pipeline = []
- self.domaininfo = {}
- self.load()
-
- def load(self):
- """
- Load pipelines stages defined in settings module
- """
- for stage in settings.getlist('ITEM_PIPELINES') or ():
- cls = load_class(stage)
- if cls:
- try:
- stageinstance = cls()
- self.pipeline.append(stageinstance)
- except NotConfigured:
- pass
- log.msg("Enabled item pipelines: %s" % ", ".join([type(p).__name__ for p in self.pipeline]))
- self.loaded = True
-
- def open_domain(self, domain):
- self.domaininfo[domain] = set()
- for pipe in self.pipeline:
- if hasattr(pipe, 'open_domain'):
- pipe.open_domain(domain)
-
- def close_domain(self, domain):
- for pipe in self.pipeline:
- if hasattr(pipe, 'close_domain'):
- pipe.close_domain(domain)
- del self.domaininfo[domain]
-
- def is_idle(self):
- return not self.domaininfo
-
- def domain_is_idle(self, domain):
- return not self.domaininfo.get(domain)
-
- def pipe(self, item, spider, response):
- """
- item pipelines are instanceable classes that defines a `pipeline` method
- that takes ScrapedItem as input and returns ScrapedItem.
-
- The output from one stage is the input of the next.
-
- Raising DropItem stops pipeline.
-
- This pipeline is configurable with the ITEM_PIPELINES setting
- """
- if not self.pipeline:
- return defer_succeed(item)
-
- domain = spider.domain_name
- pipeline = self.pipeline[:]
- current_stage = pipeline[0]
- info = self.domaininfo[domain]
- info.add(item)
-
- def _next_stage(item):
- assert isinstance(item, ScrapedItem), 'Pipeline stages must return a ScrapedItem or raise DropItem'
- if not pipeline:
- return item
-
- current_stage = pipeline.pop(0)
- log.msg("_%s_ Pipeline stage: %s" % (item, type(current_stage).__name__), log.TRACE, domain=domain)
-
- d = mustbe_deferred(current_stage.process_item, domain, response, item)
- d.addCallback(_next_stage)
- return d
-
- def _ondrop(_failure):
- ex = _failure.value
- if isinstance(ex, DropItem):
- # TODO: current_stage is not working, check why
- #log.msg("%s: Dropped %s - %s" % (type(current_stage).__name__, item, str(ex)), log.DEBUG, domain=domain)
- log.msg("Dropped %s - %s" % (item, str(ex)), log.DEBUG, domain=domain)
- return _failure
- else:
- # TODO: current_stage is not working, check why
- #log.msg('%s: Error processing %s - %s' % (type(current_stage).__name__, item, _failure), log.ERROR, domain=domain)
- log.msg('Error processing %s - %s' % (item, _failure), log.ERROR, domain=domain)
-
- def _pipeline_finished(_):
- log.msg("_%s_ Pipeline finished" % item, log.TRACE, domain=domain)
- info.remove(item)
- return _
-
- deferred = mustbe_deferred(_next_stage, item)
- deferred.addErrback(_ondrop)
- deferred.addBoth(_pipeline_finished)
- return deferred
diff --git a/scrapy/branches/cluster-refactor/scrapy/link/__init__.py b/scrapy/branches/cluster-refactor/scrapy/link/__init__.py
deleted file mode 100644
index 069d22d19..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/link/__init__.py
+++ /dev/null
@@ -1,68 +0,0 @@
-"""
-LinkExtractor provides en efficient way to extract links from pages
-"""
-
-from scrapy.utils.python import FixedSGMLParser
-from scrapy.utils.url import urljoin_rfc as urljoin
-
-class LinkExtractor(FixedSGMLParser):
- """LinkExtractor are used to extract links from web pages. They are
- instantiated and later "applied" to a Response using the extract_urls
- method which must receive a Response object and return a dict whoose keys
- are the (absolute) urls to follow, and its values any arbitrary data. In
- this case the values are the text of the hyperlink.
-
- This is the base LinkExtractor class that provides enough basic
- functionality for extracting links to follow, but you could override this
- class or create a new one if you need some additional functionality. The
- only requisite is that the new (or overrided) class must provide a
- extract_urls method that receives a Response and returns a dict with the
- links to follow as its keys.
-
- The constructor arguments are:
-
- * tag (string or function)
- * a tag name which is used to search for links (defaults to "a")
- * a function which receives a tag name and returns whether to scan it
- * attr (string or function)
- * an attribute name which is used to search for links (defaults to "href")
- * a function which receives an attribute name and returns whether to scan it
- """
-
- def __init__(self, tag="a", attr="href"):
- FixedSGMLParser.__init__(self)
- self.scan_tag = tag if callable(tag) else lambda t: t == tag
- self.scan_attr = attr if callable(attr) else lambda a: a == attr
- self.inside_link = False
-
- def extract_urls(self, response):
- self.reset()
- self.feed(response.body.to_string())
- self.close()
-
- base_url = self.base_url if self.base_url else response.url
- urls = {}
- for link, text in self.links.iteritems():
- urls[urljoin(base_url, link)] = text
- return urls
-
- def reset(self):
- FixedSGMLParser.reset(self)
- self.links = {}
- self.base_url = None
-
- def unknown_starttag(self, tag, attrs):
- if tag == 'base':
- self.base_url = dict(attrs).get('href')
- if self.scan_tag(tag):
- for attr, value in attrs:
- if self.scan_attr(attr):
- self.links[value] = ""
- self.inside_link = value
-
- def unknown_endtag(self, tag):
- self.inside_link = False
-
- def handle_data(self, data):
- if self.inside_link and not self.links.get(self.inside_link, None):
- self.links[self.inside_link] = data
diff --git a/scrapy/branches/cluster-refactor/scrapy/link/extractors.py b/scrapy/branches/cluster-refactor/scrapy/link/extractors.py
deleted file mode 100644
index 2153da7e1..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/link/extractors.py
+++ /dev/null
@@ -1,76 +0,0 @@
-"""
-This module provides some LinkExtractors, which extend that base LinkExtractor
-(scrapy.link.LinkExtractor) with some useful features.
-
-"""
-
-import re
-
-from scrapy.link import LinkExtractor
-from scrapy.utils.url import canonicalize_url, url_is_from_any_domain
-from scrapy.utils.response import new_response_from_xpaths
-from scrapy.utils.misc import dict_updatedefault
-
-_re_type = type(re.compile("", 0))
-
-_matches = lambda url, regexs: any((r.search(url) for r in regexs))
-_is_valid_url = lambda url: url.split('://', 1)[0] in set(['http', 'https', 'file'])
-
-class RegexLinkExtractor(LinkExtractor):
- """RegexLinkExtractor implements extends the base LinkExtractor by
- providing several mechanisms to extract the links.
-
- It's constructor parameters are:
-
- allow - list of regexes that the (absolute urls) must match to be extracted
- deny - ignore urls that match any of these regexes
- allow_domains - only extract urls from these domains
- deny_domains - ignore urls from these dmoains
- tags - look for urls in this tags
- attrs - look for urls in this attrs
- canonicalize - canonicalize all extracted urls using scrapy.utils.url.canonicalize_url
-
- Both 'allow' and 'deny' arguments can be a list of regexes strings or regex
- python objects (already compiled)
-
- Url matching is always performed against the absolute urls, never the
- relative urls found in pages.
-
- """
-
- def __init__(self, allow=(), deny=(), allow_domains=(), deny_domains=(), restrict_xpaths=(),
- tags=('a', 'area'), attrs=('href'), canonicalize=True):
- self.allow_res = [x if isinstance(x, _re_type) else re.compile(x) for x in allow]
- self.deny_res = [x if isinstance(x, _re_type) else re.compile(x) for x in deny]
- self.allow_domains = set(allow_domains)
- self.deny_domains = set(deny_domains)
- self.restrict_xpaths = restrict_xpaths
- self.canonicalize = canonicalize
- tag_func = lambda x: x in tags
- attr_func = lambda x: x in attrs
- LinkExtractor.__init__(self, tag=tag_func, attr=attr_func)
-
- def extract_urls(self, response):
- if self.restrict_xpaths:
- response = new_response_from_xpaths(response, self.restrict_xpaths)
-
- url_text = LinkExtractor.extract_urls(self, response)
- urls = [u for u in url_text.iterkeys() if _is_valid_url(u)]
-
- if self.allow_res:
- urls = [u for u in urls if _matches(u, self.allow_res)]
- if self.deny_res:
- urls = [u for u in urls if not _matches(u, self.deny_res)]
- if self.allow_domains:
- urls = [u for u in urls if url_is_from_any_domain(u, self.allow_domains)]
- if self.deny_domains:
- urls = [u for u in urls if not url_is_from_any_domain(u, self.deny_domains)]
-
- res = {}
- if self.canonicalize:
- for u in urls:
- res[canonicalize_url(u)] = url_text[u]
- else:
- for u in urls:
- res[u] = url_text[u]
- return res
diff --git a/scrapy/branches/cluster-refactor/scrapy/log/__init__.py b/scrapy/branches/cluster-refactor/scrapy/log/__init__.py
deleted file mode 100644
index 4c03a9121..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/log/__init__.py
+++ /dev/null
@@ -1,57 +0,0 @@
-"""
-Crawler logging functionality
-"""
-import sys
-
-from twisted.python import log
-
-from scrapy.conf import settings
-
-# Logging levels
-levels = {
- 0: "SILENT",
- 1: "CRITICAL",
- 2: "ERROR",
- 3: "WARNING",
- 4: "INFO",
- 5: "DEBUG",
- 6: "TRACE",
-}
-
-BOT_NAME = settings['BOT_NAME']
-
-# Set logging level module attributes
-for v, k in levels.items():
- setattr(sys.modules[__name__], k, v)
-
-# default logging level
-log_level = DEBUG
-
-started = False
-
-def start(logfile=None, loglevel=None, log_stdout=None):
- """ Init logging """
- if started or not settings.getbool('LOG_ENABLED'):
- return
-
- logfile = logfile or settings['LOGFILE']
- loglevel = loglevel or settings['LOGLEVEL']
- log_stdout = log_stdout or settings.getbool('LOG_STDOUT')
-
- file = open(logfile, 'a') if logfile else sys.stderr
- level = int(getattr(sys.modules[__name__], loglevel)) if loglevel else DEBUG
- log.startLogging(file, setStdout=log_stdout)
- setattr(sys.modules[__name__], 'log_level', level)
- setattr(sys.modules[__name__], 'started', True)
-
-def msg(message, level=INFO, component=BOT_NAME, domain=None):
- """ Log message according to the level """
- component = "%s/%s" % (BOT_NAME, domain) if domain else component
- if level <= log_level:
- log.msg("%s: %s" % (levels[level], message), system=component)
-
-def exc(message, level=ERROR, component=BOT_NAME, domain=None):
- from traceback import format_exc
- message = message + '\n' + format_exc()
- msg(message, level, component, domain)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/mail/__init__.py b/scrapy/branches/cluster-refactor/scrapy/mail/__init__.py
deleted file mode 100644
index 1078366e9..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/mail/__init__.py
+++ /dev/null
@@ -1,54 +0,0 @@
-import smtplib
-
-from email.MIMEMultipart import MIMEMultipart
-from email.MIMEBase import MIMEBase
-from email.MIMEText import MIMEText
-from email.Utils import COMMASPACE, formatdate
-from email import Encoders
-
-from scrapy import log
-from scrapy.core.exceptions import NotConfigured
-from scrapy.conf import settings
-
-class MailSender(object):
-
- def __init__(self, smtphost=None, mailfrom=None):
- self.smtphost = smtphost if smtphost else settings['MAIL_HOST']
- self.mailfrom = mailfrom if mailfrom else settings['MAIL_FROM']
-
- if not self.smtphost or not self.mailfrom:
- raise NotConfigured("MAIL_HOST and MAIL_FROM settings are required")
-
- def send(self, to, subject, body, cc=None, attachs=None):
- """
- Send mail to the given recipients
-
- - to: must be a list of email recipients
- - attachs must be a list of tuples: (attach_name, mimetype, file_object)
- - body and subjet must be a string
- """
-
- msg = MIMEMultipart()
- msg['From'] = self.mailfrom
- msg['To'] = COMMASPACE.join(to)
- msg['Date'] = formatdate(localtime=True)
- msg['Subject'] = subject
- rcpts = to[:]
- if cc:
- rcpts.extend(cc)
- msg['Cc'] = COMMASPACE.join(cc)
-
- msg.attach(MIMEText(body))
-
- for attach_name, mimetype, f in (attachs or []):
- part = MIMEBase(*mimetype.split('/'))
- part.set_payload(f.read())
- Encoders.encode_base64(part)
- part.add_header('Content-Disposition', 'attachment; filename="%s"' % attach_name)
- msg.attach(part)
-
- smtp = smtplib.SMTP(self.smtphost)
- smtp.sendmail(self.mailfrom, rcpts, msg.as_string())
- log.msg('Mail sent: To=%s Cc=%s Subject="%s"' % (to, cc, subject))
- smtp.close()
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/management/web.py b/scrapy/branches/cluster-refactor/scrapy/management/web.py
deleted file mode 100644
index f9d828546..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/management/web.py
+++ /dev/null
@@ -1,69 +0,0 @@
-import re
-import socket
-from datetime import datetime
-
-from twisted.internet import reactor
-from twisted.web import server, resource
-from pydispatch import dispatcher
-
-from scrapy.core.engine import scrapyengine
-from scrapy.conf import settings
-
-# web management signals
-webconsole_discover_module = object()
-
-urlpath_re = re.compile(r"^/(\w+)/")
-
-def banner(module=None):
- s = "<html>\n"
- s += "<head><title>Scrapy</title></head>\n"
- s += "<body>\n"
- s += "<h1><a href='/'>Scrapy web console</a></h1>\n"
- now = datetime.now()
- uptime = now - scrapyengine.start_time
- s += "<p>Bot: <b>%s</b> | Host: <b>%s</b> | Uptime: <b>%s</b> | Time: <b>%s</b> </p>\n" % (settings['BOT_NAME'], socket.gethostname(), str(uptime), str(now))
- if module:
- s += "<h2><a href='/%s/'>%s</a></h2>\n" % (module.webconsole_id, module.webconsole_name)
- return s
-
-class WebConsoleResource(resource.Resource):
- isLeaf = True
-
- @property
- def modules(self):
- if not hasattr(self, '_modules'):
- self._modules = {}
- for _, obj in dispatcher.send(signal=webconsole_discover_module, sender=self.__class__):
- self._modules[obj.webconsole_id] = obj
- return self._modules
-
- def render_GET(self, request):
- m = urlpath_re.search(request.path)
- if m:
- return self.modules[m.group(1)].webconsole_render(request)
- else:
- return self.module_list()
-
- render_POST = render_GET
-
- def module_list(self):
- s = banner()
- s += "<p>Available modules:</p>\n"
- s += "<ul>\n"
- for name, obj in self.modules.iteritems():
- s += "<li><a href='/%s/'>%s</a></li>\n" % (name, obj.webconsole_name)
- s += "</ul>\n"
- s += "</body>\n"
- s += "</html>\n"
- return s
-
-class WebConsole(server.Site):
-
- def __init__(self):
- if not settings.getbool('WEBCONSOLE_ENABLED'):
- return
-
- server.Site.__init__(self, WebConsoleResource())
- self.noisy = False
- port = settings.getint('WEBCONSOLE_PORT')
- scrapyengine.listenTCP(port, self)
diff --git a/scrapy/branches/cluster-refactor/scrapy/patches/monkeypatches.py b/scrapy/branches/cluster-refactor/scrapy/patches/monkeypatches.py
deleted file mode 100644
index bad1edebd..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/patches/monkeypatches.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""
-Monkey patches
-
-These are generally a bad idea.
-"""
-from twisted.web.client import HTTPClientFactory
-
-
-# Extend limit for BeautifulSoup parsing loops
-#import sys
-#sys.setrecursionlimit(7400)
-
-def apply_patches():
- patch_HTTPClientFactory_gotHeaders()
-
-
-# XXX: Monkeypatch for twisted.web.client-HTTPClientFactory
-# HTTPClientFactory.gotHeaders dies when parsing malformed cookies,
-# and the crawler is getting malformed cookies from this site.
-_old_gotHeaders = HTTPClientFactory.gotHeaders
-# Cookies format: http://www.ietf.org/rfc/rfc2109.txt
-# I have choosen not to filter based on this, so we don't filter invalid
-# values that could be managed correctly by twisted.
-#_COOKIES = re.compile(r'^[^=;]+=[^=;]*(;[^=;]+=[^=;])*$')
-
-def _is_good_cookie(cookie):
- """ Check if a given cookie would make gotHeaders raise an exception """
- cookparts = cookie.split(';')
- cook = cookparts[0]
- return len(cook.split('=', 1)) == 2
-
-def _new_gotHeaders(self, headers):
- """ Remove cookies that would make twisted raise an exception """
- if headers.has_key('set-cookie'):
- cookies = [cookie for cookie in headers['set-cookie']
- if _is_good_cookie(cookie)]
- if cookies:
- headers['set-cookie'] = cookies
- else:
- del headers['set-cookie']
-
- return _old_gotHeaders(self, headers)
-
-def patch_HTTPClientFactory_gotHeaders():
- setattr(HTTPClientFactory, 'gotHeaders', _new_gotHeaders)
diff --git a/scrapy/branches/cluster-refactor/scrapy/replay/__init__.py b/scrapy/branches/cluster-refactor/scrapy/replay/__init__.py
deleted file mode 100644
index 38512e824..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/replay/__init__.py
+++ /dev/null
@@ -1,187 +0,0 @@
-from __future__ import with_statement
-
-import os
-import cPickle as pickle
-import shutil
-import tempfile
-import tarfile
-
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy import log
-from scrapy.core.manager import scrapymanager
-from scrapy.core.exceptions import NotConfigured
-from scrapy.conf import settings
-
-class Replay(object):
- """
- This is the Replay extension, used to replay a crawling and see if the
- items scraped are the same.
- """
-
- def __init__(self, repfile, mode='play', usedir=False):
- """
- Available modes: record, play, update
-
- repfile can be either a dir (is usedir=True) or a tar.gz file (if
- usedir=False)
- """
-
- # XXX: this is ugly, and should be removed. but how?
- cachemw = 'scrapy.contrib.downloadermiddleware.cache.CacheMiddleware'
- if not cachemw in settings['DOWNLOADER_MIDDLEWARES']:
- raise NotConfigured("Cache middleware must be enabled to use Replay")
-
- self.recording = mode == 'record'
- self.updating = mode == 'update'
- self.playing = mode == 'play'
-
- self.options = {}
- self.scraped_old = {}
- self.scraped_new = {}
- self.passed_old = {}
- self.passed_new = {}
- self.responses_old = {}
- self.responses_new = {}
-
- #self._opendb(repfile, usedir)
- self._load(repfile, usedir)
-
- settings.overrides['CACHE2_DIR'] = self.cache2dir
- settings.overrides['CACHE2_EXPIRATION_SECS'] = -1
- settings.overrides['CACHE2_IGNORE_MISSING'] = self.playing or self.updating
- settings.overrides['CACHE2_SECTORIZE'] = False
-
- dispatcher.connect(self.engine_started, signal=signals.engine_started)
- dispatcher.connect(self.engine_stopped, signal=signals.engine_stopped)
- dispatcher.connect(self.item_scraped, signal=signals.item_scraped)
- dispatcher.connect(self.item_passed, signal=signals.item_passed)
- dispatcher.connect(self.response_received, signal=signals.response_received)
-
-
- def play(self, args=None, opts=None):
- if self.recording:
- raise ValueError("Replay.play() not available in record mode")
-
- args = args or self.options['args']
- opts = opts or self.options['opts']
- scrapymanager.runonce(*args, **opts)
-
- def record(self, args=None, opts=None):
- self.recording = True
- self.options.clear()
- self.options['args'] = args or []
- self.options['opts'] = opts or {}
-
- if os.path.exists(self.cache2dir):
- shutil.rmtree(self.cache2dir)
- else:
- os.mkdir(self.cache2dir)
-
- def update(self, args=None, opts=None):
- self.updating = True
- if (opts['pages']):
- args = self.options['args']
- opts = self.options['opts']
- settings.overrides['CACHE2_EXPIRATION_SECS'] = 0
- settings.overrides['CACHE2_IGNORE_MISSING'] = False
- else:
- self.play(args, opts)
-
- def engine_started(self):
- log.msg("Replay: recording session in %s" % self.repfile)
-
- def engine_stopped(self):
- if self.recording or self.updating:
- log.msg("Replay: recorded in %s: %d/%d scraped/passed items, %d received responses" % \
- (self.repfile, len(self.scraped_old), len(self.passed_old), len(self.responses_old)))
- self._save()
- self.cleanup()
-
- def item_scraped(self, item, spider):
- if self.recording or self.updating:
- self.scraped_old[str(item.guid)] = item.copy()
- else:
- self.scraped_new[str(item.guid)] = item.copy()
-
- def item_passed(self, item, spider):
- if self.recording or self.updating:
- self.passed_old[str(item.guid)] = item.copy()
- else:
- self.passed_new[str(item.guid)] = item.copy()
-
- def response_received(self, response, spider):
- #key = response.request.fingerprint()
- key = response.version()
- if (self.recording or self.updating) and key:
- self.responses_old[key] = response.copy()
- elif key:
- self.responses_new[key] = response.copy()
-
- def _load(self, repfile, usedir):
- if usedir:
- if os.path.isdir(repfile):
- replay_dir = repfile
- elif self.recording:
- os.makedirs(repfile)
- replay_dir = repfile
- else:
- raise IOError("No such dir: " % repfile)
- elif os.path.exists(repfile) and (self.playing or self.updating):
- if tarfile.is_tarfile(repfile):
- replay_dir = tempfile.mkdtemp(prefix="replay-")
- tar = tarfile.open(repfile)
- tar.extractall(replay_dir)
- tar.close()
- else:
- raise IOError("Wrong tarfile: %s" % repfile)
- elif self.recording:
- replay_dir = tempfile.mkdtemp(prefix="replay-")
- else:
- raise IOError("No such file: %s" % repfile)
-
- self.cache2dir = os.path.join(replay_dir, "httpcache")
- self.replay_dir = replay_dir
- self.repfile = repfile
- self.usedir = usedir
-
- self.options_path = os.path.join(replay_dir, "options.db")
- self.scraped_path = os.path.join(replay_dir, "items_scraped.db")
- self.passed_path = os.path.join(replay_dir, "items_passed.db")
- self.responses_path = os.path.join(replay_dir, "responses.db")
-
- if self.updating:
- with open(self.options_path, 'r') as f:
- self.options = pickle.load(f)
- if self.playing:
- with open(self.options_path, 'r') as f:
- self.options = pickle.load(f)
- with open(self.responses_path, 'r') as f:
- self.responses_old = pickle.load(f)
- with open(self.scraped_path, 'r') as f:
- self.scraped_old = pickle.load(f)
- with open(self.passed_path, 'r') as f:
- self.passed_old = pickle.load(f)
-
- def _save(self):
- if self.recording or self.updating:
- with open(self.options_path, 'w') as f:
- pickle.dump(self.options, f)
- with open(self.responses_path, 'w') as f:
- pickle.dump(self.responses_old, f)
- with open(self.scraped_path, 'w') as f:
- pickle.dump(self.scraped_old, f)
- with open(self.passed_path, 'w') as f:
- pickle.dump(self.passed_old, f)
-
- if not self.usedir:
- if self.recording or self.updating:
- tar = tarfile.open(self.repfile, "w:gz")
- for name in os.listdir(self.replay_dir):
- tar.add(os.path.join(self.replay_dir, name), name)
- tar.close()
-
- def cleanup(self):
- if not self.usedir and os.path.exists(self.replay_dir):
- shutil.rmtree(self.replay_dir)
diff --git a/scrapy/branches/cluster-refactor/scrapy/spider/manager.py b/scrapy/branches/cluster-refactor/scrapy/spider/manager.py
deleted file mode 100644
index 96203eee0..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/spider/manager.py
+++ /dev/null
@@ -1,140 +0,0 @@
-"""
-SpiderManager is the class which locates and manages all website-specific
-spiders
-"""
-import sys
-import os
-import urlparse
-
-from twisted.plugin import getCache
-
-from scrapy.spider.models import ISpider
-from scrapy import log
-from scrapy.conf import settings
-from scrapy.utils.url import url_is_from_spider
-
-class SpiderManager(object):
- """Spider locator and manager"""
-
- def __init__(self):
- self.loaded = False
- self.default_domain = None
- self.spider_modules = settings.getlist('SPIDER_MODULES')
- self.force_domain = None
-
- @property
- def all(self):
- self._load_on_demand()
- return self._alldict.values()
-
- @property
- def enabled(self):
- self._load_on_demand()
- return self._enableddict.values()
-
- def fromdomain(self, domain_name, include_disabled=True):
- return self.asdict(include_disabled=include_disabled).get(domain_name)
-
- def fromurl(self, url, include_disabled=True):
- self._load_on_demand()
- if self.force_domain:
- return self._alldict.get(self.force_domain)
- domain = urlparse.urlparse(url).hostname
- domain = str(domain).replace('www.', '')
- if domain:
- if domain in self._alldict: # try first locating by domain
- return self._alldict[domain]
- else: # else search spider by spider
- plist = self.all if include_disabled else self.enabled
- for p in plist:
- if url_is_from_spider(url, p):
- return p
- return self._alldict.get(self.default_domain)
-
- def asdict(self, include_disabled=True):
- self._load_on_demand()
- return self._alldict if include_disabled else self._enableddict
-
- def _load_on_demand(self):
- if not self.loaded:
- self.load()
-
- def _enabled_spiders(self):
- if settings['ENABLED_SPIDERS']:
- return set(settings['ENABLED_SPIDERS'])
- elif settings['ENABLED_SPIDERS_FILE']:
- if os.path.exists(settings['ENABLED_SPIDERS_FILE']):
- lines = open(settings['ENABLED_SPIDERS_FILE']).readlines()
- return set([l.strip() for l in lines if not l.strip().startswith('#')])
- else:
- return set()
- else:
- return set()
-
- def load(self):
- self._invaliddict = {}
- self._alldict = {}
- self._enableddict = {}
- enabled_spiders = self._enabled_spiders()
-
- modules = [__import__(m, {}, {}, ['']) for m in self.spider_modules]
- for module in modules:
- for spider in self._getspiders(ISpider, module):
- try:
- ISpider.validateInvariants(spider)
- self._alldict[spider.domain_name] = spider
- if spider.domain_name in enabled_spiders:
- self._enableddict[spider.domain_name] = spider
- except Exception, e:
- self._invaliddict[spider.domain_name] = spider
- # we can't use the log module here because it may not be available yet
- print "WARNING: Could not load spider %s: %s" % (spider, e)
- self.loaded = True
-
- def reload(self, skip_domains=None):
- """
- Reload all enabled spiders.
-
- This discovers any spiders added under the spiders module/packages,
- removes any spiders removed, updates all enabled spiders code and
- updates list of enabled spiders from ENABLED_SPIDERS_FILE or
- ENABLED_SPIDERS setting.
-
- Disabled spiders are intentionally excluded to avoid
- syntax/initialization errors. Currently running spiders are also
- excluded to avoid inconsistent behaviours.
-
- If skip_domains is passed those spiders won't be reloaded.
-
- """
- skip_domains = set(skip_domains or [])
- modules = [__import__(m, {}, {}, ['']) for m in self.spider_modules]
- for m in modules:
- reload(m)
- self.load() # first call to update list of enabled spiders
- reloaded = 0
- pdict = self.asdict(include_disabled=False)
- for domain, spider in pdict.iteritems():
- if not domain in skip_domains:
- reload(sys.modules[spider.__module__])
- reloaded += 1
- self.load() # second call to update spider instances
- log.msg("Reloaded %d/%d scrapy spiders" % (reloaded, len(pdict)), level=log.DEBUG)
-
- def _getspiders(self, interface, package):
- """
- This is an override of twisted.plugin.getPlugin, because we're
- interested in catching exceptions thrown when loading spiders such as
- KeyboardInterrupt
- """
-
- try:
- allDropins = getCache(package)
- for dropin in allDropins.itervalues():
- for plugin in dropin.plugins:
- adapted = interface(plugin, None)
- if adapted is not None:
- yield adapted
- except KeyboardInterrupt:
- sys.stderr.write("Interrupted while loading Scrapy spiders\n")
- sys.exit(2)
diff --git a/scrapy/branches/cluster-refactor/scrapy/spider/middleware.py b/scrapy/branches/cluster-refactor/scrapy/spider/middleware.py
deleted file mode 100644
index 782f099e5..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/spider/middleware.py
+++ /dev/null
@@ -1,122 +0,0 @@
-"""
-Spider middleware manager
-"""
-
-
-from twisted.python.failure import Failure
-
-from scrapy import log
-from scrapy.core.exceptions import NotConfigured
-from scrapy.utils.misc import load_class
-from scrapy.utils.defer import mustbe_deferred
-from scrapy.conf import settings
-
-def _isiterable(possible_iterator):
- try:
- return iter(possible_iterator)
- except TypeError:
- return None
-
-class SpiderMiddlewareManager(object):
- def __init__(self, callback=None, errback=None):
- self.loaded = False
- self.spider_middleware = []
- self.result_middleware = []
- self.exception_middleware = []
- self.filter_middleware = []
- self.domaininfo = {}
-
- self.callback = callback or self._callback
- self.errback = errback or self._errback
- self.load()
-
- def _add_middleware(self, mw):
- if hasattr(mw, 'process_scrape'):
- self.spider_middleware.append(mw.process_scrape)
- if hasattr(mw, 'process_result'):
- self.result_middleware.insert(0, mw.process_result)
- if hasattr(mw, 'process_exception'):
- self.exception_middleware.insert(0, mw.process_exception)
- if hasattr(mw, 'filter'):
- self.filter_middleware.insert(0, mw.filter)
-
- def load(self):
- """Load middleware defined in settings module"""
- mws = []
- for mwpath in settings.getlist('SPIDER_MIDDLEWARES') or ():
- cls = load_class(mwpath)
- if cls:
- try:
- mw = cls()
- self._add_middleware(mw)
- mws.append(mw)
- except NotConfigured:
- pass
- log.msg("Enabled spider middlewares: %s" % ", ".join([type(m).__name__ for m in mws]))
- self.loaded = True
-
- def scrape(self, request, response, spider):
- fname = lambda f:'%s.%s' % (f.im_self.__class__.__name__, f.im_func.__name__)
-
- def process_scrape(response):
- for method in self.spider_middleware:
- result = method(response=response, spider=spider)
- assert result is None or _isiterable(result), \
- 'Middleware %s must returns None or an iterable object, got %s ' % \
- (fname(method), type(result))
- if result is not None:
- return result
- return self.call(request=request, response=response, spider=spider)
-
-
- def process_result(result):
- for method in self.result_middleware:
- result = method(response=response, result=result, spider=spider)
- assert _isiterable(result), \
- 'Middleware %s must returns an iterable object, got %s ' % \
- (fname(method), type(result))
- return result
-
- def process_exception(_failure):
- exception = _failure.value
- for method in self.exception_middleware:
- result = method(response=response, exception=exception, spider=spider)
- assert result is None or _isiterable(result), \
- 'Middleware %s must returns None, or an iterable object, got %s ' % \
- (fname(method), type(result))
- if result is not None:
- return result
- return _failure
-
- dfd = mustbe_deferred(process_scrape, response)
- dfd.addErrback(process_exception)
- dfd.addCallback(process_result)
- return dfd
-
- def call(self, request, response, spider):
- if isinstance(response, Exception):
- return self.errback(request, Failure(response), spider)
- return self.callback(request, response, spider)
-
- def _callback(self, request, response, spider):
- request.deferred.callback(response)
- return request.deferred
-
- def _errback(self, request, failure, spider):
- request.deferred.errback(failure)
- return request.deferred
-
-
-class DummyMiddleware(object):
- def process_scrape(self, response, spider):
- pass
-
- def process_result(self, response, result, spider):
- return result
-
- def process_exception(self, response, exception, spider):
- pass
-
- def filter(self, item):
- return True
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/spider/models.py b/scrapy/branches/cluster-refactor/scrapy/spider/models.py
deleted file mode 100644
index d680b93e9..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/spider/models.py
+++ /dev/null
@@ -1,89 +0,0 @@
-"""
-Base class for scrapy spiders
-"""
-from zope.interface import Interface, Attribute, invariant, implements
-from twisted.plugin import IPlugin
-
-from scrapy.core.exceptions import UsageError
-
-def _valid_start_urls(obj):
- """Check the start urls specified are valid"""
- if not obj.start_urls:
- raise UsageError("A start url is required")
-
-def _valid_domain_name(obj):
- """Check the domain name specified is valid"""
- if not obj.domain_name:
- raise UsageError("A site domain name is required")
-
-def _valid_download_delay(obj):
- """Check the download delay is valid, if specified"""
- delay = getattr(obj, 'download_delay', 0)
- if not type(delay) in (int, long, float):
- raise UsageError("download_delay must be numeric")
- if float(delay) < 0.0:
- raise UsageError("download_delay must be positive")
-
-class ISpider(Interface, IPlugin) :
- """Interface to be implemented by site-specific web spiders"""
-
- start_urls = Attribute(
- """A sequence of URLs to retrieve to initiate the spider for this
- site. A single URL may also be provided here.""")
-
- domain_name = Attribute(
- """The domain name of the site to be scraped.""")
-
- download_delay = Attribute(
- """Optional delay in seconds to wait between web page downloads.
- Note that this delay does not apply to image downloads.
- A delay of less than a second can be specified.""")
-
- user_agent = Attribute(
- """Optional User-Agent to use for this domain""")
-
- invariant(_valid_start_urls)
- invariant(_valid_domain_name)
- invariant(_valid_download_delay)
-
- def parse(self, pagedata) :
- """This is first called with the data corresponding to start_url. It
- must return a (possibly empty) sequence where each element is either:
- * A Request object for further processing.
- * An object that extends ScrapedItem (defined in scrapeditem module)
- * or None (this will be ignored)
-
- When a Request object is returned, the Request is scheduled, then
- downloaded and finally its results is handled to the Request callback.
- That callback must behave the same way as this function.
-
- When a ScrapedItem is returned, it is passed to the transformation pipeline
- and finally the destination systems are updated.
-
- The simplest way to use this is to have a method in your class for each
- page type. So each function knows the layout and how to extract data
- for a single page (or set of similar pages). A typical class might work
- like:
- * parse() parses the landing page and returns Requests
- for a category() function to parse category pages.
- * category() parses the category pages and returns links and callbacks
- for a item() function to parse item pages.
- * item() parses the item details page and returns objects that
- extend ScrapedItem
- """
- pass
-
- def init_domain(self):
- """This is first called to initialize domain specific quirks, like
- session cookies or login stuff
- """
- pass
-
-
-class BaseSpider(object):
- """Base class for scrapy spiders. All spiders must inherit from this
- class."""
-
- implements(ISpider)
- domain_name = None
- extra_domain_names = []
diff --git a/scrapy/branches/cluster-refactor/scrapy/stats/corestats.py b/scrapy/branches/cluster-refactor/scrapy/stats/corestats.py
deleted file mode 100644
index 20435a04c..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/stats/corestats.py
+++ /dev/null
@@ -1,69 +0,0 @@
-"""
-Scrapy extension for collecting scraping stats
-"""
-import os
-import getpass
-import socket
-import datetime
-
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy.stats import stats
-from scrapy.conf import settings
-
-class CoreStats(object):
- """Scrapy core stats collector"""
-
- def __init__(self):
- stats.setpath('_envinfo/user', getpass.getuser())
- stats.setpath('_envinfo/host', socket.gethostname())
- stats.setpath('_envinfo/logfile', settings['LOGFILE'])
- stats.setpath('_envinfo/pid', os.getpid())
-
- dispatcher.connect(self.stats_domain_open, signal=stats.domain_open)
- dispatcher.connect(self.stats_domain_closing, signal=stats.domain_closing)
- dispatcher.connect(self.item_scraped, signal=signals.item_scraped)
- dispatcher.connect(self.item_passed, signal=signals.item_passed)
- dispatcher.connect(self.item_dropped, signal=signals.item_dropped)
- dispatcher.connect(self.response_downloaded, signal=signals.response_downloaded)
- dispatcher.connect(self.request_uploaded, signal=signals.request_uploaded)
-
- def stats_domain_open(self, domain, spider):
- stats.setpath('%s/start_time' % domain, datetime.datetime.now())
- stats.setpath('%s/envinfo' % domain, stats.getpath('_envinfo'))
- stats.incpath('_global/domain_count/opened')
-
- def stats_domain_closing(self, domain, spider, status):
- stats.setpath('%s/finish_time' % domain, datetime.datetime.now())
- stats.setpath('%s/finish_status' % domain, 'OK' if status == 'finished' else status)
- stats.incpath('_global/domain_count/%s' % status)
-
- def item_scraped(self, item, spider):
- stats.incpath('%s/item_scraped_count' % spider.domain_name)
- stats.incpath('_global/item_scraped_count')
-
- def item_passed(self, item, spider, pipe_output):
- stats.incpath('%s/item_passed_count' % spider.domain_name)
- stats.incpath('_global/item_passed_count')
-
- def item_dropped(self, item, spider, exception):
- reason = exception.__class__.__name__
- stats.incpath('%s/item_dropped_count' % spider.domain_name)
- stats.incpath('%s/item_dropped_reasons_count/%s' % (spider.domain_name, reason))
- stats.incpath('_global/item_dropped_count')
-
- def response_downloaded(self, response, spider):
- stats.incpath('%s/response_count' % spider.domain_name)
- stats.incpath('%s/response_status_count/%s' % (spider.domain_name, response.status))
- stats.incpath('_global/response_downloaded_count')
-
- reslen = len(response)
- stats.incpath('%s/transfer/downloaded_bytes' % spider.domain_name, reslen)
- stats.incpath('_global/transfer/downloaded_bytes', reslen)
-
- def request_uploaded(self, request, spider):
- reqlen = len(request)
- stats.incpath('%s/transfer/uploaded_bytes' % spider.domain_name, reqlen)
- stats.incpath('_global/transfer/uploaded_bytes', reqlen)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/__init__.py b/scrapy/branches/cluster-refactor/scrapy/tests/__init__.py
deleted file mode 100644
index b72b1493f..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-""" """
\ No newline at end of file
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_adaptors.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_adaptors.py
deleted file mode 100644
index df1627b5a..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_adaptors.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# -*- coding: utf8 -*-
-import unittest
-from scrapy.item import adaptors
-from scrapy.xpath.selector import XmlXPathSelector
-from scrapy.http import Response, ResponseBody
-
-class AdaptorsTestCase(unittest.TestCase):
- def test_extract(self):
- sample_xsel = XmlXPathSelector(text='<xml id="2"><tag1>foo<tag2>bar</tag2></tag1><tag3 value="mytag">test</tag3></xml>')
- self.assertEqual(adaptors.extract(sample_xsel.x('/')),
- ['<xml id="2"><tag1>foo<tag2>bar</tag2></tag1><tag3 value="mytag">test</tag3></xml>'])
- self.assertEqual(adaptors.extract(sample_xsel.x('xml/*')),
- ['<tag1>foo<tag2>bar</tag2></tag1>', '<tag3 value="mytag">test</tag3>'])
- self.assertEqual(adaptors.extract(sample_xsel.x('xml/@id')), ['2'])
- self.assertEqual(adaptors.extract(sample_xsel.x('//tag1')), ['<tag1>foo<tag2>bar</tag2></tag1>'])
- self.assertEqual(adaptors.extract(sample_xsel.x('//tag1//text()')),
- ['foo', 'bar'])
- self.assertEqual(adaptors.extract(sample_xsel.x('//text()')),
- ['foo', 'bar', 'test'])
- self.assertEqual(adaptors.extract(sample_xsel.x('//tag3/@value')), ['mytag'])
-
- def test_extract_links(self):
- test_data = """<html><body>
- <div>
- <a href="lala1.html">lala1</a>
- <a href="/lala2.html">lala2</a>
- <a href="http://foobar.com/lala3.html">lala3</a>
- <a href="lala4.html"><img src="lala4.jpg" /></a>
- <a onclick="javascript: opensomething('/my_html1.html');">something1</a>
- <a onclick="javascript: opensomething('my_html2.html');">something2</a>
- </div>
- </body></html>"""
- sample_response = Response('foobar.com', 'http://foobar.com/dummy', body=ResponseBody(test_data))
- sample_xsel = XmlXPathSelector(sample_response)
- self.assertEqual(adaptors.extract_links(sample_xsel.x('//@href')),
- [u'http://foobar.com/dummy/lala1.html', u'http://foobar.com/lala2.html',
- u'http://foobar.com/lala3.html', u'http://foobar.com/dummy/lala4.html'])
- self.assertEqual(adaptors.extract_links(sample_xsel.x('//a')),
- [u'http://foobar.com/dummy/lala1.html', u'http://foobar.com/lala2.html',
- u'http://foobar.com/lala3.html', u'http://foobar.com/dummy/lala4.jpg'])
- self.assertEqual(adaptors.extract_links((sample_xsel.x('//a[@onclick]'), r'opensomething\(\'(.*?)\'\)')),
- [u'http://foobar.com/my_html1.html', u'http://foobar.com/dummy/my_html2.html'])
-
- def test_to_unicode(self):
- self.assertEqual(adaptors.to_unicode(['lala', 'lele', 'luluñ', 1, 'áé']),
- [u'lala', u'lele', u'lulu\xf1', u'1', u'\xe1\xe9'])
-
- def test_regex(self):
- func = adaptors.regex(r'href="(.*?)"')
- self.assertEqual(func(['<a href="lala.com">dsa</a><a href="pepe.co.uk"></a>',
- '<a href="das.biz">href="lelelel.net"</a>']),
- ['lala.com', 'pepe.co.uk', 'das.biz', 'lelelel.net'])
-
- def test_unquote_all(self):
- self.assertEqual(adaptors.unquote_all([u'hello&copy;&amp;welcome', u'&lt;br /&gt;&amp;']), [u'hello\xa9&welcome', u'<br />&'])
-
- def test_unquote(self):
- self.assertEqual(adaptors.unquote([u'hello&copy;&amp;welcome', u'&lt;br /&gt;&amp;']), [u'hello\xa9&amp;welcome', u'&lt;br />&amp;'])
-
- def test_remove_tags(self):
- test_data = ['<a href="lala">adsaas<br /></a>', '<div id="1"><table>dsadasf</table></div>']
- self.assertEqual(adaptors.remove_tags(test_data), ['adsaas', 'dsadasf'])
-
- def test_remove_root(self):
- self.assertEqual(adaptors.remove_root(['<div>lallaa<a href="coso">dsfsdfds</a>pepepep<br /></div>']),
- ['lallaa<a href="coso">dsfsdfds</a>pepepep<br />'])
-
- def test_remove_multispaces(self):
- self.assertEqual(adaptors.remove_multispaces([' hello, whats up?', 'testing testingtesting testing']),
- [' hello, whats up?', 'testing testingtesting testing'])
-
- def test_strip(self):
- self.assertEqual(adaptors.strip([' hi there, sweety ;D ', ' I CAN HAZ TEST?? ']),
- ['hi there, sweety ;D', 'I CAN HAZ TEST??'])
-
- def test_drop_empty_elements(self):
- self.assertEqual(adaptors.drop_empty_elements([1, 2, None, 5, None, 6, None, 'hi']),
- [1, 2, 5, 6, 'hi'])
-
- def test_delist(self):
- self.assertEqual(adaptors.delist(['hi', 'there', 'fellas.', 'this', 'is', 'my', 'test.']),
- 'hi there fellas. this is my test.')
-
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_decompress.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_decompress.py
deleted file mode 100644
index 784495b76..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_decompress.py
+++ /dev/null
@@ -1,45 +0,0 @@
-import os
-from unittest import TestCase, main
-from scrapy.http import Response, ResponseBody
-from scrapy.utils.decompressor import Decompressor
-
-class ScrapyDecompressTest(TestCase):
- uncompressed_body = ''
- test_responses = {}
- decompressor = Decompressor()
-
- def setUp(self):
- self.datadir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sample_data', 'compressed')
- formats = ['tar', 'xml.bz2', 'xml.gz', 'zip']
- uncompressed_fd = open(os.path.join(self.datadir, 'feed-sample1.xml'), 'r')
- self.uncompressed_body = uncompressed_fd.read()
- uncompressed_fd.close()
-
- for format in formats:
- fd = open(os.path.join(self.datadir, 'feed-sample1.' + format), 'r')
- body = ResponseBody(fd.read())
- fd.close()
- self.test_responses[format] = Response('foo.com', 'http://foo.com/bar', body=body)
-
- def test_tar(self):
- ret = self.decompressor.extract(self.test_responses['tar'])
- if ret:
- self.assertEqual(ret.body.to_string(), self.uncompressed_body)
-
- def test_zip(self):
- ret = self.decompressor.extract(self.test_responses['zip'])
- if ret:
- self.assertEqual(ret.body.to_string(), self.uncompressed_body)
-
- def test_gz(self):
- ret = self.decompressor.extract(self.test_responses['xml.gz'])
- if ret:
- self.assertEqual(ret.body.to_string(), self.uncompressed_body)
-
- def test_bz2(self):
- ret = self.decompressor.extract(self.test_responses['xml.bz2'])
- if ret:
- self.assertEqual(ret.body.to_string(), self.uncompressed_body)
-
-if __name__ == '__main__':
- main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_defaultencoding.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_defaultencoding.py
deleted file mode 100644
index 36c5b782d..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_defaultencoding.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import sys
-from unittest import TestCase, main
-
-class DefaultEncodingTest(TestCase):
- def test_defaultencoding(self):
- self.assertEqual(sys.getdefaultencoding(), 'utf-8')
-
-if __name__ == "__main__":
- main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_engine.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_engine.py
deleted file mode 100644
index f64a8062a..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_engine.py
+++ /dev/null
@@ -1,197 +0,0 @@
-"""
-Scrapy engine tests
-"""
-
-import sys
-import os
-import urlparse
-import unittest
-
-from twisted.internet import reactor
-from twisted.web import server, resource, static, util
-
-#class TestResource(resource.Resource):
-# isLeaf = True
-#
-# def render_GET(self, request):
-# return "hello world!"
-
-def start_test_site():
- root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "sample_data", "test_site")
- r = static.File(root_dir)
-# r.putChild("test", TestResource())
- r.putChild("redirect", util.Redirect("/redirected"))
- r.putChild("redirected", static.Data("Redirected here", "text/plain"))
-
- port = reactor.listenTCP(0, server.Site(r), interface="127.0.0.1")
- return port
-
-
-class CrawlingSession(object):
-
- def __init__(self):
- self.domain = 'scrapytest.org'
- self.spider = None
- self.respplug = []
- self.reqplug = []
- self.itemresp = []
- self.signals_catched = {}
- self.wasrun = False
-
- def run(self):
- self.port = start_test_site()
- self.portno = self.port.getHost().port
-
- from scrapy.spider import spiders
- spiders.spider_modules = ['scrapy.tests.test_spiders']
- spiders.reload()
-
- self.spider = spiders.fromdomain(self.domain)
- if self.spider:
- self.spider.start_urls = [
- self.geturl("/"),
- self.geturl("/redirect"),
- ]
-
- from scrapy.core import signals
- from scrapy.core.manager import scrapymanager
- from scrapy.core.engine import scrapyengine
- from pydispatch import dispatcher
-
- dispatcher.connect(self.record_signal, signals.engine_started)
- dispatcher.connect(self.record_signal, signals.engine_stopped)
- dispatcher.connect(self.record_signal, signals.domain_opened)
- dispatcher.connect(self.record_signal, signals.domain_idle)
- dispatcher.connect(self.record_signal, signals.domain_closed)
- dispatcher.connect(self.item_scraped, signals.item_scraped)
- dispatcher.connect(self.request_received, signals.request_received)
- dispatcher.connect(self.response_downloaded, signals.response_downloaded)
-
- scrapymanager.runonce(self.domain)
- self.port.stopListening()
- self.wasrun = True
-
- def geturl(self, path):
- return "http://localhost:%s%s" % (self.portno, path)
-
- def getpath(self, url):
- u = urlparse.urlparse(url)
- return u.path
-
- def item_scraped(self, item, spider, response):
- self.itemresp.append((item, response))
-
- def request_received(self, request, spider):
- self.reqplug.append((request, spider))
-
- def response_downloaded(self, response, spider):
- self.respplug.append((response, spider))
-
- def record_signal(self, *args, **kwargs):
- """Record a signal and its parameters"""
- signalargs = kwargs.copy()
- sig = signalargs.pop('signal')
- signalargs.pop('sender', None)
- self.signals_catched[sig] = signalargs
-
-session = CrawlingSession()
-
-
-class EngineTest(unittest.TestCase):
-
- def setUp(self):
- if not session.wasrun:
- session.run()
-
- # disable extensions that cause problems with tests (probably
- # because they leave the reactor in an unclean state)
- from scrapy.conf import settings
- settings.overrides['CLUSTER_MANAGER_ENABLED'] = 0
-
- def test_spider_locator(self):
- """
- Check the spider is loaded and located properly via the SpiderLocator
- """
- assert session.spider is not None
- self.assertEqual(session.spider.domain_name, session.domain)
-
- def test_visited_urls(self):
- """
- Make sure certain URls were actually visited
- """
- # expected urls that should be visited
- must_be_visited = ["/", "/redirect", "/redirected",
- "/item1.html", "/item2.html", "/item999.html"]
-
- urls_visited = set([rp[0].url for rp in session.respplug])
- urls_expected = set([session.geturl(p) for p in must_be_visited])
- assert urls_expected <= urls_visited, "URLs not visited: %s" % list(urls_expected - urls_visited)
-
- def test_requests_received(self):
- """
- Check requests received
- """
- # 3 requests should be received from the spider. start_urls and redirects don't count
- self.assertEqual(3, len(session.reqplug))
-
- paths_expected = ['/item999.html', '/item2.html', '/item1.html']
-
- urls_requested = set([rq[0].url for rq in session.reqplug])
- urls_expected = set([session.geturl(p) for p in paths_expected])
- assert urls_expected <= urls_requested
-
- def test_responses_downloaded(self):
- """
- Check responses downloaded
- """
- # response tests
- self.assertEqual(6, len(session.respplug))
-
- for response, spider in session.respplug:
- if session.getpath(response.url) == '/item999.html':
- self.assertEqual('404', response.status)
- if session.getpath(response.url) == '/redirect':
- self.assertEqual('302', response.status)
- self.assertEqual(response.domain, spider.domain_name)
-
- def test_item_data(self):
- """
- Check item data
- """
- # item tests
- self.assertEqual(2, len(session.itemresp))
- for item, response in session.itemresp:
- self.assertEqual(item.url, response.url)
- if 'item1.html' in item.url:
- self.assertEqual('Item 1 name', item.name)
- self.assertEqual('100', item.price)
- if 'item2.html' in item.url:
- self.assertEqual('Item 2 name', item.name)
- self.assertEqual('200', item.price)
-
- def test_signals(self):
- """
- Check signals were sent properly
- """
- from scrapy.core import signals
-
- assert signals.engine_started in session.signals_catched
- assert signals.engine_stopped in session.signals_catched
- assert signals.domain_opened in session.signals_catched
- assert signals.domain_idle in session.signals_catched
- assert signals.domain_closed in session.signals_catched
-
- self.assertEqual({'domain': session.domain, 'spider': session.spider},
- session.signals_catched[signals.domain_opened])
- self.assertEqual({'domain': session.domain, 'spider': session.spider},
- session.signals_catched[signals.domain_idle])
- self.assertEqual({'domain': session.domain, 'spider': session.spider, 'status': 'finished'},
- session.signals_catched[signals.domain_closed])
-
-if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == 'runserver':
- port = start_test_site()
- print "Test server running at http://localhost:%d/ - hit Ctrl-C to finish." % port.getHost().port
- reactor.run()
- else:
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_http_request.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_http_request.py
deleted file mode 100644
index 511ca9797..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_http_request.py
+++ /dev/null
@@ -1,230 +0,0 @@
-import unittest
-from scrapy.http import Request, Headers
-from scrapy.core.scheduler import GroupFilter
-
-class RequestTest(unittest.TestCase):
- """ c14n comparison functions """
-
- def test_groupfilter(self):
- k1 = Request(url="http://www.scrapy.org/path?key=val").fingerprint()
- k2 = Request(url="http://www.scrapy.org/path?key=val&key=val").fingerprint()
- self.assertEqual(k1, k2)
-
- f = GroupFilter()
- f.open("mygroup")
- self.assertTrue(f.add("mygroup", k1))
- self.assertFalse(f.add("mygroup", k1))
- self.assertFalse(f.add("mygroup", k2))
-
- f.open('anothergroup')
- self.assertTrue(f.add("anothergroup", k1))
- self.assertFalse(f.add("anothergroup", k1))
- self.assertFalse(f.add("anothergroup", k2))
-
- f.close('mygroup')
- f.open('mygroup')
- self.assertTrue(f.add("mygroup", k2))
- self.assertFalse(f.add("mygroup", k1))
-
- def test_headers(self):
- # Different ways of setting headers attribute
- url = 'http://www.scrapy.org'
- headers = {'Accept':'gzip', 'Custom-Header':'nothing to tell you'}
- r = Request(url=url, headers=headers)
- p = Request(url=url, headers=r.headers)
-
- self.assertEqual(r.headers, p.headers)
- self.assertFalse(r.headers is headers)
- self.assertFalse(p.headers is r.headers)
-
- # headers must not be unicode
- h = Headers({'key1': u'val1', u'key2': 'val2'})
- h[u'newkey'] = u'newval'
- for k,v in h.iteritems():
- self.assert_(isinstance(k, str))
- self.assert_(isinstance(v, str))
-
- r = Request(url="http://www.example.org/1", referer=u"http://www.example.org")
- self.assert_(isinstance(r.headers['referer'], str))
-
- def test_eq(self):
- url = 'http://www.scrapy.org'
- r1 = Request(url=url)
- r2 = Request(url=url)
- self.assertNotEqual(r1, r2)
-
- set_ = set()
- set_.add(r1)
- set_.add(r2)
- self.assertEqual(len(set_), 2)
-
- def test_fingerprint(self):
- url = 'http://www.scrapy.org'
- r = Request(url=url)
- urlhash = r.fingerprint()
-
- # fingerprint including all initials headers
- r.fingerprint_params['exclude_headers'] = []
- fullhash = r.fingerprint()
- del r.fingerprint_params['exclude_headers']
-
- # all headers are excluded from fingerprint by default
- r.headers['Accept'] = 'application/json'
- accepthash = r.fingerprint()
- r.headers['User-Agent'] = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.8) Gecko/20071004 Iceweasel/2.0.0.8 (Debian-2.0.0.8-1)'
- useragenthash = r.fingerprint()
- self.assertEqual(urlhash, accepthash)
- self.assertEqual(urlhash, useragenthash)
- self.assertEqual(accepthash, useragenthash)
-
- # take User-Agent header in count as specified in `include_headers`
- r.fingerprint_params['include_headers'] = ['user-agent']
- useragenthash = r.fingerprint()
- self.assertNotEqual(useragenthash, urlhash)
-
- # include_headers has precedence over exclude_headers
- r.fingerprint_params['exclude_headers'] = ['user-agent', 'Accept']
- self.assertEqual(useragenthash, r.fingerprint())
-
- del r.fingerprint_params['include_headers']
- self.assertNotEqual(useragenthash, r.fingerprint()) # exclude_headers is excluding 'User-Agent' from hash
- self.assertEqual(fullhash, r.fingerprint()) # all headers previously seted was excluded
-
- # set more headers
- r.headers['Accept-Language'] = 'en-us,en;q=0.5'
- r.headers['SESSIONID'] = 'an ugly session id header'
- self.assertNotEqual(urlhash, r.fingerprint())
-
- # force emtpy include_headers (ignore exclude_headers)
- r.fingerprint_params['include_headers'] = []
- self.assertEqual(urlhash, r.fingerprint())
-
- # Tamper Function
- r.fingerprint_params['tamperfunc'] = lambda req: Request(url=req.url)
- self.assertEqual(urlhash, r.fingerprint())
-
- # Compare request with None vs {} header
- r = Request(url=url, headers=None)
- o = Request(url=url, headers={})
- self.assertEqual(o.fingerprint(), r.fingerprint())
- self.assertNotEqual(r, o)
-
- # Different ways of setting headers attribute
- headers = {'Accept':'gzip', 'Custom-Header':'nothing to tell you'}
- r = Request(url=url, headers=headers)
- p = Request(url=url, headers=r.headers)
- o = Request(url=url)
- o.headers = headers
- self.assertEqual(r.fingerprint(), o.fingerprint())
- self.assertEqual(r.fingerprint(), p.fingerprint())
- self.assertEqual(o.fingerprint(), p.fingerprint())
- self.assertNotEqual(r, o)
- self.assertNotEqual(r, p)
- self.assertNotEqual(o, p)
-
- # same url, implicit method
- r1 = Request(url=url)
- r2 = Request(url=url, method='GET')
- self.assertEqual(r1.fingerprint(), r2.fingerprint())
-
- # same url, different method
- r3 = Request(url=url, method='POST')
- self.assertNotEqual(r1.fingerprint(), r3.fingerprint())
-
- # implicit POST method
- r3.body = ''
- r4 = Request(url=url, body='')
- self.assertEqual(r3.fingerprint(), r4.fingerprint())
-
- # body is not important in GET or DELETE
- r1 = Request(url=url, method='get', body='data')
- r2 = Request(url=url, method='get')
- self.assertEqual(r1.fingerprint(), r2.fingerprint())
-
- r1 = Request(url=url, method='delete', body='data')
- r2 = Request(url=url, method='delete')
- self.assertEqual(r1.fingerprint(), r2.fingerprint())
-
- # no body by default
- r1 = Request(url=url, method='POST')
- r2 = Request(url=url, method='POST', body=None)
- self.assertEqual(r1.fingerprint(), r2.fingerprint())
-
- # empty body is equal to None body
- r3 = Request(url=url, method='POST', body='')
- self.assertEqual(r1.fingerprint(), r3.fingerprint())
-
- def test_insensitive_request_fingerprints(self):
- url = 'http://www.scrapy.org'
- fp = {'include_headers':['Accept','Content-Type']}
- r1a = Request(url=url.lower())
- r1b = Request(url=url.upper())
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
-
- r1a = Request(url=url.lower(), method='get')
- r1b = Request(url=url.upper(), method='GET')
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
-
- r1c = Request(url=url.upper(), method='GET', body='this is not important')
- self.assertEqual(r1b.fingerprint(), r1c.fingerprint())
-
- r1a = Request(url=url.lower(), method='get', fingerprint_params=fp)
- r1b = Request(url=url.upper(), method='GET', fingerprint_params=fp)
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
-
- r1a = Request(url=url.lower(), method='get', headers={'ACCEPT':'Black'})
- r1b = Request(url=url.upper(), method='GET', headers={'ACCEPT':'Black'})
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
-
- r1a = Request(url=url.lower(), method='get', fingerprint_params=fp, headers={'ACCEPT':'Black'})
- r1b = Request(url=url.upper(), method='GET', fingerprint_params=fp, headers={'ACCEPT':'Black'})
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
-
- r1a = Request(url=url.lower(), method='get', fingerprint_params=fp, headers={'ACCEPT':'Black'})
- r1b = Request(url=url.upper(), method='GET', fingerprint_params=fp, headers={'Accept':'Black'})
- r1c = Request(url=url.upper(), method='gEt', fingerprint_params=fp, headers={'accept':'Black'})
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
- self.assertEqual(r1a.fingerprint(), r1c.fingerprint())
-
- r1a = Request(url=url.lower(), method='get', fingerprint_params=fp, headers={'ACCEPT':'Black', 'content-type':'application/json'})
- r1b = Request(url=url.upper(), method='GET', fingerprint_params=fp, headers={'Accept':'Black', 'Content-Type':'application/json'})
- r1c = Request(url=url.upper(), method='Get', fingerprint_params=fp, headers={'accepT':'Black', 'CONTENT-TYPE':'application/json'})
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
- self.assertEqual(r1a.fingerprint(), r1c.fingerprint())
-
- r1a = Request(url=url.lower(), method='Post', fingerprint_params=fp, headers={'ACCEPT':'Black', 'content-type':'application/json'})
- r1b = Request(url=url.upper(), method='POST', fingerprint_params=fp, headers={'Accept':'Black', 'Content-Type':'application/json'})
- r1c = Request(url=url.upper(), method='posT', fingerprint_params=fp, headers={'accepT':'Black', 'CONTENT-TYPE':'application/json'})
- self.assertEqual(r1a.fingerprint(), r1b.fingerprint())
- self.assertEqual(r1a.fingerprint(), r1c.fingerprint())
-
- def test_url(self):
- """Request url tests"""
- r = Request(url="http://www.scrapy.org/path")
- self.assertEqual(r.url, "http://www.scrapy.org/path")
-
- # url quoting on attribute assign
- r.url = "http://www.scrapy.org/blank%20space"
- self.assertEqual(r.url, "http://www.scrapy.org/blank%20space")
- r.url = "http://www.scrapy.org/blank space"
- self.assertEqual(r.url, "http://www.scrapy.org/blank%20space")
-
- # url quoting on creation
- r = Request(url="http://www.scrapy.org/blank%20space")
- self.assertEqual(r.url, "http://www.scrapy.org/blank%20space")
- r = Request(url="http://www.scrapy.org/blank space")
- self.assertEqual(r.url, "http://www.scrapy.org/blank%20space")
-
- # url coercion to string
- r.url = u"http://www.scrapy.org/test"
- self.assert_(isinstance(r.url, str))
-
- # url encoding
- r = Request(url=u"http://www.scrapy.org/price/\xa3", url_encoding="utf-8")
- self.assert_(isinstance(r.url, str))
- self.assertEqual(r.url, "http://www.scrapy.org/price/%C2%A3")
-
-if __name__ == "__main__":
- unittest.main()
-
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_http_response.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_http_response.py
deleted file mode 100644
index 5c3a7692f..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_http_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-from unittest import TestCase, main
-import libxml2
-from scrapy.http import ResponseBody
-
-class ResponseTest(TestCase):
- def test_responsebodyencoding(self):
- string = 'кириллический текст'
- unicode_string = unicode(string, 'utf-8')
- body_cp1251 = unicode_string.encode('cp1251')
- body = ResponseBody(body_cp1251, 'cp1251')
- self.assertEqual(body.to_unicode(), unicode_string)
- self.assertEqual(isinstance(body.to_unicode(), unicode), True)
- self.assertEqual(body.to_string('utf-8'), string)
- self.assertEqual(isinstance(body.to_string('utf-8'), str), True)
- self.assertEqual(body.to_string(), body_cp1251)
- self.assertEqual(isinstance(body.to_string('utf-8'), str), True)
-
-if __name__ == "__main__":
- main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_http_url.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_http_url.py
deleted file mode 100644
index 08266a262..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_http_url.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import unittest
-from scrapy.http import Url
-
-class UrlClassTest(unittest.TestCase):
-
- def test_url_attributes(self):
- u = Url("http://scrapy.org/wiki/info")
- self.assertEqual("scrapy.org", u.hostname)
- self.assertEqual("/wiki/info", u.path)
- self.assertEqual(None, u.username)
- self.assertEqual(None, u.password)
-
- u = Url("http://someuser:[email protected]/ticket/query?owner=pablo")
- self.assertEqual("someuser", u.username)
- self.assertEqual("somepass", u.password)
- self.assertEqual("example.com", u.hostname)
- self.assertEqual("/ticket/query", u.path)
- self.assertEqual("owner=pablo", u.query)
-
- u = Url("http://example.com/somepage.html#fragment-1")
- self.assertEqual("fragment-1", u.fragment)
-
- u = Url("file:///home/pablo/file.txt")
- self.assertEqual("/home/pablo/file.txt", u.path)
-
-if __name__ == "__main__":
- unittest.main()
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_libxml2.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_libxml2.py
deleted file mode 100644
index 35b0cade4..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_libxml2.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from unittest import TestCase, main
-import libxml2
-from scrapy.http import ResponseBody, Response
-
-class Libxml2Test(TestCase):
- def setUp(self):
- libxml2.debugMemory(1)
-
- def tearDown(self):
- libxml2.cleanupParser()
- leaked_bytes = libxml2.debugMemory(0)
- assert leaked_bytes == 0, "libxml2 memory leak detected: %d bytes" % leaked_bytes
-
- def test_xpath(self):
- #this test will fail in version 2.6.27 but passes on 2.6.29+
- html = "<td>1<b>2</b>3</td>"
- node = libxml2.htmlParseDoc(html, 'utf-8')
- result = [str(r) for r in node.xpathEval('//text()')]
- self.assertEquals(result, ['1', '2', '3'])
- node.freeDoc()
-
-class ResponseLibxml2DocTest(TestCase):
- def setUp(self):
- libxml2.debugMemory(1)
-
- def tearDown(self):
- libxml2.cleanupParser()
- leaked_bytes = libxml2.debugMemory(0)
- assert leaked_bytes == 0, "libxml2 memory leak detected: %d bytes" % leaked_bytes
-
- def test_getlibxml2doc(self):
- # test to simulate '\x00' char in body of html page
- #this method don't should raise TypeError Exception
- from scrapy.core.manager import scrapymanager
- scrapymanager.configure()
-
- self.body_content = 'test problematic \x00 body'
- self.problematic_body = ResponseBody(self.body_content, 'utf-8')
- response = Response('example.com', 'http://example.com/catalog/product/blabla-123', body=self.problematic_body)
- response.getlibxml2doc()
-
-if __name__ == "__main__":
- main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_link.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_link.py
deleted file mode 100644
index e4cf3ee58..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_link.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import unittest
-
-from scrapy.http import Response
-from scrapy.link import LinkExtractor
-
-class LinkExtractorTestCase(unittest.TestCase):
- def test_basic(self):
- html = """<html><head><title>Page title<title>
- <body><p><a href="item/12.html">Item 12</a></p>
- <p><a href="/about.html">About us</a></p>
- <img src="/logo.png" alt="Company logo (not a link)" />
- <p><a href="../othercat.html">Other category</a></p>
- <p><a href="/" /></p>
- </body></html>"""
- response = Response("example.org", "http://example.org/somepage/index.html", body=html)
-
- lx = LinkExtractor() # default: tag=a, attr=href
- self.assertEqual(lx.extract_urls(response),
- {'http://example.org/somepage/item/12.html': 'Item 12',
- 'http://example.org/about.html': 'About us',
- 'http://example.org/othercat.html': 'Other category',
- 'http://example.org/': ''})
-
- def test_base_url(self):
- html = """<html><head><title>Page title<title><base href="http://otherdomain.com/base/" />
- <body><p><a href="item/12.html">Item 12</a></p>
- </body></html>"""
- response = Response("example.org", "http://example.org/somepage/index.html", body=html)
-
- lx = LinkExtractor() # default: tag=a, attr=href
- self.assertEqual(lx.extract_urls(response),
- {'http://otherdomain.com/base/item/12.html': 'Item 12'})
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_pipeline_images.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_pipeline_images.py
deleted file mode 100644
index b3b5d09a6..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_pipeline_images.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import unittest
-from scrapy.contrib.pipeline.images import thumbnail_name, image_path
-
-class ImagesPipelineTestCase(unittest.TestCase):
- def test_image_path(self):
- self.assertEqual(image_path("https://dev.mydeco.com/mydeco.gif"),
- 'dev.mydeco.com/mydeco.gif')
- self.assertEqual(image_path("http://www.maddiebrown.co.uk///catalogue-items//image_54642_12175_95307.jpg"),
- 'www.maddiebrown.co.uk/catalogue-items/image_54642_12175_95307.jpg')
- self.assertEqual(image_path("https://dev.mydeco.com/two/dirs/with%20spaces%2Bsigns.gif"),
- 'dev.mydeco.com/two/dirs/with spaces+signs.gif')
- self.assertEqual(image_path("http://www.dfsonline.co.uk/get_prod_image.php?img=status_0907_mdm.jpg"),
- 'www.dfsonline.co.uk/4507be485f38b0da8a0be9eb2e1dfab8a19223f2')
- self.assertEqual(image_path("http://www.dorma.co.uk/images/product_details/2532/"),
- 'www.dorma.co.uk/images/product_details/2532.jpg')
- self.assertEqual(image_path("http://www.dorma.co.uk/images/product_details/2532"),
- 'www.dorma.co.uk/images/product_details/2532')
-
- def test_thumbnail_name(self):
- name = '50'
- self.assertEqual(thumbnail_name("/tmp/foo.jpg", name),
- '/tmp/foo_50.jpg')
- self.assertEqual(thumbnail_name("foo.png", name),
- 'foo_50.jpg')
- self.assertEqual(thumbnail_name("/tmp/foo", name),
- '/tmp/foo_50.jpg')
- self.assertEqual(thumbnail_name("/tmp/some.name/foo", name),
- '/tmp/some.name/foo_50.jpg')
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_serialization.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_serialization.py
deleted file mode 100644
index 1c7d3f18c..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_serialization.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import unittest
-from scrapy.utils.serialization import serialize, unserialize, serialize_funcs
-
-class SerializationTest(unittest.TestCase):
- def test_string_serialization(self):
- """Test simple string serialization"""
-
- s = "string to serialize"
- for format in serialize_funcs.iterkeys():
- self.assertEqual(s, unserialize(serialize(s)))
-
- def test_dict_serialization(self):
- """Test dict serialization"""
-
- # using only string keys/values since it's the only data type that
- # works with all serializers
- d = {'one': 'item one', 'two': 'item two'}
- for format in serialize_funcs.iterkeys():
- self.assertEqual(d, unserialize(serialize(d)))
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_spiders/testplugin.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_spiders/testplugin.py
deleted file mode 100644
index 0454db00e..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_spiders/testplugin.py
+++ /dev/null
@@ -1,41 +0,0 @@
-"""
-This is a spider for the unittest sample site.
-
-See scrapy/tests/test_engine.py for more info.
-"""
-import re
-
-from scrapy.spider import BaseSpider
-from scrapy.item import ScrapedItem
-from scrapy.link import LinkExtractor
-from scrapy.http import Request
-
-class TestSpider(BaseSpider):
- domain_name = "scrapytest.org"
- extra_domain_names = ["localhost"]
- start_urls = ['http://localhost']
-
- itemurl_re = re.compile("item\d+.html")
- name_re = re.compile("<h1>(.*?)</h1>", re.M)
- price_re = re.compile(">Price: \$(.*?)<", re.M)
-
- def parse(self, response):
- xlink = LinkExtractor()
- itemre = re.compile(self.itemurl_re)
- for url in xlink.extract_urls(response):
- if itemre.search(url):
- yield Request(url=url, callback=self.parse_item)
-
- def parse_item(self, response):
- item = ScrapedItem()
- m = self.name_re.search(response.body.to_string())
- if m:
- item.name = m.group(1)
- item.url = response.url
- m = self.price_re.search(response.body.to_string())
- if m:
- item.price = m.group(1)
- return [item]
-
-
-SPIDER = TestSpider()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_storedb.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_storedb.py
deleted file mode 100644
index 4e2d920b3..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_storedb.py
+++ /dev/null
@@ -1,76 +0,0 @@
-from datetime import datetime, timedelta
-from time import sleep
-
-from twisted.trial import unittest
-from scrapy.conf import settings
-
-
-class ProductComparisonTestCase(unittest.TestCase):
- """ Test product comparison functions """
-
- def setUp(self):
- self.test_db = settings.get('TEST_SCRAPING_DB')
- if not self.test_db:
- raise unittest.SkipTest("Missing TEST_SCRAPING_DB setting")
-
- try:
- import MySQLdb
- from scrapy.utils.db import mysql_connect
- mysql_connect(self.test_db)
- except ImportError:
- raise unittest.SkipTest("MySQLdb module not available")
- except MySQLdb.OperationalError:
- raise unittest.SkipTest("Test database not available at: %s" % self.test_db)
-
- def test_domaindatahistory(self):
- from scrapy.store.db import DomainDataHistory
- from time import sleep
-
- ddh = DomainDataHistory(self.test_db, 'domain_data_history')
- c = ddh.mysql_conn.cursor()
- c.execute("DELETE FROM domain_data_history")
- ddh.mysql_conn.commit()
-
- def now_nomicro():
- now = datetime.now()
- return now - timedelta(microseconds=now.microsecond)
-
- assert hasattr(ddh.get('scrapy.org'), '__iter__')
- self.assertEqual(list(ddh.get('scrapy.org')), [])
-
- self.assertEqual(ddh.domain_count(), 0)
-
- now = now_nomicro()
- ddh.put('scrapy.org', 'value', timestamp=now)
- self.assertEqual(list(ddh.get('scrapy.org')), [(now, 'value')])
- self.assertEqual(list(ddh.get('scrapy2.org')), [])
-
- sleep(1)
- now2 = now_nomicro()
- ddh.put('scrapy.org', 'newvalue', timestamp=now2)
- self.assertEqual(list(ddh.getall('scrapy.org')), [(now2, 'newvalue'), (now, 'value')])
-
- self.assertEqual(ddh.getlast('scrapy.org'), (now2, 'newvalue'))
- self.assertEqual(ddh.getlast('scrapy.org', offset=1), (now, 'value'))
- self.assertEqual(ddh.getlast('scrapy2.org'), None)
-
- ddh.remove('scrapy.org')
- self.assertEqual(list(ddh.get('scrapy.org')), [])
-
- now3 = now_nomicro()
- d1 = {'name': 'John', 'surname': 'Doe'}
- ddh.put('scrapy.org', d1, timestamp=now3)
- self.assertEqual(list(ddh.getall('scrapy.org')), [(now3, d1)])
-
- # get path support
- self.assertEqual(ddh.getlast('scrapy.org', path='name'), (now3, 'John'))
- # behaviour for non existant paths
- self.assertEqual(ddh.getlast('scrapy.org', path='name2'), (now3, None))
-
- self.assertEqual(ddh.domain_count(), 1)
-
- self.assertEqual(list(ddh.getlast_alldomains()),
- [('scrapy.org', now3, {'surname': 'Doe', 'name': 'John'})])
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_datatypes.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_datatypes.py
deleted file mode 100644
index 629eaf2ff..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_datatypes.py
+++ /dev/null
@@ -1,26 +0,0 @@
-import unittest
-from scrapy.utils.datatypes import PriorityQueue
-
-class DatatypesTestCase(unittest.TestCase):
-
- def test_priority_queue(self):
- pq = PriorityQueue()
-
- pq.put('b', priority=1)
- pq.put('a', priority=1)
- pq.put('c', priority=1)
- pq.put('z', priority=0)
- pq.put('d', priority=2)
-
- v = []
- p = []
- while not pq.empty():
- priority, value = pq.get()
- v.append(value)
- p.append(priority)
-
- self.assertEqual(v, ['z', 'b', 'a', 'c', 'd'])
- self.assertEqual(p, [0, 1, 1, 1, 2])
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_markup.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_markup.py
deleted file mode 100644
index 0624560d8..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_markup.py
+++ /dev/null
@@ -1,113 +0,0 @@
-import unittest
-
-from scrapy.utils.markup import remove_entities, replace_tags, remove_comments
-from scrapy.utils.markup import remove_tags_with_content, remove_escape_chars, remove_tags
-
-class UtilsMarkupTest(unittest.TestCase):
-
- def test_remove_entities(self):
- # make sure it always return uncode
- assert isinstance(remove_entities('no entities'), unicode)
- assert isinstance(remove_entities('Price: &pound;100!'), unicode)
-
- # regular conversions
- self.assertEqual(remove_entities(u'As low as &#163;100!'),
- u'As low as \xa3100!')
- self.assertEqual(remove_entities('As low as &pound;100!'),
- u'As low as \xa3100!')
- self.assertEqual(remove_entities('redirectTo=search&searchtext=MR0221Y&aff=buyat&affsrc=d_data&cm_mmc=buyat-_-ELECTRICAL & SEASONAL-_-MR0221Y-_-9-carat gold &frac12;oz solid crucifix pendant'),
- u'redirectTo=search&searchtext=MR0221Y&aff=buyat&affsrc=d_data&cm_mmc=buyat-_-ELECTRICAL & SEASONAL-_-MR0221Y-_-9-carat gold \xbdoz solid crucifix pendant')
- # keep some entities
- self.assertEqual(remove_entities('<b>Low &lt; High &amp; Medium &pound; six</b>', keep=['lt', 'amp']),
- u'<b>Low &lt; High &amp; Medium \xa3 six</b>')
-
- # illegal entities
- self.assertEqual(remove_entities('a &lt; b &illegal; c &#12345678; six', remove_illegal=False),
- u'a < b &illegal; c &#12345678; six')
- self.assertEqual(remove_entities('a &lt; b &illegal; c &#12345678; six', remove_illegal=True),
- u'a < b c six')
-
-
-
- def test_replace_tags(self):
- # make sure it always return uncode
- assert isinstance(replace_tags('no entities'), unicode)
-
- self.assertEqual(replace_tags(u'This text contains <a>some tag</a>'),
- u'This text contains some tag')
-
- self.assertEqual(replace_tags('This text is very im<b>port</b>ant', ' '),
- u'This text is very im port ant')
-
- # multiline tags
- self.assertEqual(replace_tags('Click <a class="one"\r\n href="url">here</a>'),
- u'Click here')
-
- def test_remove_comments(self):
- # make sure it always return unicode
- assert isinstance(remove_comments('without comments'), unicode)
- assert isinstance(remove_comments('<!-- with comments -->'), unicode)
-
- # text without comments
- self.assertEqual(remove_comments(u'text without comments'), u'text without comments')
-
- # text with comments
- self.assertEqual(remove_comments(u'<!--text with comments-->'), u'')
- self.assertEqual(remove_comments(u'Hello<!--World-->'),u'Hello')
-
- def test_remove_tags(self):
- # make sure it always return unicode
- assert isinstance(remove_tags('no tags'), unicode)
- assert isinstance(remove_tags('no tags', which_ones=('p',)), unicode)
- assert isinstance(remove_tags('<p>one tag</p>'), unicode)
- assert isinstance(remove_tags('<p>one tag</p>', which_ones=('p')), unicode)
- assert isinstance(remove_tags('<a>link</a>', which_ones=('b',)), unicode)
-
- # text without tags
- self.assertEqual(remove_tags(u'no tags'), u'no tags')
- self.assertEqual(remove_tags(u'no tags', which_ones=('p','b',)), u'no tags')
-
- # text with tags
- self.assertEqual(remove_tags(u'<p>one p tag</p>'), u'one p tag')
- self.assertEqual(remove_tags(u'<p>one p tag</p>', which_ones=('b',)), u'<p>one p tag</p>')
-
- self.assertEqual(remove_tags(u'<b>not will removed</b><i>i will removed</i>', which_ones=('i',)),
- u'<b>not will removed</b>i will removed')
-
- # text with tags and attributes
- self.assertEqual(remove_tags(u'<p align="center" class="one">texty</p>'), u'texty')
- self.assertEqual(remove_tags(u'<p align="center" class="one">texty</p>', which_ones=('b',)),
- u'<p align="center" class="one">texty</p>')
-
- def test_remove_tags_with_content(self):
- # make sure it always return unicode
- assert isinstance(remove_tags_with_content('no tags'), unicode)
- assert isinstance(remove_tags_with_content('no tags', which_ones=('p',)), unicode)
- assert isinstance(remove_tags_with_content('<p>one tag</p>', which_ones=('p',)), unicode)
- assert isinstance(remove_tags_with_content('<a>link</a>', which_ones=('b',)), unicode)
-
- # text without tags
- self.assertEqual(remove_tags_with_content(u'no tags'), u'no tags')
- self.assertEqual(remove_tags_with_content(u'no tags', which_ones=('p','b',)), u'no tags')
-
- # text with tags
- self.assertEqual(remove_tags_with_content(u'<p>one p tag</p>'), u'<p>one p tag</p>')
- self.assertEqual(remove_tags_with_content(u'<p>one p tag</p>', which_ones=('p',)), u'')
-
- self.assertEqual(remove_tags_with_content(u'<b>not will removed</b><i>i will removed</i>', which_ones=('i',)),
- u'<b>not will removed</b>')
-
- def test_remove_escape_chars(self):
- # make sure it always return unicode
- assert isinstance(remove_escape_chars('no ec'), unicode)
- assert isinstance(remove_escape_chars('no ec', which_ones=('\n','\t',)), unicode)
-
- # text without escape chars
- self.assertEqual(remove_escape_chars(u'no ec'), u'no ec')
- self.assertEqual(remove_escape_chars(u'no ec', which_ones=('\n',)), u'no ec')
-
- # text with escape chars
- self.assertEqual(remove_escape_chars(u'escape\n\n'), u'escape')
- self.assertEqual(remove_escape_chars(u'escape\n', which_ones=('\t',)), u'escape\n')
- self.assertEqual(remove_escape_chars(u'escape\tchars\n', which_ones=('\t')), 'escapechars\n')
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_url.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_url.py
deleted file mode 100644
index bc7dae523..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_url.py
+++ /dev/null
@@ -1,151 +0,0 @@
-import unittest
-from scrapy.utils.url import url_is_from_any_domain, safe_url_string, safe_download_url, url_query_parameter, add_or_replace_parameter, url_query_cleaner, canonicalize_url
-
-class UrlUtilsTest(unittest.TestCase):
-
- def test_url_is_from_any_domain(self):
- url = 'http://www.wheele-bin-art.co.uk/get/product/123'
- self.assertTrue(url_is_from_any_domain(url, ['wheele-bin-art.co.uk']))
- self.assertFalse(url_is_from_any_domain(url, ['art.co.uk']))
-
- url = 'http://wheele-bin-art.co.uk/get/product/123'
- self.assertTrue(url_is_from_any_domain(url, ['wheele-bin-art.co.uk']))
- self.assertFalse(url_is_from_any_domain(url, ['art.co.uk']))
-
- url = 'javascript:%20document.orderform_2581_1190810811.mode.value=%27add%27;%20javascript:%20document.orderform_2581_1190810811.submit%28%29'
- self.assertFalse(url_is_from_any_domain(url, ['testdomain.com']))
- self.assertFalse(url_is_from_any_domain(url+'.testdomain.com', ['testdomain.com']))
-
- def test_safe_url_string(self):
- # Motoko Kusanagi (Cyborg from Ghost in the Shell)
- motoko = u'\u8349\u8599 \u7d20\u5b50'
- self.assertEqual(safe_url_string(motoko), # note the %20 for space
- '%E8%8D%89%E8%96%99%20%E7%B4%A0%E5%AD%90')
- self.assertEqual(safe_url_string(motoko),
- safe_url_string(safe_url_string(motoko)))
- self.assertEqual(safe_url_string(u'\xa9'), # copyright symbol
- '%C2%A9')
- self.assertEqual(safe_url_string(u'\xa9', 'iso-8859-1'),
- '%A9')
- self.assertEqual(safe_url_string("http://www.scrapy.org/"),
- 'http://www.scrapy.org/')
-
- alessi = u'/ecommerce/oggetto/Te \xf2/tea-strainer/1273'
-
- self.assertEqual(safe_url_string(alessi),
- '/ecommerce/oggetto/Te%20%C3%B2/tea-strainer/1273')
-
- self.assertEqual(safe_url_string("http://www.example.com/test?p(29)url(http://www.another.net/page)"),
- "http://www.example.com/test?p(29)url(http://www.another.net/page)")
- self.assertEqual(safe_url_string("http://www.example.com/Brochures_&_Paint_Cards&PageSize=200"),
- "http://www.example.com/Brochures_&_Paint_Cards&PageSize=200")
-
- def test_safe_download_url(self):
- self.assertEqual(safe_download_url('http://www.scrapy.org/../'),
- 'http://www.scrapy.org/')
- self.assertEqual(safe_download_url('http://www.scrapy.org/../../images/../image'),
- 'http://www.scrapy.org/image')
- self.assertEqual(safe_download_url('http://www.scrapy.org/dir/'),
- 'http://www.scrapy.org/dir/')
-
- def test_url_query_parameter(self):
- self.assertEqual(url_query_parameter("product.html?id=200&foo=bar", "id"),
- '200')
- self.assertEqual(url_query_parameter("product.html?id=200&foo=bar", "notthere", "mydefault"),
- 'mydefault')
- self.assertEqual(url_query_parameter("product.html?id=", "id"),
- None)
- self.assertEqual(url_query_parameter("product.html?id=", "id", keep_blank_values=1),
- '')
-
- def test_add_or_replace_parameter(self):
- url = 'http://domain/test'
- self.assertEqual(add_or_replace_parameter(url, 'arg', 'v'),
- 'http://domain/test?arg=v')
- url = 'http://domain/test?arg1=v1&arg2=v2&arg3=v3'
- self.assertEqual(add_or_replace_parameter(url, 'arg4', 'v4'),
- 'http://domain/test?arg1=v1&arg2=v2&arg3=v3&arg4=v4')
- self.assertEqual(add_or_replace_parameter(url, 'arg3', 'nv3'),
- 'http://domain/test?arg1=v1&arg2=v2&arg3=nv3')
- url = 'http://domain/test?arg1=v1'
- self.assertEqual(add_or_replace_parameter(url, 'arg2', 'v2', sep=';'),
- 'http://domain/test?arg1=v1;arg2=v2')
- self.assertEqual(add_or_replace_parameter("http://domain/moreInfo.asp?prodID=", 'prodID', '20'),
- 'http://domain/moreInfo.asp?prodID=20')
-
- def test_url_query_cleaner(self):
- self.assertEqual(url_query_cleaner("product.html?id=200&foo=bar&name=wired", 'id'),
- 'product.html?id=200')
- self.assertEqual(url_query_cleaner("product.html?id=200&foo=bar&name=wired", ['id', 'name']),
- 'product.html?id=200&name=wired')
-
- def test_canonicalize_url(self):
- # no query arguments
- self.assertEqual(canonicalize_url("http://www.example.com"),
- "http://www.example.com")
-
- # typical usage
- self.assertEqual(canonicalize_url("http://www.example.com/do?a=1&b=2&c=3"),
- "http://www.example.com/do?a=1&b=2&c=3")
- self.assertEqual(canonicalize_url("http://www.example.com/do?c=1&b=2&a=3"),
- "http://www.example.com/do?a=3&b=2&c=1")
- self.assertEqual(canonicalize_url("http://www.example.com/do?&a=1"),
- "http://www.example.com/do?a=1")
-
- # sorting by argument values
- self.assertEqual(canonicalize_url("http://www.example.com/do?c=3&b=5&b=2&a=50"),
- "http://www.example.com/do?a=50&b=2&b=5&c=3")
-
- # using keep_blank_values
- self.assertEqual(canonicalize_url("http://www.example.com/do?b=&a=2"),
- "http://www.example.com/do?a=2")
- self.assertEqual(canonicalize_url("http://www.example.com/do?b=&a=2", keep_blank_values=True),
- "http://www.example.com/do?a=2&b=")
- self.assertEqual(canonicalize_url("http://www.example.com/do?b=&c&a=2"),
- "http://www.example.com/do?a=2")
- self.assertEqual(canonicalize_url("http://www.example.com/do?b=&c&a=2", keep_blank_values=True),
- "http://www.example.com/do?a=2&b=&c=")
-
- # spaces
- self.assertEqual(canonicalize_url("http://www.example.com/do?q=a space&a=1"),
- "http://www.example.com/do?a=1&q=a+space")
- self.assertEqual(canonicalize_url("http://www.example.com/do?q=a+space&a=1"),
- "http://www.example.com/do?a=1&q=a+space")
- self.assertEqual(canonicalize_url("http://www.example.com/do?q=a%20space&a=1"),
- "http://www.example.com/do?a=1&q=a+space")
-
- # normalize percent-encoding case (in paths)
- self.assertEqual(canonicalize_url("http://www.example.com/a%a3do"),
- "http://www.example.com/a%A3do"),
- # normalize percent-encoding case (in query arguments)
- self.assertEqual(canonicalize_url("http://www.example.com/do?k=b%a3"),
- "http://www.example.com/do?k=b%A3")
-
- # non-ASCII percent-encoding in paths
- self.assertEqual(canonicalize_url("http://www.example.com/a do?a=1"),
- "http://www.example.com/a%20do?a=1"),
- self.assertEqual(canonicalize_url("http://www.example.com/a %20do?a=1"),
- "http://www.example.com/a%20%20do?a=1"),
- self.assertEqual(canonicalize_url("http://www.example.com/a do\xc2\xa3.html?a=1"),
- "http://www.example.com/a%20do%C2%A3.html?a=1")
- # non-ASCII percent-encoding in query arguments
- self.assertEqual(canonicalize_url(u"http://www.example.com/do?price=\xa3500&a=5&z=3"),
- u"http://www.example.com/do?a=5&price=%C2%A3500&z=3")
- self.assertEqual(canonicalize_url("http://www.example.com/do?price=\xc2\xa3500&a=5&z=3"),
- "http://www.example.com/do?a=5&price=%C2%A3500&z=3")
- self.assertEqual(canonicalize_url("http://www.example.com/do?price(\xc2\xa3)=500&a=1"),
- "http://www.example.com/do?a=1&price%28%C2%A3%29=500")
-
- # urls containing auth and ports
- self.assertEqual(canonicalize_url(u"http://user:[email protected]:81/do?now=1"),
- u"http://user:[email protected]:81/do?now=1")
-
- # remove fragments
- self.assertEqual(canonicalize_url(u"http://user:[email protected]/do?a=1#frag"),
- u"http://user:[email protected]/do?a=1")
- self.assertEqual(canonicalize_url(u"http://user:[email protected]/do?a=1#frag", keep_fragments=True),
- u"http://user:[email protected]/do?a=1#frag")
-
-if __name__ == "__main__":
- unittest.main()
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_xml.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_xml.py
deleted file mode 100644
index fd59a446b..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_utils_xml.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import os
-import unittest
-
-from scrapy.utils.xml import xpathselector_iternodes
-from scrapy.http import Response
-
-class UtilsXmlTestCase(unittest.TestCase):
-
- def test_iterator(self):
- body = """<?xml version="1.0" encoding="UTF-8"?>
-<products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="someschmea.xsd">
- <product id="001">
- <type>Type 1</type>
- <name>Name 1</name>
- </product>
- <product id="002">
- <type>Type 2</type>
- <name>Name 2</name>
- </product>
-</products>
- """
- response = Response(domain="example.com", url="http://example.com", body=body)
- attrs = []
- for x in xpathselector_iternodes(response, 'product'):
- attrs.append((x.x("@id").extract(), x.x("name/text()").extract(), x.x("./type/text()").extract()))
-
- self.assertEqual(attrs,
- [(['001'], ['Name 1'], ['Type 1']), (['002'], ['Name 2'], ['Type 2'])])
-
- def test_iterator_text(self):
- body = u"""<?xml version="1.0" encoding="UTF-8"?><products><product>one</product><product>two</product></products>"""
-
- self.assertEqual([x.x("text()").extract() for x in xpathselector_iternodes(body, 'product')],
- [[u'one'], [u'two']])
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_xpath.py b/scrapy/branches/cluster-refactor/scrapy/tests/test_xpath.py
deleted file mode 100644
index 99c06119b..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/tests/test_xpath.py
+++ /dev/null
@@ -1,225 +0,0 @@
-import re
-import unittest
-
-import libxml2
-
-from scrapy.http import Response
-from scrapy.xpath.selector import XmlXPathSelector, HtmlXPathSelector
-
-class XPathTestCase(unittest.TestCase):
-
- def setUp(self):
- libxml2.debugMemory(1)
-
- def tearDown(self):
- libxml2.cleanupParser()
- leaked_bytes = libxml2.debugMemory(0)
- assert leaked_bytes == 0, "libxml2 memory leak detected: %d bytes" % leaked_bytes
-
- def test_selector_simple(self):
- """Simple selector tests"""
- body = "<p><input name='a'value='1'/><input name='b'value='2'/></p>"
- response = Response(domain="example.com", url="http://example.com", body=body)
- xpath = HtmlXPathSelector(response)
-
- xl = xpath.x('//input')
- self.assertEqual(2, len(xl))
- for x in xl:
- assert isinstance(x, HtmlXPathSelector)
-
- self.assertEqual(xpath.x('//input').extract(),
- [x.extract() for x in xpath.x('//input')])
-
- self.assertEqual([x.extract() for x in xpath.x("//input[@name='a']/@name")],
- [u'a'])
- self.assertEqual([x.extract() for x in xpath.x("number(concat(//input[@name='a']/@value, //input[@name='b']/@value))")],
- [u'12.0'])
-
- self.assertEqual(xpath.x("concat('xpath', 'rules')").extract(),
- [u'xpathrules'])
- self.assertEqual([x.extract() for x in xpath.x("concat(//input[@name='a']/@value, //input[@name='b']/@value)")],
- [u'12'])
-
- def test_selector_same_type(self):
- """Test XPathSelector returning the same type in x() method"""
- text = '<p>test<p>'
- assert isinstance(XmlXPathSelector(text=text).x("//p")[0],
- XmlXPathSelector)
- assert isinstance(HtmlXPathSelector(text=text).x("//p")[0],
- HtmlXPathSelector)
-
- def test_selector_xml_html(self):
- """Test that XML and HTML XPathSelector's behave differently"""
-
- # some text which is parsed differently by XML and HTML flavors
- text = '<div><img src="a.jpg"><p>Hello</div>'
-
- self.assertEqual(XmlXPathSelector(text=text).x("//div").extract(),
- [u'<div><img src="a.jpg"><p>Hello</p></img></div>'])
-
- self.assertEqual(HtmlXPathSelector(text=text).x("//div").extract(),
- [u'<div><img src="a.jpg"><p>Hello</p></div>'])
-
- def test_selector_nested(self):
- """Nested selector tests"""
- body = """<body>
- <div class='one'>
- <ul>
- <li>one</li><li>two</li>
- </ul>
- </div>
- <div class='two'>
- <ul>
- <li>four</li><li>five</li><li>six</li>
- </ul>
- </div>
- </body>"""
-
- response = Response(domain="example.com", url="http://example.com", body=body)
- x = HtmlXPathSelector(response)
-
- divtwo = x.x('//div[@class="two"]')
- self.assertEqual(divtwo.x("//li").extract(),
- ["<li>one</li>", "<li>two</li>", "<li>four</li>", "<li>five</li>", "<li>six</li>"])
- self.assertEqual(divtwo.x("./ul/li").extract(),
- ["<li>four</li>", "<li>five</li>", "<li>six</li>"])
- self.assertEqual(divtwo.x(".//li").extract(),
- ["<li>four</li>", "<li>five</li>", "<li>six</li>"])
- self.assertEqual(divtwo.x("./li").extract(),
- [])
-
- def test_selector_re(self):
- body = """<div>Name: Mary
- <ul>
- <li>Name: John</li>
- <li>Age: 10</li>
- <li>Name: Paul</li>
- <li>Age: 20</li>
- </ul>
- Age: 20
- </div>
-
- """
- response = Response(domain="example.com", url="http://example.com", body=body)
- x = HtmlXPathSelector(response)
-
- name_re = re.compile("Name: (\w+)")
- self.assertEqual(x.x("//ul/li").re(name_re),
- ["John", "Paul"])
- self.assertEqual(x.x("//ul/li").re("Age: (\d+)"),
- ["10", "20"])
-
- def test_selector_over_text(self):
- hxs = HtmlXPathSelector(text='<root>lala</root>')
- self.assertEqual(hxs.extract(),
- u'<html><body><root>lala</root></body></html>')
-
- xxs = XmlXPathSelector(text='<root>lala</root>')
- self.assertEqual(xxs.extract(),
- u'<root>lala</root>')
-
- xxs = XmlXPathSelector(text='<root>lala</root>')
- self.assertEqual(xxs.x('.').extract(),
- [u'<root>lala</root>'])
-
-
- def test_selector_namespaces_simple(self):
- body = """
- <test xmlns:somens="http://scrapy.org">
- <somens:a id="foo"/>
- <a id="bar">found</a>
- </test>
- """
-
- response = Response(domain="example.com", url="http://example.com", body=body)
- x = XmlXPathSelector(response)
-
- x.register_namespace("somens", "http://scrapy.org")
- self.assertEqual(x.x("//somens:a").extract(),
- ['<somens:a id="foo"/>'])
-
-
- def test_selector_namespaces_multiple(self):
- body = """<?xml version="1.0" encoding="UTF-8"?>
-<BrowseNode xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05"
- xmlns:b="http://somens.com"
- xmlns:p="http://www.scrapy.org/product" >
- <b:Operation>hello</b:Operation>
- <TestTag b:att="value"><Other>value</Other></TestTag>
- <p:SecondTestTag><material/><price>90</price><p:name>Dried Rose</p:name></p:SecondTestTag>
-</BrowseNode>
- """
- response = Response(domain="example.com", url="http://example.com", body=body)
- x = XmlXPathSelector(response)
-
- x.register_namespace("xmlns", "http://webservices.amazon.com/AWSECommerceService/2005-10-05")
- x.register_namespace("p", "http://www.scrapy.org/product")
- x.register_namespace("b", "http://somens.com")
- self.assertEqual(len(x.x("//xmlns:TestTag")), 1)
- self.assertEqual(x.x("//b:Operation/text()").extract()[0], 'hello')
- self.assertEqual(x.x("//xmlns:TestTag/@b:att").extract()[0], 'value')
- self.assertEqual(x.x("//p:SecondTestTag/xmlns:price/text()").extract()[0], '90')
- self.assertEqual(x.x("//p:SecondTestTag").x("./xmlns:price/text()")[0].extract(), '90')
- self.assertEqual(x.x("//p:SecondTestTag/xmlns:material").extract()[0], '<material/>')
-
- def test_http_header_encoding_precedence(self):
- # u'\xa3' = pound symbol in unicode
- # u'\xc2\xa3' = pound symbol in utf-8
- # u'\xa3' = pound symbol in latin-1 (iso-8859-1)
-
- meta = u'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'
- head = u'<head>' + meta + u'</head>'
- body_content = u'<span id="blank">\xa3</span>'
- body = u'<body>' + body_content + u'</body>'
- html = u'<html>' + head + body + u'</html>'
- encoding = 'utf-8'
- html_utf8 = html.encode(encoding)
-
- headers = {'Content-Type': ['text/html; charset=utf-8']}
- response = Response(domain="example.com", url="http://example.com", headers=headers, body=html_utf8)
- x = HtmlXPathSelector(response)
- self.assertEquals(x.x("//span[@id='blank']/text()").extract(),
- [u'\xa3'])
-
- def test_null_bytes(self):
- hxs = HtmlXPathSelector(text='<root>la\x00la</root>')
- self.assertEqual(hxs.extract(),
- u'<html><body><root>lala</root></body></html>')
-
- xxs = XmlXPathSelector(text='<root>la\x00la</root>')
- self.assertEqual(xxs.extract(),
- u'<root>lala</root>')
-
- def test_unquote(self):
- xmldoc = '\n'.join((
- '<root>',
- ' lala',
- ' <node>',
- ' blabla&amp;more<!--comment-->a<b>test</b>oh',
- ' <![CDATA[lalalal&ppppp<b>PPPP</b>ppp&amp;la]]>',
- ' </node>',
- ' pff',
- '</root>'))
- xxs = XmlXPathSelector(text=xmldoc)
-
- self.assertEqual(xxs.extract_unquoted(), u'')
-
- self.assertEqual(xxs.x('/root').extract_unquoted(), [u''])
- self.assertEqual(xxs.x('/root/text()').extract_unquoted(), [
- u'\n lala\n ',
- u'\n pff\n'])
-
- self.assertEqual(xxs.x('//*').extract_unquoted(), [u'', u'', u''])
- self.assertEqual(xxs.x('//text()').extract_unquoted(), [
- u'\n lala\n ',
- u'\n blabla&more',
- u'a',
- u'test',
- u'oh\n ',
- u'lalalal&ppppp<b>PPPP</b>ppp&amp;la',
- u'\n ',
- u'\n pff\n'])
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/datatypes.py b/scrapy/branches/cluster-refactor/scrapy/utils/datatypes.py
deleted file mode 100644
index ab32a82ce..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/datatypes.py
+++ /dev/null
@@ -1,458 +0,0 @@
-"""
-This module contains data types used by Scrapy which are not included in the
-Python Standard Library.
-
-This module must not depend on any module outside the Standard Library.
-"""
-
-import copy
-import gzip
-import Queue
-import bisect
-from cStringIO import StringIO
-
-class MergeDict(object):
- """
- A simple class for creating new "virtual" dictionaries that actualy look
- up values in more than one dictionary, passed in the constructor.
- """
- def __init__(self, *dicts):
- self.dicts = dicts
-
- def __getitem__(self, key):
- for dict_ in self.dicts:
- try:
- return dict_[key]
- except KeyError:
- pass
- raise KeyError
-
- def __copy__(self):
- return self.__class__(*self.dicts)
-
- def get(self, key, default=None):
- try:
- return self[key]
- except KeyError:
- return default
-
- def getlist(self, key):
- for dict in self.dicts:
- try:
- return dict.getlist(key)
- except KeyError:
- pass
- raise KeyError
-
- def items(self):
- item_list = []
- for dict in self.dicts:
- item_list.extend(dict.items())
- return item_list
-
- def has_key(self, key):
- for dict in self.dicts:
- if key in dict:
- return True
- return False
-
- __contains__ = has_key
-
- def copy(self):
- """ returns a copy of this object"""
- return self.__copy__()
-
-class SortedDict(dict):
- "A dictionary that keeps its keys in the order in which they're inserted."
- def __init__(self, data=None):
- if data is None:
- data = {}
- dict.__init__(self, data)
- self.keyOrder = data.keys()
-
- def __setitem__(self, key, value):
- dict.__setitem__(self, key, value)
- if key not in self.keyOrder:
- self.keyOrder.append(key)
-
- def __delitem__(self, key):
- dict.__delitem__(self, key)
- self.keyOrder.remove(key)
-
- def __iter__(self):
- for k in self.keyOrder:
- yield k
-
- def items(self):
- return zip(self.keyOrder, self.values())
-
- def iteritems(self):
- for key in self.keyOrder:
- yield key, dict.__getitem__(self, key)
-
- def keys(self):
- return self.keyOrder[:]
-
- def iterkeys(self):
- return iter(self.keyOrder)
-
- def values(self):
- return [dict.__getitem__(self, k) for k in self.keyOrder]
-
- def itervalues(self):
- for key in self.keyOrder:
- yield dict.__getitem__(self, key)
-
- def update(self, dict):
- for k, v in dict.items():
- self.__setitem__(k, v)
-
- def setdefault(self, key, default):
- if key not in self.keyOrder:
- self.keyOrder.append(key)
- return dict.setdefault(self, key, default)
-
- def value_for_index(self, index):
- "Returns the value of the item at the given zero-based index."
- return self[self.keyOrder[index]]
-
- def insert(self, index, key, value):
- "Inserts the key, value pair before the item with the given index."
- if key in self.keyOrder:
- n = self.keyOrder.index(key)
- del self.keyOrder[n]
- if n < index:
- index -= 1
- self.keyOrder.insert(index, key)
- dict.__setitem__(self, key, value)
-
- def copy(self):
- "Returns a copy of this object."
- # This way of initializing the copy means it works for subclasses, too.
- obj = self.__class__(self)
- obj.keyOrder = self.keyOrder
- return obj
-
- def __repr__(self):
- """
- Replaces the normal dict.__repr__ with a version that returns the keys
- in their sorted order.
- """
- return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()])
-
-class MultiValueDictKeyError(KeyError):
- pass
-
-class MultiValueDict(dict):
- """
- A subclass of dictionary customized to handle multiple values for the same key.
-
- >>> d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': ['Developer']})
- >>> d['name']
- 'Simon'
- >>> d.getlist('name')
- ['Adrian', 'Simon']
- >>> d.get('lastname', 'nonexistent')
- 'nonexistent'
- >>> d.setlist('lastname', ['Holovaty', 'Willison'])
-
- This class exists to solve the irritating problem raised by cgi.parse_qs,
- which returns a list for every key, even though most Web forms submit
- single name-value pairs.
- """
- def __init__(self, key_to_list_mapping=()):
- dict.__init__(self, key_to_list_mapping)
-
- def __repr__(self):
- return "<%s: %s>" % (self.__class__.__name__, dict.__repr__(self))
-
- def __getitem__(self, key):
- """
- Returns the last data value for this key, or [] if it's an empty list;
- raises KeyError if not found.
- """
- try:
- list_ = dict.__getitem__(self, key)
- except KeyError:
- raise MultiValueDictKeyError, "Key %r not found in %r" % (key, self)
- try:
- return list_[-1]
- except IndexError:
- return []
-
- def __setitem__(self, key, value):
- dict.__setitem__(self, key, [value])
-
- def __copy__(self):
- return self.__class__(dict.items(self))
-
- def __deepcopy__(self, memo=None):
- if memo is None:
- memo = {}
- result = self.__class__()
- memo[id(self)] = result
- for key, value in dict.items(self):
- dict.__setitem__(result, copy.deepcopy(key, memo), copy.deepcopy(value, memo))
- return result
-
- def get(self, key, default=None):
- "Returns the default value if the requested data doesn't exist"
- try:
- val = self[key]
- except KeyError:
- return default
- if val == []:
- return default
- return val
-
- def getlist(self, key):
- "Returns an empty list if the requested data doesn't exist"
- try:
- return dict.__getitem__(self, key)
- except KeyError:
- return []
-
- def setlist(self, key, list_):
- dict.__setitem__(self, key, list_)
-
- def setdefault(self, key, default=None):
- if key not in self:
- self[key] = default
- return self[key]
-
- def setlistdefault(self, key, default_list=()):
- if key not in self:
- self.setlist(key, default_list)
- return self.getlist(key)
-
- def appendlist(self, key, value):
- "Appends an item to the internal list associated with key"
- self.setlistdefault(key, [])
- dict.__setitem__(self, key, self.getlist(key) + [value])
-
- def items(self):
- """
- Returns a list of (key, value) pairs, where value is the last item in
- the list associated with the key.
- """
- return [(key, self[key]) for key in self.keys()]
-
- def lists(self):
- "Returns a list of (key, list) pairs."
- return dict.items(self)
-
- def values(self):
- "Returns a list of the last value on every key list."
- return [self[key] for key in self.keys()]
-
- def copy(self):
- "Returns a copy of this object."
- return self.__deepcopy__()
-
- def update(self, *args, **kwargs):
- "update() extends rather than replaces existing key lists. Also accepts keyword args."
- if len(args) > 1:
- raise TypeError, "update expected at most 1 arguments, got %d" % len(args)
- if args:
- other_dict = args[0]
- if isinstance(other_dict, MultiValueDict):
- for key, value_list in other_dict.lists():
- self.setlistdefault(key, []).extend(value_list)
- else:
- try:
- for key, value in other_dict.items():
- self.setlistdefault(key, []).append(value)
- except TypeError:
- raise ValueError, "MultiValueDict.update() takes either a MultiValueDict or dictionary"
- for key, value in kwargs.iteritems():
- self.setlistdefault(key, []).append(value)
-
-class DotExpandedDict(dict):
- """
- A special dictionary constructor that takes a dictionary in which the keys
- may contain dots to specify inner dictionaries. It's confusing, but this
- example should make sense.
-
- >>> d = DotExpandedDict({'person.1.firstname': ['Simon'], \
- 'person.1.lastname': ['Willison'], \
- 'person.2.firstname': ['Adrian'], \
- 'person.2.lastname': ['Holovaty']})
- >>> d
- {'person': {'1': {'lastname': ['Willison'], 'firstname': ['Simon']}, '2': {'lastname': ['Holovaty'], 'firstname': ['Adrian']}}}
- >>> d['person']
- {'1': {'lastname': ['Willison'], 'firstname': ['Simon']}, '2': {'lastname': ['Holovaty'], 'firstname': ['Adrian']}}
- >>> d['person']['1']
- {'lastname': ['Willison'], 'firstname': ['Simon']}
-
- # Gotcha: Results are unpredictable if the dots are "uneven":
- >>> DotExpandedDict({'c.1': 2, 'c.2': 3, 'c': 1})
- {'c': 1}
- """
- def __init__(self, key_to_list_mapping):
- for k, v in key_to_list_mapping.items():
- current = self
- bits = k.split('.')
- for bit in bits[:-1]:
- current = current.setdefault(bit, {})
- # Now assign value to current position
- try:
- current[bits[-1]] = v
- except TypeError: # Special-case if current isn't a dict.
- current = {bits[-1] : v}
-
-class FileDict(dict):
- """
- A dictionary used to hold uploaded file contents. The only special feature
- here is that repr() of this object won't dump the entire contents of the
- file to the output. A handy safeguard for a large file upload.
- """
- def __repr__(self):
- if 'content' in self:
- d = dict(self, content='<omitted>')
- return dict.__repr__(d)
- return dict.__repr__(self)
-
-class Sitemap(object):
- """Sitemap class is used to build a map of the traversed pages"""
-
- def __init__(self):
- self._nodes = {}
- self._roots = []
-
- def add_node(self, url, parent_url):
- if not url in self._nodes:
- parent = self._nodes.get(parent_url, None)
- node = SiteNode(url)
- self._nodes[url] = node
- if parent:
- parent.add_child(node)
- else:
- self._roots.append(node)
-
- def add_item(self, url, item):
- if url in self._nodes:
- self._nodes[url].itemnames.append(str(item))
-
- def to_string(self):
- s = ''.join([n.to_string(0) for n in self._roots])
- return s
-
-class SiteNode(object):
- """Class to represent a site node (page, image or any other file)"""
-
- def __init__(self, url):
- self.url = url
- self.itemnames = []
- self.children = []
- self.parent = None
-
- def add_child(self, node):
- self.children.append(node)
- node.parent = self
-
- def to_string(self, level=0):
- s = "%s%s\n" % (' '*level, self.url)
- if self.itemnames:
- for n in self.itemnames:
- s += "%sScraped: %s\n" % (' '*(level+1), n)
- for node in self.children:
- s += node.to_string(level+1)
- return s
-
-class CaselessDict(dict):
- def __init__(self, other=None):
- if other:
- # Doesn't do keyword args
- if isinstance(other, dict):
- for k, v in other.items():
- dict.__setitem__(self, self.normkey(k), v)
- else:
- for k, v in other:
- dict.__setitem__(self, self.normkey(k), v)
-
- def __getitem__(self, key):
- return dict.__getitem__(self, self.normkey(key))
-
- def __setitem__(self, key, value):
- dict.__setitem__(self, self.normkey(key), value)
-
- def __delitem__(self, key):
- dict.__delitem__(self, self.normkey(key))
-
- def __contains__(self, key):
- return dict.__contains__(self, self.normkey(key))
-
- def normkey(self, key):
- return key.lower()
-
- def has_key(self, key):
- return dict.has_key(self, self.normkey(key))
-
- def get(self, key, def_val=None):
- return dict.get(self, self.normkey(key), def_val)
-
- def setdefault(self, key, def_val=None):
- return dict.setdefault(self, self.normkey(key), def_val)
-
- def update(self, other):
- for k, v in other.items():
- dict.__setitem__(self, self.normkey(k), v)
-
- def fromkeys(self, iterable, value=None):
- d = CaselessDict()
- for k in iterable:
- dict.__setitem__(d, self.normkey(k), value)
- return d
-
- def pop(self, key, def_val=None):
- return dict.pop(self, self.normkey(key), def_val)
-
-
-class PriorityQueue(Queue.Queue):
-
- def __len__(self):
- return self.qsize()
-
- def _init(self, maxsize):
- self.maxsize = maxsize
- # Python 2.5 uses collections.deque, but we can't because
- # we need insert(pos, item) for our priority stuff
- self.queue = []
-
- def put(self, item, priority=0, block=True, timeout=None):
- """Puts an item onto the queue with a numeric priority (default is zero).
-
- Note that we are "shadowing" the original Queue.Queue put() method here.
- """
- Queue.Queue.put(self, (priority, item), block, timeout)
-
- def _put(self, item):
- """Override of the Queue._put to support prioritisation."""
- # Priorities must be integers!
- priority = int(item[0])
-
- # Using a tuple (priority+1,) finds us the correct insertion
- # position to maintain the existing ordering.
- self.queue.insert(bisect.bisect_left(self.queue, (priority+1,)), item)
-
- def _get(self):
- """Override of Queue._get(). Strips the priority."""
- return self.queue.pop(0)
-
-
-class PriorityStack(PriorityQueue):
- def _put(self, item):
- priority = int(item[0])
- self.queue.insert(bisect.bisect_left(self.queue, (priority,)), item)
-
-class gzStringIO:
- """a file like object, similar to StringIO, but gzip-compressed."""
- def __init__(self, data, compress_level = 9, filename = ""):
- self._s = StringIO()
- g = gzip.GzipFile(filename, "wb", compress_level, self._s)
- g.write(data)
- g.flush()
- g.close()
- def read(self):
- return self._s.getvalue()
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/db.py b/scrapy/branches/cluster-refactor/scrapy/utils/db.py
deleted file mode 100644
index a3aa5a672..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/db.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""
-Function for dealing with databases
-"""
-import re
-from scrapy.conf import settings
-from scrapy import log
-from scrapy.core.engine import scrapyengine
-
-def mysql_connect(db_uri, **kwargs):
- """
- Connects to a MySQL DB given a mysql URI
- """
- import MySQLdb
-
- if not db_uri or not db_uri.startswith('mysql://'):
- raise Exception("Incorrect MySQL URI: %s" % db_uri)
- m = re.search(r"mysql:\/\/(?P<user>[^:]+)(:(?P<passwd>[^@]+))?@(?P<host>[^/]+)/(?P<db>.*)$", db_uri)
- if m:
- d = m.groupdict()
- if d['passwd'] is None:
- del(d['passwd'])
-
- d.update(settings.get("MYSQL_CONNECTION_SETTINGS"))
- d.update(kwargs)
-
- dcopy = d.copy()
- if dcopy.get("passwd"):
- dcopy["passwd"] = "********"
- log.msg("Connecting db with settings %s" % dcopy )
-
- conn = MySQLdb.connect(**d)
-
- #this is to maintain active the connection
- def _ping():
- log.msg("Pinging connection to %s/%s" % (d.get('host'), d.get('db')) )
- conn.ping()
- scrapyengine.addtask(_ping, settings.getint("MYSQL_CONNECTION_PING_PERIOD", 600))
-
- return conn
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/decompressor.py b/scrapy/branches/cluster-refactor/scrapy/utils/decompressor.py
deleted file mode 100644
index 67849ef48..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/decompressor.py
+++ /dev/null
@@ -1,72 +0,0 @@
-"""
-Utility for autodetecting and decompressing responses
-"""
-
-import zipfile
-import tarfile
-import gzip
-import bz2
-from scrapy.http import ResponseBody
-try:
- from cStringIO import StringIO
-except:
- from StringIO import StringIO
-
-class Decompressor(object):
- class ArchiveIsEmpty(Exception):
- pass
-
- def __init__(self):
- self.decompressors = {'tar': self.is_tar, 'zip': self.is_zip,
- 'gz': self.is_gzip, 'bz2': self.is_bzip2}
-
- def is_tar(self, response):
- try:
- tar_file = tarfile.open(name='tar.tmp', fileobj=self.archive)
- except tarfile.ReadError:
- return False
- if tar_file.members:
- return response.replace(body=ResponseBody(tar_file.extractfile(tar_file.members[0]).read()))
- else:
- raise self.ArchiveIsEmpty
-
- def is_zip(self, response):
- try:
- zip_file = zipfile.ZipFile(self.archive)
- except zipfile.BadZipfile:
- return False
- namelist = zip_file.namelist()
- if namelist:
- return response.replace(body=ResponseBody(zip_file.read(namelist[0])))
- else:
- raise self.ArchiveIsEmpty
-
- def is_gzip(self, response):
- try:
- gzip_file = gzip.GzipFile(fileobj=self.archive)
- decompressed_body = gzip_file.read()
- except IOError:
- return False
- return response.replace(body=decompressed_body)
-
- def is_bzip2(self, response):
- try:
- decompressed_body = bz2.decompress(self.body)
- except IOError:
- return False
- return response.replace(body=ResponseBody(decompressed_body))
-
- def extract_winfo(self, response):
- self.body = response.body.to_string()
- self.archive = StringIO()
- self.archive.write(self.body)
-
- for decompressor in self.decompressors.keys():
- self.archive.seek(0)
- new_response = self.decompressors[decompressor](response)
- if new_response:
- return new_response, decompressor
- return response, ''
-
- def extract(self, response):
- return self.extract_winfo(response)[0]
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/defer.py b/scrapy/branches/cluster-refactor/scrapy/utils/defer.py
deleted file mode 100644
index 453d7320d..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/defer.py
+++ /dev/null
@@ -1,81 +0,0 @@
-"""
-Helper functions for dealing with Twisted deferreds
-"""
-
-from twisted.internet import defer, reactor
-from twisted.python import failure
-
-def defer_fail(_failure):
- """same as twsited.internet.defer.fail, but delay calling errback """
- d = defer.Deferred()
- reactor.callLater(0, d.errback, _failure)
- return d
-
-def defer_succeed(result):
- """same as twsited.internet.defer.succed, but delay calling callback"""
- d = defer.Deferred()
- reactor.callLater(0, d.callback, result)
- return d
-
-def defer_result(result):
- if isinstance(result, defer.Deferred):
- return result
- elif isinstance(result, failure.Failure):
- return defer_fail(result)
- else:
- return defer_succeed(result)
-
-def mustbe_deferred(f, *args, **kw):
- """same as twisted.internet.defer.maybeDeferred, but delay calling callback/errback"""
- try:
- result = f(*args, **kw)
- except:
- return defer_fail(failure.Failure())
- else:
- return defer_result(result)
-
-def chain_deferred(d1, d2):
- if callable(d2):
- d2 = lambda_deferred(d2)
-
- def _pause(_):
- d2.pause()
- reactor.callLater(0, d2.unpause)
- return _
-
- def _reclaim(_):
- return d2
-
- #d1.addBoth(_pause) ## needs more debugging before reenable it
- d1.chainDeferred(d2)
- d1.addBoth(_reclaim)
- return d1
-
-def lambda_deferred(func):
- deferred = defer.Deferred()
- def _success(res):
- d = func()
- d.callback(res)
- return d
- def _fail(res):
- d = func()
- d.errback(res)
- return d
- return deferred.addCallbacks(_success, _fail)
-
-def deferred_degenerate(generator, container=None, next_delay=0):
- generator = iter(generator or [])
- deferred = defer.Deferred()
- container = container or []
- def _next():
- try:
- container.append(generator.next())
- except StopIteration:
- reactor.callLater(0, deferred.callback, container)
- except:
- reactor.callLater(0, deferred.errback, failure.Failure())
- else:
- reactor.callLater(next_delay, _next)
- _next()
- return deferred
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/iterators.py b/scrapy/branches/cluster-refactor/scrapy/utils/iterators.py
deleted file mode 100644
index 5f989d0a3..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/iterators.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import csv
-
-from scrapy.http import Response
-from scrapy import log
-
-def csv_iter(response, delimiter=None, headers=None):
- if delimiter:
- csv_r = csv.reader(response.body.to_unicode().split('\n'), delimiter=delimiter)
- else:
- csv_r = csv.reader(response.body.to_unicode().split('\n'))
-
- if not headers:
- headers = csv_r.next()
-
- while True:
- node = csv_r.next()
-
- if len(node) != len(headers):
- log.msg("ignoring node %d (length: %d, should be: %d)" % (csv_r.line_num, len(node), len(headers)), log.WARNING)
- continue
-
- yield dict(zip(headers, node))
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/markup.py b/scrapy/branches/cluster-refactor/scrapy/utils/markup.py
deleted file mode 100644
index 5ec5b1719..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/markup.py
+++ /dev/null
@@ -1,100 +0,0 @@
-"""
-Functions for dealing with markup text
-"""
-
-import re
-import htmlentitydefs
-
-_ent_re = re.compile(r'&(#?)([^&;]+);')
-_tag_re = re.compile(r'<[a-zA-Z\/!].*?>', re.DOTALL)
-
-def remove_entities(text, keep=(), remove_illegal=True):
- """Remove entities from the given text.
-
- 'text' can be a unicode string or a regular string encoded as 'utf-8'
-
- If 'keep' is passed (with a list of entity names) those entities will
- be kept (they won't be removed).
-
- It supports both numeric (&#nnnn;) and named (&nbsp; &gt;) entities.
-
- If remove_illegal is True, entities that can't be converted are removed.
- If remove_illegal is False, entities that can't be converted are kept "as
- is". For more information see the tests.
-
- Always returns a unicode string (with the entities removed).
- """
-
- def convert_entity(m):
- if m.group(1) == '#':
- try:
- return unichr(int(m.group(2)))
- except ValueError:
- if remove_illegal:
- return u''
- else:
- return u'&#%s;' % m.group(2)
- try:
- if m.group(2) in keep:
- return '&%s;' % m.group(2)
- else:
- return unichr(htmlentitydefs.name2codepoint[m.group(2)])
- except KeyError:
- if remove_illegal:
- return u''
- else:
- return u'&%s;' % m.group(2)
-
- return _ent_re.sub(convert_entity, text.decode('utf-8'))
-
-def has_entities(text):
- return bool(_ent_re.search(text))
-
-def replace_tags(text, token=''):
- """Replace all markup tags found in the given text by the given token. By
- default token is a null string so it just remove all tags.
-
- 'text' can be a unicode string or a regular string encoded as 'utf-8'
-
- Always returns a unicode string.
- """
- return _tag_re.sub(token, text.decode('utf-8'))
-
-
-def remove_comments(text):
- """ Remove HTML Comments. """
- return re.sub('<!--.*?-->', u'', text.decode('utf-8'), re.DOTALL)
-
-def remove_tags(text, which_ones=()):
- """ Remove HTML Tags only.
-
- which_ones -- is a tuple of which tags we want to remove.
- if is empty remove all tags.
- """
- if len(which_ones) > 0:
- tags = [ '<%s>|<%s .*?>|</%s>' % (tag,tag,tag) for tag in which_ones ]
- reg_exp_remove_tags = '|'.join(tags)
- else:
- reg_exp_remove_tags = '<.*?>'
- re_tags = re.compile(reg_exp_remove_tags, re.DOTALL)
- return re_tags.sub(u'', text.decode('utf-8'))
-
-def remove_tags_with_content(text, which_ones=()):
- """ Remove tags and its content.
-
- which_ones -- is a tuple of which tags with its content we want to remove.
- if is empty do nothing.
- """
- tags = [ '<%s.*?</%s>' % (tag,tag) for tag in which_ones ]
- re_tags_remove = re.compile('|'.join(tags), re.DOTALL)
- return re_tags_remove.sub(u'', text.decode('utf-8'))
-
-def remove_escape_chars(text, which_ones=('\n','\t','\r')):
- """ Remove escape chars. Default : \\n, \\t, \\r
-
- which_ones -- is a tuple of which escape chars we want to remove.
- By default removes \n, \t, \r.
- """
- re_escape_chars = re.compile('[%s]' % ''.join(which_ones))
- return re_escape_chars.sub(u'', text.decode('utf-8'))
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/misc.py b/scrapy/branches/cluster-refactor/scrapy/utils/misc.py
deleted file mode 100644
index f3cc378f8..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/misc.py
+++ /dev/null
@@ -1,97 +0,0 @@
-"""
-Auxiliary functions which doesn't fit anywhere else
-"""
-import re
-
-from twisted.internet import defer
-
-from scrapy.core.exceptions import UsageError
-from scrapy.utils.python import flatten
-from scrapy.utils.markup import remove_entities
-from scrapy.utils.defer import defer_succeed
-
-def dict_updatedefault(D, E, **F):
- """
- updatedefault(D, E, **F) -> None.
-
- Update D from E and F: for k in E: D.setdefault(k, E[k])
- (if E has keys else: for (k, v) in E: D.setdefault(k, v))
- then: for k in F: D.setdefault(k, F[k])
- """
- for k in E:
- if isinstance(k, tuple):
- k, v = k
- else:
- v = E[k]
- D.setdefault(k, v)
-
- for k in F:
- D.setdefault(k, F[k])
-
-def memoize(cache, hash):
- def decorator(func):
- def wrapper(*args, **kwargs):
- key = hash(*args, **kwargs)
- if key in cache:
- return defer_succeed(cache[key])
-
- def _store(_):
- cache[key] = _
- return _
-
- result = func(*args, **kwargs)
- if isinstance(result, defer.Deferred):
- return result.addBoth(_store)
- cache[key] = result
- return result
- return wrapper
- return decorator
-
-def stats_getpath(dict_, path, default=None):
- for key in path.split('/'):
- if key in dict_:
- dict_ = dict_[key]
- else:
- return default
- return dict_
-
-def load_class(class_path):
- """Load a class given its absolute class path, and return it without
- instantiating it"""
- try:
- dot = class_path.rindex('.')
- except ValueError:
- raise UsageError, '%s isn\'t a module' % class_path
- module, classname = class_path[:dot], class_path[dot+1:]
- try:
- mod = __import__(module, {}, {}, [''])
- except ImportError, e:
- raise UsageError, 'Error importing %s: "%s"' % (module, e)
- try:
- cls = getattr(mod, classname)
- except AttributeError:
- raise UsageError, 'module "%s" does not define a "%s" class' % (module, classname)
-
- return cls
-
-def extract_regex(regex, text, encoding):
- """Extract a list of unicode strings from the given text/encoding using the following policies:
-
- * if the regex contains a named group called "extract" that will be returned
- * if the regex contains multiple numbered groups, all those will be returned (flattened)
- * if the regex doesn't contain any group the entire regex matching is returned
- """
-
- if isinstance(regex, basestring):
- regex = re.compile(regex)
-
- try:
- strings = [regex.search(text).group('extract')] # named group
- except:
- strings = regex.findall(text) # full regex or numbered groups
- strings = flatten(strings)
-
- if isinstance(text, unicode):
- return [remove_entities(s, keep=['lt', 'amp']) for s in strings]
- else:
- return [remove_entities(unicode(s, encoding), keep=['lt', 'amp']) for s in strings]
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/python.py b/scrapy/branches/cluster-refactor/scrapy/utils/python.py
deleted file mode 100644
index 23e08075a..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/python.py
+++ /dev/null
@@ -1,55 +0,0 @@
-"""
-This module contains essential stuff that should've come with Python itself ;)
-"""
-
-from sgmllib import SGMLParser
-
-class FixedSGMLParser(SGMLParser):
- """The SGMLParser that comes with Python has a bug in the convert_charref()
- method. This is the same class with the bug fixed"""
-
- def convert_charref(self, name):
- """This method fixes a bug in Python's SGMLParser."""
- try:
- n = int(name)
- except ValueError:
- return
- if not 0 <= n <= 127 : # ASCII ends at 127, not 255
- return
- return self.convert_codepoint(n)
-
-
-def flatten(x):
- """flatten(sequence) -> list
-
- Returns a single, flat list which contains all elements retrieved
- from the sequence and all recursively contained sub-sequences
- (iterables).
-
- Examples:
- >>> [1, 2, [3,4], (5,6)]
- [1, 2, [3, 4], (5, 6)]
- >>> flatten([[[1,2,3], (42,None)], [4,5], [6], 7, (8,9,10)])
- [1, 2, 3, 42, None, 4, 5, 6, 7, 8, 9, 10]"""
-
- result = []
- for el in x:
- if hasattr(el, "__iter__"):
- result.extend(flatten(el))
- else:
- result.append(el)
- return result
-
-
-def unique(list_):
- """efficient function to uniquify a list preserving item order"""
- seen = {}
- result = []
- for item in list_:
- if item in seen:
- continue
- seen[item] = 1
- result.append(item)
- return result
-
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/response.py b/scrapy/branches/cluster-refactor/scrapy/utils/response.py
deleted file mode 100644
index 63fa3f686..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/response.py
+++ /dev/null
@@ -1,15 +0,0 @@
-"""
-This module provides some useful functions for working with
-scrapy.http.Response objects
-"""
-
-from scrapy.xpath import XPathSelector
-
-def new_response_from_xpaths(response, xpaths):
- """Return a new response constructed by applying the given xpaths to the
- original response body
- """
- xs = XPathSelector(response)
- parts = [''.join([n for n in xs.x(x).extract()]) for x in xpaths]
- new_body = ''.join(parts)
- return response.replace(body=new_body)
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/url.py b/scrapy/branches/cluster-refactor/scrapy/utils/url.py
deleted file mode 100644
index 091827760..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/url.py
+++ /dev/null
@@ -1,147 +0,0 @@
-"""
-This module contains general purpose URL functions not found in the standard
-library.
-"""
-
-import re
-import urlparse
-import urllib
-import posixpath
-import cgi
-
-def url_is_from_any_domain(url, domains):
- """Return True if the url belongs to the given domain"""
- host = urlparse.urlparse(url).hostname
-
- if host:
- return any(((host == d) or (host.endswith('.%s' % d)) for d in domains))
- else:
- return False
-
-def url_is_from_spider(url, spider):
- """Return True if the url belongs to the given spider"""
- domains = [spider.domain_name] + spider.extra_domain_names
- return url_is_from_any_domain(url, domains)
-
-def urljoin_rfc(base, ref):
- """
- Fixed urlparse.urljoin version that handles
- relative query string as RFC states.
- """
- if ref.startswith('?'):
- fpart = urlparse.urlsplit(str(base))[2].rsplit('/', 1)[-1]
- ref = ''.join([fpart, ref])
- # convert ref to a string. This should already
- # be the case, however, many spiders do not convert.
- return urlparse.urljoin(base, str(ref))
-
-
-_reserved = ';/?:@&=+$|,#' # RFC 2396 (Generic Syntax)
-_unreserved_marks = "-_.!~*'()" #RFC 2396 sec 2.3
-_safe_chars = urllib.always_safe + '%' + _reserved + _unreserved_marks
-
-def safe_url_string(url, use_encoding='utf8'):
- """Convert a unicode (or utf8 string) object into a legal URL.
-
- Illegal characters are escaped (RFC-3986)
-
- It is safe to call this function multiple times. Do not pass this
- function strings in encodings other than utf8.
-
- The use_encoding argument is the encoding to use to determine the numerical
- values in the escaping. For urls on html pages, you should use the original
- encoding of that page.
- """
- s = url.encode(use_encoding)
- return urllib.quote(s, _safe_chars)
-
-
-_parent_dirs = re.compile(r'/?(\.\./)+')
-
-def safe_download_url(url):
- """ Make a url for download. This will call safe_url_string
- and then strip the fragment, if one exists. The path will
- be normalised.
-
- If the path is outside the document root, it will be changed
- to be within the document root.
- """
- safe_url = safe_url_string(url)
- scheme, netloc, path, query, _ = urlparse.urlsplit(safe_url)
- if path:
- path = _parent_dirs.sub('', posixpath.normpath(path))
- if url.endswith('/') and not path.endswith('/'):
- path += '/'
- else:
- path = '/'
- return urlparse.urlunsplit((scheme, netloc, path, query, ''))
-
-def is_url(text):
- return text.partition("://")[0] in ('file', 'http', 'https')
-
-def url_query_parameter(url, parameter, default=None, keep_blank_values=0):
- """Return the value of a url parameter, given the url and parameter name"""
- queryparams = cgi.parse_qs(urlparse.urlsplit(str(url))[3], keep_blank_values=keep_blank_values)
- return queryparams.get(parameter, [default])[0]
-
-def url_query_cleaner(url, parameterlist=(), sep='&', kvsep='='):
- """Clean url arguments leaving only those passed in the parameterlist"""
- try:
- base, query = url.split('?', 1)
- parameters = [pair.split(kvsep, 1) for pair in query.split(sep)]
- except:
- base = url
- query = ""
- parameters = []
-
- # unique parameters while keeping order
- unique = {}
- querylist = []
- for pair in parameters:
- k = pair[0]
- if not unique.get(k):
- querylist += [pair]
- unique[k] = 1
-
- query = sep.join([kvsep.join(pair) for pair in querylist if pair[0] in parameterlist])
- return '?'.join([base, query])
-
-def add_or_replace_parameter(url, name, new_value, sep='&'):
- """Add or remove a parameter to a given url"""
- def has_querystring(url):
- _, _, _, query, _ = urlparse.urlsplit(url)
- return bool(query)
-
- parameter = url_query_parameter(url, name, keep_blank_values=1)
- if parameter is None:
- if has_querystring(url):
- next_url = url + sep + name + '=' + new_value
- else:
- next_url = url + '?' + name + '=' + new_value
- else:
- next_url = url.replace(name+'='+parameter,
- name+'='+new_value)
- return next_url
-
-def canonicalize_url(url, keep_blank_values=False, keep_fragments=False):
- """Canonicalize url by applying the following procedures:
-
- - sort query arguments, first by key, then by value
- - percent encode paths and query arguments. non-ASCII characters are
- percent-encoded using UTF-8 (RFC-3986)
- - normalize all spaces (in query arguments) '+' (plus symbol)
- - normalize percent encodings case (%2f -> %2F)
- - remove query arguments with blank values (unless keep_blank_values is True)
- - remove fragments (unless keep_fragments is True)
-
- For examples see the tests in scrapy.tests.test_utils_url
- """
-
- parts = list(urlparse.urlparse(url))
- keyvals = cgi.parse_qsl(parts[4], keep_blank_values)
- keyvals.sort()
- parts[2] = urllib.quote(urllib.unquote(parts[2]))
- parts[4] = urllib.urlencode(keyvals)
- if not keep_fragments:
- parts[5] = ''
- return urlparse.urlunparse(parts)
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/xml.py b/scrapy/branches/cluster-refactor/scrapy/utils/xml.py
deleted file mode 100644
index acfa52363..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/utils/xml.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import re
-
-from scrapy.xpath import XmlXPathSelector
-from scrapy.http import Response
-
-def xpathselector_iternodes(obj, nodename):
- """Return a iterator of XPathSelector's over all nodes of a XML document,
- given tha name of the node to iterate. Useful for parsing XML feeds.
-
- obj can be:
- - a Response object
- - a unicode string
- - a string encoded as utf-8
- """
-
- assert isinstance(obj, (Response, basestring)), "obj must be Response or basestring, not %s" % type(obj).__name__
-
- if isinstance(obj, Response):
- text = obj.body.to_unicode()
- elif isinstance(obj, str):
- text = obj.decode('utf-8')
- else:
- text = obj
-
- r = re.compile(r"<%s[\s>].*?</%s>" % (nodename, nodename), re.DOTALL)
- for match in r.finditer(text):
- nodetext = match.group()
- yield XmlXPathSelector(text=nodetext).x('/' + nodename)[0]
diff --git a/scrapy/branches/cluster-refactor/scrapy/xpath/constructors.py b/scrapy/branches/cluster-refactor/scrapy/xpath/constructors.py
deleted file mode 100644
index e6ca7fdcc..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/xpath/constructors.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""
-This module provides functions for generating libxml2 documents (xmlDoc).
-
-Constructors must receive a Response object and return a xmlDoc object.
-"""
-
-import libxml2
-
-xml_parser_options = libxml2.XML_PARSE_RECOVER + \
- libxml2.XML_PARSE_NOERROR + \
- libxml2.XML_PARSE_NOWARNING
-
-html_parser_options = libxml2.HTML_PARSE_RECOVER + \
- libxml2.HTML_PARSE_NOERROR + \
- libxml2.HTML_PARSE_NOWARNING
-
-def xmlDoc_from_html(response):
- """Return libxml2 doc for HTMLs"""
- try:
- lxdoc = libxml2.htmlReadDoc(response.body.to_string('utf-8'), response.url, 'utf-8', html_parser_options)
- except TypeError: # libxml2 doesn't parse text with null bytes
- lxdoc = libxml2.htmlReadDoc(response.body.to_string('utf-8').replace("\x00", ""), response.url, 'utf-8', html_parser_options)
- return lxdoc
-
-def xmlDoc_from_xml(response):
- """Return libxml2 doc for XMLs"""
- try:
- lxdoc = libxml2.readDoc(response.body.to_string('utf-8'), response.url, 'utf-8', xml_parser_options)
- except TypeError: # libxml2 doesn't parse text with null bytes
- lxdoc = libxml2.readDoc(response.body.to_string('utf-8').replace("\x00", ""), response.url, 'utf-8', xml_parser_options)
- return lxdoc
diff --git a/scrapy/branches/cluster-refactor/scrapy/xpath/extension.py b/scrapy/branches/cluster-refactor/scrapy/xpath/extension.py
deleted file mode 100644
index 0642e0cd6..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/xpath/extension.py
+++ /dev/null
@@ -1,20 +0,0 @@
-"""
-The ResponseLibxml2 extension causes the Response objects to grow a new method
-("getlibxml2doc") which returns a (cached) libxml2 document of itself.
-"""
-
-from scrapy.http import Response
-from scrapy.xpath.document import Libxml2Document
-from scrapy.xpath.constructors import xmlDoc_from_html
-
-class ResponseLibxml2(object):
- def __init__(self):
- setattr(Response, 'getlibxml2doc', getlibxml2doc)
-
-def getlibxml2doc(response, constructor=xmlDoc_from_html):
- attr = '_lx2doc_%s' % constructor.__name__
- if not hasattr(response, attr):
- lx2doc = Libxml2Document(response, constructor=constructor)
- setattr(response, attr, lx2doc)
- return getattr(response, attr)
-
diff --git a/scrapy/branches/cluster-refactor/scrapy/xpath/selector.py b/scrapy/branches/cluster-refactor/scrapy/xpath/selector.py
deleted file mode 100644
index cb97f7da8..000000000
--- a/scrapy/branches/cluster-refactor/scrapy/xpath/selector.py
+++ /dev/null
@@ -1,133 +0,0 @@
-import libxml2
-
-from scrapy.http import Response
-from scrapy.xpath.extension import Libxml2Document
-from scrapy.xpath.constructors import xmlDoc_from_html, xmlDoc_from_xml
-from scrapy.utils.python import flatten
-from scrapy.utils.misc import extract_regex
-
-class XPathSelector(object):
- """The XPathSelector class provides a convenient way for selecting document
- parts using XPaths and regexs, with support for nested queries.
-
- Although this is not an abstract class, you usually instantiate one of its
- children:
-
- - XmlXPathSelector (for XML content)
- - HtmlXPathSelector (for HTML content)
- """
-
- def __init__(self, response=None, text=None, node=None, parent=None, expr=None, constructor=xmlDoc_from_html):
- if parent:
- self.doc = parent.doc
- self.xmlNode = node
- elif response:
- try:
- self.doc = response.getlibxml2doc(constructor=constructor) # try with cached version first
- except AttributeError:
- self.doc = Libxml2Document(response, constructor=constructor)
- self.xmlNode = self.doc.xmlDoc
- elif text:
- response = Response(domain=None, url=None, body=str(text))
- self.doc = Libxml2Document(response, constructor=constructor)
- self.xmlNode = self.doc.xmlDoc
- self.expr = expr
- self.response = response
-
- def x(self, xpath):
- """Perform the given XPath query on the current XPathSelector and
- return a XPathSelectorList of the result"""
- if hasattr(self.xmlNode, 'xpathEval'):
- self.doc.xpathContext.setContextNode(self.xmlNode)
- xpath_result = self.doc.xpathContext.xpathEval(xpath)
- cls = type(self)
- if hasattr(xpath_result, '__iter__'):
- return XPathSelectorList([cls(node=node, parent=self, expr=xpath, response=self.response)
- for node in xpath_result])
- else:
- return XPathSelectorList([cls(node=xpath_result, parent=self, expr=xpath, response=self.response)])
- else:
- return XPathSelectorList([])
-
- def re(self, regex):
- """Return a list of unicode strings by applying the regex over all
- current XPath selections, and flattening the results"""
- return extract_regex(regex, self.extract(), 'utf-8')
-
- def extract(self):
- """Return a unicode string of the content referenced by the XPathSelector"""
- if isinstance(self.xmlNode, basestring):
- text = unicode(self.xmlNode, 'utf-8', errors='ignore')
- elif hasattr(self.xmlNode, 'serialize'):
- if isinstance(self.xmlNode, libxml2.xmlDoc):
- data = self.xmlNode.getRootElement().serialize('utf-8')
- text = unicode(data, 'utf-8', errors='ignore') if data else u''
- elif isinstance(self.xmlNode, libxml2.xmlAttr):
- # serialization doesn't work sometimes for xmlAttr types
- text = unicode(self.xmlNode.content, errors='ignore')
- else:
- data = self.xmlNode.serialize('utf-8')
- text = unicode(data, 'utf-8', errors='ignore') if data else u''
- else:
- try:
- text = unicode(self.xmlNode, errors='ignore')
- except TypeError: # catched when self.xmlNode is a float - see tests
- text = unicode(self.xmlNode)
- return text
-
- def extract_unquoted(self):
- """Get unescaped contents from the text node (no entities, no CDATA)"""
- if self.x('self::text()'):
- return unicode(self.xmlNode.getContent(), errors='ignore')
- else:
- return u''
-
- def register_namespace(self, prefix, uri):
- """Register namespace so that it can be used in XPath queries"""
- self.doc.xpathContext.xpathRegisterNs(prefix, uri)
-
- def __nonzero__(self):
- return bool(self.extract())
-
- def __str__(self):
- return "<%s (%s) xpath=%s>" % (type(self).__name__, getattr(self.xmlNode, 'name', type(self.xmlNode).__name__), self.expr)
-
- __repr__ = __str__
-
-
-class XPathSelectorList(list):
- """List of XPathSelector objects"""
-
- def __getslice__(self, i, j):
- return XPathSelectorList(list.__getslice__(self, i, j))
-
- def x(self, xpath):
- """Perform the given XPath query on each XPathSelector of the list and
- return a new (flattened) XPathSelectorList of the results"""
- return XPathSelectorList(flatten([x.x(xpath) for x in self]))
-
- def re(self, regex):
- """Perform the re() method on each XPathSelector of the list, and
- return the result as a flattened list of unicode strings"""
- return flatten([x.re(regex) for x in self])
-
- def extract(self):
- """Return a list of unicode strings with the content referenced by each
- XPathSelector of the list"""
- return [x.extract() if isinstance(x, XPathSelector) else x for x in self]
-
- def extract_unquoted(self):
- return [x.extract_unquoted() if isinstance(x, XPathSelector) else x for x in self]
-
-
-class XmlXPathSelector(XPathSelector):
- """XPathSelector for XML content"""
- def __init__(self, *args, **kwargs):
- kwargs['constructor'] = xmlDoc_from_xml
- XPathSelector.__init__(self, *args, **kwargs)
-
-class HtmlXPathSelector(XPathSelector):
- """XPathSelector for HTML content"""
- def __init__(self, *args, **kwargs):
- kwargs['constructor'] = xmlDoc_from_html
- XPathSelector.__init__(self, *args, **kwargs)
diff --git a/scrapy/branches/cluster-refactor/setup.cfg b/scrapy/branches/cluster-refactor/setup.cfg
deleted file mode 100644
index 2b1e9475f..000000000
--- a/scrapy/branches/cluster-refactor/setup.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-[bdist_rpm]
-release = 1
-install-script = scripts/rpm-install.sh
-
-[install]
-optimize = 1
-
-[aliases]
-rpm = bdist_rpm --binary-only clean -a
diff --git a/scrapy/branches/cluster-refactor/setup.py b/scrapy/branches/cluster-refactor/setup.py
deleted file mode 100644
index da54c4a35..000000000
--- a/scrapy/branches/cluster-refactor/setup.py
+++ /dev/null
@@ -1,26 +0,0 @@
-from setuptools import setup, find_packages
-import os, os.path, glob
-
-def findfiles(pattern, base='.'):
- matches = []
- for root, _, _ in os.walk(base):
- matches.extend(glob.glob(os.path.join(root, pattern)))
- return matches
-
-
-setup(
- name = 'scrapy',
- version = '0.8',
- description = '',
- long_description = '',
- author = '',
- author_email = '',
- license = '',
- url = 'http://scrapy.org',
-
- packages = find_packages(),
- package_data = {
- 'scrapy': ['templates/*.tmpl'],
- },
- scripts = ['scrapy/bin/scrapy-admin.py'],
-)
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/__init__.py b/scrapy/command/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/command/__init__.py
rename to scrapy/command/__init__.py
diff --git a/scrapy/trunk/scrapy/command/cmdline.py b/scrapy/command/cmdline.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/cmdline.py
rename to scrapy/command/cmdline.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/__init__.py b/scrapy/command/commands/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/__init__.py
rename to scrapy/command/commands/__init__.py
diff --git a/scrapy/trunk/scrapy/command/commands/crawl.py b/scrapy/command/commands/crawl.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/commands/crawl.py
rename to scrapy/command/commands/crawl.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/download.py b/scrapy/command/commands/download.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/command/commands/download.py
rename to scrapy/command/commands/download.py
diff --git a/scrapy/trunk/scrapy/command/commands/genspider.py b/scrapy/command/commands/genspider.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/commands/genspider.py
rename to scrapy/command/commands/genspider.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/help.py b/scrapy/command/commands/help.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/command/commands/help.py
rename to scrapy/command/commands/help.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/list.py b/scrapy/command/commands/list.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/command/commands/list.py
rename to scrapy/command/commands/list.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/log.py b/scrapy/command/commands/log.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/command/commands/log.py
rename to scrapy/command/commands/log.py
diff --git a/scrapy/trunk/scrapy/command/commands/parse.py b/scrapy/command/commands/parse.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/commands/parse.py
rename to scrapy/command/commands/parse.py
diff --git a/scrapy/trunk/scrapy/command/commands/shell.py b/scrapy/command/commands/shell.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/commands/shell.py
rename to scrapy/command/commands/shell.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/command/commands/start.py b/scrapy/command/commands/start.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/command/commands/start.py
rename to scrapy/command/commands/start.py
diff --git a/scrapy/trunk/scrapy/command/commands/stats.py b/scrapy/command/commands/stats.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/commands/stats.py
rename to scrapy/command/commands/stats.py
diff --git a/scrapy/trunk/scrapy/command/models.py b/scrapy/command/models.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/models.py
rename to scrapy/command/models.py
diff --git a/scrapy/trunk/scrapy/conf/__init__.py b/scrapy/conf/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/conf/__init__.py
rename to scrapy/conf/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/__init__.py b/scrapy/conf/commands/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/__init__.py
rename to scrapy/conf/commands/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/crawl.py b/scrapy/conf/commands/crawl.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/crawl.py
rename to scrapy/conf/commands/crawl.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/help.py b/scrapy/conf/commands/help.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/help.py
rename to scrapy/conf/commands/help.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/list.py b/scrapy/conf/commands/list.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/list.py
rename to scrapy/conf/commands/list.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/log.py b/scrapy/conf/commands/log.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/log.py
rename to scrapy/conf/commands/log.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/scrape.py b/scrapy/conf/commands/scrape.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/scrape.py
rename to scrapy/conf/commands/scrape.py
diff --git a/scrapy/trunk/scrapy/conf/commands/shell.py b/scrapy/conf/commands/shell.py
similarity index 100%
rename from scrapy/trunk/scrapy/conf/commands/shell.py
rename to scrapy/conf/commands/shell.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/stats.py b/scrapy/conf/commands/stats.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/stats.py
rename to scrapy/conf/commands/stats.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/conf/commands/test.py b/scrapy/conf/commands/test.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/conf/commands/test.py
rename to scrapy/conf/commands/test.py
diff --git a/scrapy/trunk/scrapy/conf/default_settings.py b/scrapy/conf/default_settings.py
similarity index 100%
rename from scrapy/trunk/scrapy/conf/default_settings.py
rename to scrapy/conf/default_settings.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/__init__.py b/scrapy/contrib/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/pipeline/__init__.py
rename to scrapy/contrib/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/aws.py b/scrapy/contrib/aws.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/aws.py
rename to scrapy/contrib/aws.py
diff --git a/scrapy/trunk/scrapy/contrib/closedomain.py b/scrapy/contrib/closedomain.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/closedomain.py
rename to scrapy/contrib/closedomain.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/__init__.py b/scrapy/contrib/cluster/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/__init__.py
rename to scrapy/contrib/cluster/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/response/__init__.py b/scrapy/contrib/cluster/crawler/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/response/__init__.py
rename to scrapy/contrib/cluster/crawler/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/crawler/manager.py b/scrapy/contrib/cluster/crawler/manager.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/crawler/manager.py
rename to scrapy/contrib/cluster/crawler/manager.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/hooks/__init__.py b/scrapy/contrib/cluster/hooks/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/hooks/__init__.py
rename to scrapy/contrib/cluster/hooks/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/hooks/svn.py b/scrapy/contrib/cluster/hooks/svn.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/hooks/svn.py
rename to scrapy/contrib/cluster/hooks/svn.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spider/__init__.py b/scrapy/contrib/cluster/master/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/spider/__init__.py
rename to scrapy/contrib/cluster/master/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/master/manager.py b/scrapy/contrib/cluster/master/manager.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/master/manager.py
rename to scrapy/contrib/cluster/master/manager.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/master/web.py b/scrapy/contrib/cluster/master/web.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/master/web.py
rename to scrapy/contrib/cluster/master/web.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/master/ws_api.txt b/scrapy/contrib/cluster/master/ws_api.txt
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/master/ws_api.txt
rename to scrapy/contrib/cluster/master/ws_api.txt
diff --git a/scrapy/trunk/scrapy/contrib/cluster/tools/scrapy-cluster-ctl.py b/scrapy/contrib/cluster/tools/scrapy-cluster-ctl.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/tools/scrapy-cluster-ctl.py
rename to scrapy/contrib/cluster/tools/scrapy-cluster-ctl.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/tools/test-worker.py b/scrapy/contrib/cluster/tools/test-worker.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/tools/test-worker.py
rename to scrapy/contrib/cluster/tools/test-worker.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/__init__.py b/scrapy/contrib/cluster/worker/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/spidermiddleware/__init__.py
rename to scrapy/contrib/cluster/worker/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/worker/manager.py b/scrapy/contrib/cluster/worker/manager.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/worker/manager.py
rename to scrapy/contrib/cluster/worker/manager.py
diff --git a/scrapy/trunk/scrapy/contrib/codecs/__init__.py b/scrapy/contrib/codecs/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/codecs/__init__.py
rename to scrapy/contrib/codecs/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/codecs/x_mac_roman.py b/scrapy/contrib/codecs/x_mac_roman.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/codecs/x_mac_roman.py
rename to scrapy/contrib/codecs/x_mac_roman.py
diff --git a/scrapy/trunk/scrapy/contrib/debug.py b/scrapy/contrib/debug.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/debug.py
rename to scrapy/contrib/debug.py
diff --git a/scrapy/trunk/scrapy/contrib/delayedclosedomain.py b/scrapy/contrib/delayedclosedomain.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/delayedclosedomain.py
rename to scrapy/contrib/delayedclosedomain.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/web/__init__.py b/scrapy/contrib/downloadermiddleware/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/web/__init__.py
rename to scrapy/contrib/downloadermiddleware/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/cache.py b/scrapy/contrib/downloadermiddleware/cache.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/cache.py
rename to scrapy/contrib/downloadermiddleware/cache.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/common.py b/scrapy/contrib/downloadermiddleware/common.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/common.py
rename to scrapy/contrib/downloadermiddleware/common.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/cookies.py b/scrapy/contrib/downloadermiddleware/cookies.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/cookies.py
rename to scrapy/contrib/downloadermiddleware/cookies.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/debug.py b/scrapy/contrib/downloadermiddleware/debug.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/debug.py
rename to scrapy/contrib/downloadermiddleware/debug.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/errorpages.py b/scrapy/contrib/downloadermiddleware/errorpages.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/downloadermiddleware/errorpages.py
rename to scrapy/contrib/downloadermiddleware/errorpages.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/httpauth.py b/scrapy/contrib/downloadermiddleware/httpauth.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/httpauth.py
rename to scrapy/contrib/downloadermiddleware/httpauth.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/httpcompression.py b/scrapy/contrib/downloadermiddleware/httpcompression.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/httpcompression.py
rename to scrapy/contrib/downloadermiddleware/httpcompression.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/redirect.py b/scrapy/contrib/downloadermiddleware/redirect.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/redirect.py
rename to scrapy/contrib/downloadermiddleware/redirect.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/retry.py b/scrapy/contrib/downloadermiddleware/retry.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/retry.py
rename to scrapy/contrib/downloadermiddleware/retry.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/robotstxt.py b/scrapy/contrib/downloadermiddleware/robotstxt.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/robotstxt.py
rename to scrapy/contrib/downloadermiddleware/robotstxt.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/stats.py b/scrapy/contrib/downloadermiddleware/stats.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/stats.py
rename to scrapy/contrib/downloadermiddleware/stats.py
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/useragent.py b/scrapy/contrib/downloadermiddleware/useragent.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/downloadermiddleware/useragent.py
rename to scrapy/contrib/downloadermiddleware/useragent.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/groupsettings.py b/scrapy/contrib/groupsettings.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/groupsettings.py
rename to scrapy/contrib/groupsettings.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/item/__init__.py b/scrapy/contrib/item/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/item/__init__.py
rename to scrapy/contrib/item/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/item/models.py b/scrapy/contrib/item/models.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/item/models.py
rename to scrapy/contrib/item/models.py
diff --git a/scrapy/trunk/scrapy/contrib/itemsampler.py b/scrapy/contrib/itemsampler.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/itemsampler.py
rename to scrapy/contrib/itemsampler.py
diff --git a/scrapy/trunk/scrapy/contrib/link_extractors.py b/scrapy/contrib/link_extractors.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/link_extractors.py
rename to scrapy/contrib/link_extractors.py
diff --git a/scrapy/trunk/scrapy/contrib/memdebug.py b/scrapy/contrib/memdebug.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/memdebug.py
rename to scrapy/contrib/memdebug.py
diff --git a/scrapy/trunk/scrapy/contrib/memusage.py b/scrapy/contrib/memusage.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/memusage.py
rename to scrapy/contrib/memusage.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/__init__.py b/scrapy/contrib/pipeline/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/__init__.py
rename to scrapy/contrib/pipeline/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/pipeline/images.py b/scrapy/contrib/pipeline/images.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/pipeline/images.py
rename to scrapy/contrib/pipeline/images.py
diff --git a/scrapy/trunk/scrapy/contrib/pipeline/media.py b/scrapy/contrib/pipeline/media.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/pipeline/media.py
rename to scrapy/contrib/pipeline/media.py
diff --git a/scrapy/trunk/scrapy/contrib/pipeline/s3images.py b/scrapy/contrib/pipeline/s3images.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/pipeline/s3images.py
rename to scrapy/contrib/pipeline/s3images.py
diff --git a/scrapy/trunk/scrapy/contrib/pipeline/show.py b/scrapy/contrib/pipeline/show.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/pipeline/show.py
rename to scrapy/contrib/pipeline/show.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/prioritizers.py b/scrapy/contrib/prioritizers.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/prioritizers.py
rename to scrapy/contrib/prioritizers.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/management/__init__.py b/scrapy/contrib/response/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/management/__init__.py
rename to scrapy/contrib/response/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/response/soup.py b/scrapy/contrib/response/soup.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/response/soup.py
rename to scrapy/contrib/response/soup.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/patches/__init__.py b/scrapy/contrib/schedulermiddleware/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/patches/__init__.py
rename to scrapy/contrib/schedulermiddleware/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/schedulermiddleware/duplicatesfilter.py b/scrapy/contrib/schedulermiddleware/duplicatesfilter.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/schedulermiddleware/duplicatesfilter.py
rename to scrapy/contrib/schedulermiddleware/duplicatesfilter.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/store/__init__.py b/scrapy/contrib/spider/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/store/__init__.py
rename to scrapy/contrib/spider/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spider/profiler.py b/scrapy/contrib/spider/profiler.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/spider/profiler.py
rename to scrapy/contrib/spider/profiler.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/spider/reloader.py b/scrapy/contrib/spider/reloader.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/spider/reloader.py
rename to scrapy/contrib/spider/reloader.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_spiders/__init__.py b/scrapy/contrib/spidermiddleware/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/test_spiders/__init__.py
rename to scrapy/contrib/spidermiddleware/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/depth.py b/scrapy/contrib/spidermiddleware/depth.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/depth.py
rename to scrapy/contrib/spidermiddleware/depth.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/duplicatesfilter.py b/scrapy/contrib/spidermiddleware/duplicatesfilter.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/duplicatesfilter.py
rename to scrapy/contrib/spidermiddleware/duplicatesfilter.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/limit.py b/scrapy/contrib/spidermiddleware/limit.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/limit.py
rename to scrapy/contrib/spidermiddleware/limit.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/offsite.py b/scrapy/contrib/spidermiddleware/offsite.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/offsite.py
rename to scrapy/contrib/spidermiddleware/offsite.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/referer.py b/scrapy/contrib/spidermiddleware/referer.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/referer.py
rename to scrapy/contrib/spidermiddleware/referer.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/restrict.py b/scrapy/contrib/spidermiddleware/restrict.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/restrict.py
rename to scrapy/contrib/spidermiddleware/restrict.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/urlfilter.py b/scrapy/contrib/spidermiddleware/urlfilter.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/urlfilter.py
rename to scrapy/contrib/spidermiddleware/urlfilter.py
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/urllength.py b/scrapy/contrib/spidermiddleware/urllength.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spidermiddleware/urllength.py
rename to scrapy/contrib/spidermiddleware/urllength.py
diff --git a/scrapy/trunk/scrapy/contrib/spiders/__init__.py b/scrapy/contrib/spiders/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spiders/__init__.py
rename to scrapy/contrib/spiders/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib/spiders/crawl.py b/scrapy/contrib/spiders/crawl.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spiders/crawl.py
rename to scrapy/contrib/spiders/crawl.py
diff --git a/scrapy/trunk/scrapy/contrib/spiders/feed.py b/scrapy/contrib/spiders/feed.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spiders/feed.py
rename to scrapy/contrib/spiders/feed.py
diff --git a/scrapy/trunk/scrapy/contrib/spiders/generic.py b/scrapy/contrib/spiders/generic.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/spiders/generic.py
rename to scrapy/contrib/spiders/generic.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/__init__.py b/scrapy/contrib/web/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/utils/__init__.py
rename to scrapy/contrib/web/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/web/http.py b/scrapy/contrib/web/http.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/web/http.py
rename to scrapy/contrib/web/http.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/web/json.py b/scrapy/contrib/web/json.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/web/json.py
rename to scrapy/contrib/web/json.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/web/service.py b/scrapy/contrib/web/service.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/web/service.py
rename to scrapy/contrib/web/service.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/web/site.py b/scrapy/contrib/web/site.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/web/site.py
rename to scrapy/contrib/web/site.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/web/stats.py b/scrapy/contrib/web/stats.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/web/stats.py
rename to scrapy/contrib/web/stats.py
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/__init__.py b/scrapy/contrib/webconsole/__init__.py
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/__init__.py
rename to scrapy/contrib/webconsole/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/enginestatus.py b/scrapy/contrib/webconsole/enginestatus.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/enginestatus.py
rename to scrapy/contrib/webconsole/enginestatus.py
diff --git a/scrapy/trunk/scrapy/contrib/webconsole/livestats.py b/scrapy/contrib/webconsole/livestats.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/webconsole/livestats.py
rename to scrapy/contrib/webconsole/livestats.py
diff --git a/scrapy/trunk/scrapy/contrib/webconsole/scheduler.py b/scrapy/contrib/webconsole/scheduler.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/webconsole/scheduler.py
rename to scrapy/contrib/webconsole/scheduler.py
diff --git a/scrapy/trunk/scrapy/contrib/webconsole/spiderctl.py b/scrapy/contrib/webconsole/spiderctl.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/webconsole/spiderctl.py
rename to scrapy/contrib/webconsole/spiderctl.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/spiderstats.py b/scrapy/contrib/webconsole/spiderstats.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/spiderstats.py
rename to scrapy/contrib/webconsole/spiderstats.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/stats.py b/scrapy/contrib/webconsole/stats.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/webconsole/stats.py
rename to scrapy/contrib/webconsole/stats.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/__init__.py b/scrapy/contrib_exp/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/__init__.py
rename to scrapy/contrib_exp/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/adaptors/__init__.py b/scrapy/contrib_exp/adaptors/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/adaptors/__init__.py
rename to scrapy/contrib_exp/adaptors/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/adaptors/date.py b/scrapy/contrib_exp/adaptors/date.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/adaptors/date.py
rename to scrapy/contrib_exp/adaptors/date.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/adaptors/extraction.py b/scrapy/contrib_exp/adaptors/extraction.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/adaptors/extraction.py
rename to scrapy/contrib_exp/adaptors/extraction.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/adaptors/markup.py b/scrapy/contrib_exp/adaptors/markup.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/adaptors/markup.py
rename to scrapy/contrib_exp/adaptors/markup.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/adaptors/misc.py b/scrapy/contrib_exp/adaptors/misc.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/adaptors/misc.py
rename to scrapy/contrib_exp/adaptors/misc.py
diff --git a/scrapy/trunk/examples/experimental/googledir/googledir/spiders/__init__.py b/scrapy/contrib_exp/downloadermiddleware/__init__.py
similarity index 100%
rename from scrapy/trunk/examples/experimental/googledir/googledir/spiders/__init__.py
rename to scrapy/contrib_exp/downloadermiddleware/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/downloadermiddleware/decompression.py b/scrapy/contrib_exp/downloadermiddleware/decompression.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/downloadermiddleware/decompression.py
rename to scrapy/contrib_exp/downloadermiddleware/decompression.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/history/__init__.py b/scrapy/contrib_exp/history/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/history/__init__.py
rename to scrapy/contrib_exp/history/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/history/history.py b/scrapy/contrib_exp/history/history.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/history/history.py
rename to scrapy/contrib_exp/history/history.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/history/middleware.py b/scrapy/contrib_exp/history/middleware.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/history/middleware.py
rename to scrapy/contrib_exp/history/middleware.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/history/scheduler.py b/scrapy/contrib_exp/history/scheduler.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/history/scheduler.py
rename to scrapy/contrib_exp/history/scheduler.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/contrib/history/store.py b/scrapy/contrib_exp/history/store.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/contrib/history/store.py
rename to scrapy/contrib_exp/history/store.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/link/__init__.py b/scrapy/contrib_exp/link/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/link/__init__.py
rename to scrapy/contrib_exp/link/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/newitem/__init__.py b/scrapy/contrib_exp/newitem/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/newitem/__init__.py
rename to scrapy/contrib_exp/newitem/__init__.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/newitem/adaptors.py b/scrapy/contrib_exp/newitem/adaptors.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/newitem/adaptors.py
rename to scrapy/contrib_exp/newitem/adaptors.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/newitem/fields.py b/scrapy/contrib_exp/newitem/fields.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/newitem/fields.py
rename to scrapy/contrib_exp/newitem/fields.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/newitem/models.py b/scrapy/contrib_exp/newitem/models.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/newitem/models.py
rename to scrapy/contrib_exp/newitem/models.py
diff --git a/scrapy/trunk/scrapy/contrib_exp/pipeline/shoveitem.py b/scrapy/contrib_exp/pipeline/shoveitem.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib_exp/pipeline/shoveitem.py
rename to scrapy/contrib_exp/pipeline/shoveitem.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/__init__.py b/scrapy/core/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/core/__init__.py
rename to scrapy/core/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/downloader/__init__.py b/scrapy/core/downloader/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/core/downloader/__init__.py
rename to scrapy/core/downloader/__init__.py
diff --git a/scrapy/trunk/scrapy/core/downloader/dnscache.py b/scrapy/core/downloader/dnscache.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/downloader/dnscache.py
rename to scrapy/core/downloader/dnscache.py
diff --git a/scrapy/trunk/scrapy/core/downloader/handlers.py b/scrapy/core/downloader/handlers.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/downloader/handlers.py
rename to scrapy/core/downloader/handlers.py
diff --git a/scrapy/trunk/scrapy/core/downloader/manager.py b/scrapy/core/downloader/manager.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/downloader/manager.py
rename to scrapy/core/downloader/manager.py
diff --git a/scrapy/trunk/scrapy/core/downloader/middleware.py b/scrapy/core/downloader/middleware.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/downloader/middleware.py
rename to scrapy/core/downloader/middleware.py
diff --git a/scrapy/trunk/scrapy/core/downloader/responsetypes/__init__.py b/scrapy/core/downloader/responsetypes/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/downloader/responsetypes/__init__.py
rename to scrapy/core/downloader/responsetypes/__init__.py
diff --git a/scrapy/trunk/scrapy/core/downloader/responsetypes/mime.types b/scrapy/core/downloader/responsetypes/mime.types
similarity index 100%
rename from scrapy/trunk/scrapy/core/downloader/responsetypes/mime.types
rename to scrapy/core/downloader/responsetypes/mime.types
diff --git a/scrapy/trunk/scrapy/core/downloader/webclient.py b/scrapy/core/downloader/webclient.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/downloader/webclient.py
rename to scrapy/core/downloader/webclient.py
diff --git a/scrapy/trunk/scrapy/core/engine.py b/scrapy/core/engine.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/engine.py
rename to scrapy/core/engine.py
diff --git a/scrapy/trunk/scrapy/core/exceptions.py b/scrapy/core/exceptions.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/exceptions.py
rename to scrapy/core/exceptions.py
diff --git a/scrapy/trunk/scrapy/core/manager.py b/scrapy/core/manager.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/manager.py
rename to scrapy/core/manager.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/prioritizers.py b/scrapy/core/prioritizers.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/core/prioritizers.py
rename to scrapy/core/prioritizers.py
diff --git a/scrapy/trunk/scrapy/core/scheduler/__init__.py b/scrapy/core/scheduler/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/scheduler/__init__.py
rename to scrapy/core/scheduler/__init__.py
diff --git a/scrapy/trunk/scrapy/core/scheduler/middleware.py b/scrapy/core/scheduler/middleware.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/scheduler/middleware.py
rename to scrapy/core/scheduler/middleware.py
diff --git a/scrapy/trunk/scrapy/core/scheduler/schedulers.py b/scrapy/core/scheduler/schedulers.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/scheduler/schedulers.py
rename to scrapy/core/scheduler/schedulers.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/core/scheduler/store.py b/scrapy/core/scheduler/store.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/core/scheduler/store.py
rename to scrapy/core/scheduler/store.py
diff --git a/scrapy/trunk/scrapy/core/signals.py b/scrapy/core/signals.py
similarity index 100%
rename from scrapy/trunk/scrapy/core/signals.py
rename to scrapy/core/signals.py
diff --git a/scrapy/trunk/scrapy/dupefilter/__init__.py b/scrapy/dupefilter/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/dupefilter/__init__.py
rename to scrapy/dupefilter/__init__.py
diff --git a/scrapy/trunk/scrapy/extension/__init__.py b/scrapy/extension/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/extension/__init__.py
rename to scrapy/extension/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/fetcher/__init__.py b/scrapy/fetcher/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/fetcher/__init__.py
rename to scrapy/fetcher/__init__.py
diff --git a/scrapy/trunk/scrapy/http/__init__.py b/scrapy/http/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/__init__.py
rename to scrapy/http/__init__.py
diff --git a/scrapy/trunk/scrapy/http/cookies.py b/scrapy/http/cookies.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/cookies.py
rename to scrapy/http/cookies.py
diff --git a/scrapy/trunk/scrapy/http/headers.py b/scrapy/http/headers.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/headers.py
rename to scrapy/http/headers.py
diff --git a/scrapy/trunk/scrapy/http/request/__init__.py b/scrapy/http/request/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/request/__init__.py
rename to scrapy/http/request/__init__.py
diff --git a/scrapy/trunk/scrapy/http/request/form.py b/scrapy/http/request/form.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/request/form.py
rename to scrapy/http/request/form.py
diff --git a/scrapy/trunk/scrapy/http/request/rpc.py b/scrapy/http/request/rpc.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/request/rpc.py
rename to scrapy/http/request/rpc.py
diff --git a/scrapy/trunk/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/response/__init__.py
rename to scrapy/http/response/__init__.py
diff --git a/scrapy/trunk/scrapy/http/response/html.py b/scrapy/http/response/html.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/response/html.py
rename to scrapy/http/response/html.py
diff --git a/scrapy/trunk/scrapy/http/response/text.py b/scrapy/http/response/text.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/response/text.py
rename to scrapy/http/response/text.py
diff --git a/scrapy/trunk/scrapy/http/response/xml.py b/scrapy/http/response/xml.py
similarity index 100%
rename from scrapy/trunk/scrapy/http/response/xml.py
rename to scrapy/http/response/xml.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/http/url.py b/scrapy/http/url.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/http/url.py
rename to scrapy/http/url.py
diff --git a/scrapy/trunk/scrapy/item/__init__.py b/scrapy/item/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/item/__init__.py
rename to scrapy/item/__init__.py
diff --git a/scrapy/trunk/scrapy/item/adaptors.py b/scrapy/item/adaptors.py
similarity index 100%
rename from scrapy/trunk/scrapy/item/adaptors.py
rename to scrapy/item/adaptors.py
diff --git a/scrapy/trunk/scrapy/item/models.py b/scrapy/item/models.py
similarity index 100%
rename from scrapy/trunk/scrapy/item/models.py
rename to scrapy/item/models.py
diff --git a/scrapy/trunk/scrapy/item/pipeline.py b/scrapy/item/pipeline.py
similarity index 100%
rename from scrapy/trunk/scrapy/item/pipeline.py
rename to scrapy/item/pipeline.py
diff --git a/scrapy/trunk/scrapy/link/__init__.py b/scrapy/link/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/link/__init__.py
rename to scrapy/link/__init__.py
diff --git a/scrapy/trunk/scrapy/link/extractors.py b/scrapy/link/extractors.py
similarity index 100%
rename from scrapy/trunk/scrapy/link/extractors.py
rename to scrapy/link/extractors.py
diff --git a/scrapy/trunk/scrapy/log/__init__.py b/scrapy/log/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/log/__init__.py
rename to scrapy/log/__init__.py
diff --git a/scrapy/trunk/scrapy/mail/__init__.py b/scrapy/mail/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/mail/__init__.py
rename to scrapy/mail/__init__.py
diff --git a/scrapy/trunk/examples/googledir/googledir/__init__.py b/scrapy/management/__init__.py
similarity index 100%
rename from scrapy/trunk/examples/googledir/googledir/__init__.py
rename to scrapy/management/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/management/telnet.py b/scrapy/management/telnet.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/management/telnet.py
rename to scrapy/management/telnet.py
diff --git a/scrapy/trunk/scrapy/management/web.py b/scrapy/management/web.py
similarity index 100%
rename from scrapy/trunk/scrapy/management/web.py
rename to scrapy/management/web.py
diff --git a/scrapy/trunk/scrapy/command/commands/__init__.py b/scrapy/patches/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/command/commands/__init__.py
rename to scrapy/patches/__init__.py
diff --git a/scrapy/trunk/scrapy/patches/monkeypatches.py b/scrapy/patches/monkeypatches.py
similarity index 100%
rename from scrapy/trunk/scrapy/patches/monkeypatches.py
rename to scrapy/patches/monkeypatches.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/spider/__init__.py b/scrapy/spider/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/spider/__init__.py
rename to scrapy/spider/__init__.py
diff --git a/scrapy/trunk/scrapy/spider/manager.py b/scrapy/spider/manager.py
similarity index 100%
rename from scrapy/trunk/scrapy/spider/manager.py
rename to scrapy/spider/manager.py
diff --git a/scrapy/trunk/scrapy/spider/middleware.py b/scrapy/spider/middleware.py
similarity index 100%
rename from scrapy/trunk/scrapy/spider/middleware.py
rename to scrapy/spider/middleware.py
diff --git a/scrapy/trunk/scrapy/spider/models.py b/scrapy/spider/models.py
similarity index 100%
rename from scrapy/trunk/scrapy/spider/models.py
rename to scrapy/spider/models.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/stats/__init__.py b/scrapy/stats/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/stats/__init__.py
rename to scrapy/stats/__init__.py
diff --git a/scrapy/trunk/scrapy/stats/corestats.py b/scrapy/stats/corestats.py
similarity index 100%
rename from scrapy/trunk/scrapy/stats/corestats.py
rename to scrapy/stats/corestats.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/stats/statscollector.py b/scrapy/stats/statscollector.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/stats/statscollector.py
rename to scrapy/stats/statscollector.py
diff --git a/scrapy/trunk/scrapy/conf/commands/__init__.py b/scrapy/store/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/conf/commands/__init__.py
rename to scrapy/store/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/store/db.py b/scrapy/store/db.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/store/db.py
rename to scrapy/store/db.py
diff --git a/scrapy/trunk/scrapy/contrib/__init__.py b/scrapy/templates/project/module/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/__init__.py
rename to scrapy/templates/project/module/__init__.py
diff --git a/scrapy/trunk/scrapy/templates/project/module/items.py.tmpl b/scrapy/templates/project/module/items.py.tmpl
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/module/items.py.tmpl
rename to scrapy/templates/project/module/items.py.tmpl
diff --git a/scrapy/trunk/scrapy/templates/project/module/pipelines.py.tmpl b/scrapy/templates/project/module/pipelines.py.tmpl
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/module/pipelines.py.tmpl
rename to scrapy/templates/project/module/pipelines.py.tmpl
diff --git a/scrapy/trunk/scrapy/templates/project/module/settings.py.tmpl b/scrapy/templates/project/module/settings.py.tmpl
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/module/settings.py.tmpl
rename to scrapy/templates/project/module/settings.py.tmpl
diff --git a/scrapy/trunk/examples/googledir/googledir/spiders/__init__.py b/scrapy/templates/project/module/spiders/__init__.py
similarity index 100%
rename from scrapy/trunk/examples/googledir/googledir/spiders/__init__.py
rename to scrapy/templates/project/module/spiders/__init__.py
diff --git a/scrapy/trunk/scrapy/templates/project/module/templates/spider_basic.tmpl b/scrapy/templates/project/module/templates/spider_basic.tmpl
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/module/templates/spider_basic.tmpl
rename to scrapy/templates/project/module/templates/spider_basic.tmpl
diff --git a/scrapy/trunk/scrapy/templates/project/module/templates/spider_crawl.tmpl b/scrapy/templates/project/module/templates/spider_crawl.tmpl
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/module/templates/spider_crawl.tmpl
rename to scrapy/templates/project/module/templates/spider_crawl.tmpl
diff --git a/scrapy/trunk/scrapy/templates/project/module/templates/spider_csvfeed.tmpl b/scrapy/templates/project/module/templates/spider_csvfeed.tmpl
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/module/templates/spider_csvfeed.tmpl
rename to scrapy/templates/project/module/templates/spider_csvfeed.tmpl
diff --git a/scrapy/trunk/scrapy/templates/project/module/templates/spider_xmlfeed.tmpl b/scrapy/templates/project/module/templates/spider_xmlfeed.tmpl
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/module/templates/spider_xmlfeed.tmpl
rename to scrapy/templates/project/module/templates/spider_xmlfeed.tmpl
diff --git a/scrapy/trunk/scrapy/templates/project/root/scrapy-ctl.py b/scrapy/templates/project/root/scrapy-ctl.py
similarity index 100%
rename from scrapy/trunk/scrapy/templates/project/root/scrapy-ctl.py
rename to scrapy/templates/project/root/scrapy-ctl.py
diff --git a/scrapy/trunk/scrapy/tests/__init__.py b/scrapy/tests/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/__init__.py
rename to scrapy/tests/__init__.py
diff --git a/scrapy/trunk/scrapy/tests/run.py b/scrapy/tests/run.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/run.py
rename to scrapy/tests/run.py
diff --git a/scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-ascii.html b/scrapy/tests/sample_data/adaptors/enc-ascii.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-ascii.html
rename to scrapy/tests/sample_data/adaptors/enc-ascii.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-cp1252.html b/scrapy/tests/sample_data/adaptors/enc-cp1252.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-cp1252.html
rename to scrapy/tests/sample_data/adaptors/enc-cp1252.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-latin1.html b/scrapy/tests/sample_data/adaptors/enc-latin1.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-latin1.html
rename to scrapy/tests/sample_data/adaptors/enc-latin1.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-utf8-meta-latin1.html b/scrapy/tests/sample_data/adaptors/enc-utf8-meta-latin1.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-utf8-meta-latin1.html
rename to scrapy/tests/sample_data/adaptors/enc-utf8-meta-latin1.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-utf8.html b/scrapy/tests/sample_data/adaptors/enc-utf8.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/adaptors/enc-utf8.html
rename to scrapy/tests/sample_data/adaptors/enc-utf8.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/adaptors/extr_unquoted.xml b/scrapy/tests/sample_data/adaptors/extr_unquoted.xml
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/adaptors/extr_unquoted.xml
rename to scrapy/tests/sample_data/adaptors/extr_unquoted.xml
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.tar b/scrapy/tests/sample_data/compressed/feed-sample1.tar
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.tar
rename to scrapy/tests/sample_data/compressed/feed-sample1.tar
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.xml b/scrapy/tests/sample_data/compressed/feed-sample1.xml
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.xml
rename to scrapy/tests/sample_data/compressed/feed-sample1.xml
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.xml.bz2 b/scrapy/tests/sample_data/compressed/feed-sample1.xml.bz2
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.xml.bz2
rename to scrapy/tests/sample_data/compressed/feed-sample1.xml.bz2
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.xml.gz b/scrapy/tests/sample_data/compressed/feed-sample1.xml.gz
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.xml.gz
rename to scrapy/tests/sample_data/compressed/feed-sample1.xml.gz
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.zip b/scrapy/tests/sample_data/compressed/feed-sample1.zip
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/compressed/feed-sample1.zip
rename to scrapy/tests/sample_data/compressed/feed-sample1.zip
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/html-gzip.bin b/scrapy/tests/sample_data/compressed/html-gzip.bin
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/compressed/html-gzip.bin
rename to scrapy/tests/sample_data/compressed/html-gzip.bin
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/html-rawdeflate.bin b/scrapy/tests/sample_data/compressed/html-rawdeflate.bin
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/compressed/html-rawdeflate.bin
rename to scrapy/tests/sample_data/compressed/html-rawdeflate.bin
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/html-zlibdeflate.bin b/scrapy/tests/sample_data/compressed/html-zlibdeflate.bin
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/compressed/html-zlibdeflate.bin
rename to scrapy/tests/sample_data/compressed/html-zlibdeflate.bin
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/feeds/feed-sample1.xml b/scrapy/tests/sample_data/feeds/feed-sample1.xml
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/feeds/feed-sample1.xml
rename to scrapy/tests/sample_data/feeds/feed-sample1.xml
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/feeds/feed-sample2.xml b/scrapy/tests/sample_data/feeds/feed-sample2.xml
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/feeds/feed-sample2.xml
rename to scrapy/tests/sample_data/feeds/feed-sample2.xml
diff --git a/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample3.csv b/scrapy/tests/sample_data/feeds/feed-sample3.csv
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample3.csv
rename to scrapy/tests/sample_data/feeds/feed-sample3.csv
diff --git a/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample4.csv b/scrapy/tests/sample_data/feeds/feed-sample4.csv
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample4.csv
rename to scrapy/tests/sample_data/feeds/feed-sample4.csv
diff --git a/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample5.csv b/scrapy/tests/sample_data/feeds/feed-sample5.csv
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample5.csv
rename to scrapy/tests/sample_data/feeds/feed-sample5.csv
diff --git a/scrapy/trunk/scrapy/tests/sample_data/link_extractor/image_linkextractor.html b/scrapy/tests/sample_data/link_extractor/image_linkextractor.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/link_extractor/image_linkextractor.html
rename to scrapy/tests/sample_data/link_extractor/image_linkextractor.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/link_extractor/linkextractor_latin1.html b/scrapy/tests/sample_data/link_extractor/linkextractor_latin1.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/link_extractor/linkextractor_latin1.html
rename to scrapy/tests/sample_data/link_extractor/linkextractor_latin1.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/link_extractor/linkextractor_noenc.html b/scrapy/tests/sample_data/link_extractor/linkextractor_noenc.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/link_extractor/linkextractor_noenc.html
rename to scrapy/tests/sample_data/link_extractor/linkextractor_noenc.html
diff --git a/scrapy/trunk/scrapy/tests/sample_data/link_extractor/regex_linkextractor.html b/scrapy/tests/sample_data/link_extractor/regex_linkextractor.html
similarity index 100%
rename from scrapy/trunk/scrapy/tests/sample_data/link_extractor/regex_linkextractor.html
rename to scrapy/tests/sample_data/link_extractor/regex_linkextractor.html
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/test_site/index.html b/scrapy/tests/sample_data/test_site/index.html
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/test_site/index.html
rename to scrapy/tests/sample_data/test_site/index.html
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/test_site/item1.html b/scrapy/tests/sample_data/test_site/item1.html
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/test_site/item1.html
rename to scrapy/tests/sample_data/test_site/item1.html
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/sample_data/test_site/item2.html b/scrapy/tests/sample_data/test_site/item2.html
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/sample_data/test_site/item2.html
rename to scrapy/tests/sample_data/test_site/item2.html
diff --git a/scrapy/trunk/scrapy/tests/test_adaptors.py b/scrapy/tests/test_adaptors.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_adaptors.py
rename to scrapy/tests/test_adaptors.py
diff --git a/scrapy/trunk/scrapy/tests/test_aws.py b/scrapy/tests/test_aws.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_aws.py
rename to scrapy/tests/test_aws.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_c14nurls.py b/scrapy/tests/test_c14nurls.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/test_c14nurls.py
rename to scrapy/tests/test_c14nurls.py
diff --git a/scrapy/trunk/scrapy/tests/test_contrib_response_soup.py b/scrapy/tests/test_contrib_response_soup.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_contrib_response_soup.py
rename to scrapy/tests/test_contrib_response_soup.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_dependencies.py b/scrapy/tests/test_dependencies.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/test_dependencies.py
rename to scrapy/tests/test_dependencies.py
diff --git a/scrapy/trunk/scrapy/tests/test_downloadermiddleware_cookies.py b/scrapy/tests/test_downloadermiddleware_cookies.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_downloadermiddleware_cookies.py
rename to scrapy/tests/test_downloadermiddleware_cookies.py
diff --git a/scrapy/trunk/scrapy/tests/test_downloadermiddleware_decompression.py b/scrapy/tests/test_downloadermiddleware_decompression.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_downloadermiddleware_decompression.py
rename to scrapy/tests/test_downloadermiddleware_decompression.py
diff --git a/scrapy/trunk/scrapy/tests/test_downloadermiddleware_httpcompression.py b/scrapy/tests/test_downloadermiddleware_httpcompression.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_downloadermiddleware_httpcompression.py
rename to scrapy/tests/test_downloadermiddleware_httpcompression.py
diff --git a/scrapy/trunk/scrapy/tests/test_downloadermiddleware_redirect.py b/scrapy/tests/test_downloadermiddleware_redirect.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_downloadermiddleware_redirect.py
rename to scrapy/tests/test_downloadermiddleware_redirect.py
diff --git a/scrapy/trunk/scrapy/tests/test_downloadermiddleware_retry.py b/scrapy/tests/test_downloadermiddleware_retry.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_downloadermiddleware_retry.py
rename to scrapy/tests/test_downloadermiddleware_retry.py
diff --git a/scrapy/trunk/scrapy/tests/test_downloadermiddleware_useragent.py b/scrapy/tests/test_downloadermiddleware_useragent.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_downloadermiddleware_useragent.py
rename to scrapy/tests/test_downloadermiddleware_useragent.py
diff --git a/scrapy/trunk/scrapy/tests/test_dupefilter.py b/scrapy/tests/test_dupefilter.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_dupefilter.py
rename to scrapy/tests/test_dupefilter.py
diff --git a/scrapy/trunk/scrapy/tests/test_engine.py b/scrapy/tests/test_engine.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_engine.py
rename to scrapy/tests/test_engine.py
diff --git a/scrapy/trunk/scrapy/tests/test_http_cookies.py b/scrapy/tests/test_http_cookies.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_http_cookies.py
rename to scrapy/tests/test_http_cookies.py
diff --git a/scrapy/trunk/scrapy/tests/test_http_headers.py b/scrapy/tests/test_http_headers.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_http_headers.py
rename to scrapy/tests/test_http_headers.py
diff --git a/scrapy/trunk/scrapy/tests/test_http_request.py b/scrapy/tests/test_http_request.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_http_request.py
rename to scrapy/tests/test_http_request.py
diff --git a/scrapy/trunk/scrapy/tests/test_http_response.py b/scrapy/tests/test_http_response.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_http_response.py
rename to scrapy/tests/test_http_response.py
diff --git a/scrapy/trunk/scrapy/tests/test_http_url.py b/scrapy/tests/test_http_url.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_http_url.py
rename to scrapy/tests/test_http_url.py
diff --git a/scrapy/trunk/scrapy/tests/test_item.py b/scrapy/tests/test_item.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_item.py
rename to scrapy/tests/test_item.py
diff --git a/scrapy/trunk/scrapy/tests/test_itemadaptor.py b/scrapy/tests/test_itemadaptor.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_itemadaptor.py
rename to scrapy/tests/test_itemadaptor.py
diff --git a/scrapy/trunk/scrapy/tests/test_libxml2.py b/scrapy/tests/test_libxml2.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_libxml2.py
rename to scrapy/tests/test_libxml2.py
diff --git a/scrapy/trunk/scrapy/tests/test_link.py b/scrapy/tests/test_link.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_link.py
rename to scrapy/tests/test_link.py
diff --git a/scrapy/trunk/scrapy/tests/test_newitem.py b/scrapy/tests/test_newitem.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_newitem.py
rename to scrapy/tests/test_newitem.py
diff --git a/scrapy/trunk/scrapy/tests/test_pipeline_images.py b/scrapy/tests/test_pipeline_images.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_pipeline_images.py
rename to scrapy/tests/test_pipeline_images.py
diff --git a/scrapy/trunk/scrapy/tests/test_responsetypes.py b/scrapy/tests/test_responsetypes.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_responsetypes.py
rename to scrapy/tests/test_responsetypes.py
diff --git a/scrapy/trunk/scrapy/tests/test_robustscrapeditem.py b/scrapy/tests/test_robustscrapeditem.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_robustscrapeditem.py
rename to scrapy/tests/test_robustscrapeditem.py
diff --git a/scrapy/trunk/scrapy/tests/test_schedulermiddleware_duplicatesfilter.py b/scrapy/tests/test_schedulermiddleware_duplicatesfilter.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_schedulermiddleware_duplicatesfilter.py
rename to scrapy/tests/test_schedulermiddleware_duplicatesfilter.py
diff --git a/scrapy/trunk/scrapy/tests/test_serialization.py b/scrapy/tests/test_serialization.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_serialization.py
rename to scrapy/tests/test_serialization.py
diff --git a/scrapy/trunk/scrapy/tests/test_spidermiddleware_duplicatesfilter.py b/scrapy/tests/test_spidermiddleware_duplicatesfilter.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_spidermiddleware_duplicatesfilter.py
rename to scrapy/tests/test_spidermiddleware_duplicatesfilter.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_spidermonkey.py b/scrapy/tests/test_spidermonkey.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/test_spidermonkey.py
rename to scrapy/tests/test_spidermonkey.py
diff --git a/scrapy/trunk/scrapy/contrib/cluster/crawler/__init__.py b/scrapy/tests/test_spiders/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/crawler/__init__.py
rename to scrapy/tests/test_spiders/__init__.py
diff --git a/scrapy/trunk/scrapy/tests/test_spiders/testspider.py b/scrapy/tests/test_spiders/testspider.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_spiders/testspider.py
rename to scrapy/tests/test_spiders/testspider.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/tests/test_stats.py b/scrapy/tests/test_stats.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/tests/test_stats.py
rename to scrapy/tests/test_stats.py
diff --git a/scrapy/trunk/scrapy/tests/test_storedb.py b/scrapy/tests/test_storedb.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_storedb.py
rename to scrapy/tests/test_storedb.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_datatypes.py b/scrapy/tests/test_utils_datatypes.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_datatypes.py
rename to scrapy/tests/test_utils_datatypes.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_defer.py b/scrapy/tests/test_utils_defer.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_defer.py
rename to scrapy/tests/test_utils_defer.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_iterators.py b/scrapy/tests/test_utils_iterators.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_iterators.py
rename to scrapy/tests/test_utils_iterators.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_markup.py b/scrapy/tests/test_utils_markup.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_markup.py
rename to scrapy/tests/test_utils_markup.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_misc.py b/scrapy/tests/test_utils_misc.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_misc.py
rename to scrapy/tests/test_utils_misc.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_python.py b/scrapy/tests/test_utils_python.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_python.py
rename to scrapy/tests/test_utils_python.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_request.py b/scrapy/tests/test_utils_request.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_request.py
rename to scrapy/tests/test_utils_request.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_response.py b/scrapy/tests/test_utils_response.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_response.py
rename to scrapy/tests/test_utils_response.py
diff --git a/scrapy/trunk/scrapy/tests/test_utils_url.py b/scrapy/tests/test_utils_url.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_utils_url.py
rename to scrapy/tests/test_utils_url.py
diff --git a/scrapy/trunk/scrapy/tests/test_webclient.py b/scrapy/tests/test_webclient.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_webclient.py
rename to scrapy/tests/test_webclient.py
diff --git a/scrapy/trunk/scrapy/tests/test_xpath.py b/scrapy/tests/test_xpath.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_xpath.py
rename to scrapy/tests/test_xpath.py
diff --git a/scrapy/trunk/scrapy/tests/test_xpath_extension.py b/scrapy/tests/test_xpath_extension.py
similarity index 100%
rename from scrapy/trunk/scrapy/tests/test_xpath_extension.py
rename to scrapy/tests/test_xpath_extension.py
diff --git a/scrapy/trunk/README b/scrapy/trunk/README
deleted file mode 100644
index e59d381f7..000000000
--- a/scrapy/trunk/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This is Scrapy, an opensource screen scraping framework written in Python.
-
-For more visit the project home page at http://scrapy.org
diff --git a/scrapy/trunk/docs/media/scrapy-architecture.dia b/scrapy/trunk/docs/media/scrapy-architecture.dia
deleted file mode 100644
index d23cba1ac..000000000
Binary files a/scrapy/trunk/docs/media/scrapy-architecture.dia and /dev/null differ
diff --git a/scrapy/trunk/extras/sql/scraping.sql b/scrapy/trunk/extras/sql/scraping.sql
deleted file mode 100644
index c3314f5a1..000000000
--- a/scrapy/trunk/extras/sql/scraping.sql
+++ /dev/null
@@ -1,72 +0,0 @@
-DROP TABLE IF EXISTS `url_history`;
-DROP TABLE IF EXISTS `version`;
-DROP TABLE IF EXISTS `url_status`;
-DROP TABLE IF EXISTS `ticket`;
-DROP TABLE IF EXISTS `domain_stats`;
-DROP TABLE IF EXISTS `domain_stats_history`;
-DROP TABLE IF EXISTS `domain_data_history`;
-
-CREATE TABLE `ticket` (
- `guid` char(40) NOT NULL,
- `domain` varchar(255) default NULL,
- `url` varchar(2048) default NULL,
- `url_hash` char(40) default NULL, -- so we can join to url_status
- PRIMARY KEY (`guid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `version` (
- `id` bigint(20) NOT NULL auto_increment,
- `guid` char(40) NOT NULL,
- `version` char(40) NOT NULL,
- `seen` datetime NOT NULL,
- PRIMARY KEY (`id`),
- FOREIGN KEY (`guid`) REFERENCES ticket(guid) ON UPDATE CASCADE ON DELETE CASCADE,
- UNIQUE KEY (`version`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `url_status` (
- -- see http://support.microsoft.com/kb/q208427/ for explanation of 2048
- `url_hash` char(40) NOT NULL, -- for faster searches
- `url` varchar(2048) NOT NULL,
- `parent_hash` char(40) default NULL, -- the url that was followed to this one - for reporting
- `last_version` char(40) default NULL, -- can be null if it generated an error the last time is was checked
- `last_checked` datetime NOT NULL,
- PRIMARY KEY (`url_hash`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `url_history` (
- `url_hash` char(40) NOT NULL,
- `version` char(40) NOT NULL,
- `postdata_hash` char(40) default NULL,
- `created` datetime NOT NULL,
- PRIMARY KEY (`version`),
- FOREIGN KEY (`url_hash`) REFERENCES url_status(url_hash) ON UPDATE CASCADE ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `domain_stats` (
- `key1` varchar(128) NOT NULL,
- `key2` varchar(128) NOT NULL,
- `value` text,
- PRIMARY KEY `key1_key2` (`key1`, `key2`),
- KEY `key1` (`key1`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `domain_stats_history` (
- `id` bigint(20) NOT NULL auto_increment,
- `key1` varchar(128) NOT NULL,
- `key2` varchar(128) NOT NULL,
- `value` varchar(2048) NOT NULL,
- `stored` datetime NOT NULL,
- PRIMARY KEY (`id`),
- KEY `key1_key2` (`key1`, `key2`),
- KEY `key1` (`key1`),
- KEY `stored` (`stored`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `domain_data_history` (
- `domain` varchar(255) NOT NULL,
- `stored` datetime NOT NULL,
- `data` text,
- KEY `domain_stored` (`domain`, `stored`),
- KEY `domain` (`domain`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/scrapy/trunk/scrapy/command/__init__.py b/scrapy/trunk/scrapy/command/__init__.py
deleted file mode 100644
index 0692578bb..000000000
--- a/scrapy/trunk/scrapy/command/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from scrapy.command.models import ScrapyCommand
diff --git a/scrapy/trunk/scrapy/command/commands/download.py b/scrapy/trunk/scrapy/command/commands/download.py
deleted file mode 100644
index a8a09a0f0..000000000
--- a/scrapy/trunk/scrapy/command/commands/download.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import sys, pprint
-
-from scrapy.command import ScrapyCommand
-from scrapy.fetcher import fetch
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "[options] <url>"
-
- def short_desc(self):
- return "Download a URL using the Scrapy downloader"
-
- def add_options(self, parser):
- ScrapyCommand.add_options(self, parser)
- parser.add_option("-s", "--source", dest="source", action="store_true", help="output HTTP body only")
- parser.add_option("--headers", dest="headers", action="store_true", help="output HTTP headers only")
-
- def run(self, args, opts):
- if not args:
- print "A URL is required"
- return
-
- responses = fetch(args)
- if responses:
- if opts.headers:
- pprint.pprint(responses[0].headers)
- else:
- sys.stdout.write(str(responses[0].body))
diff --git a/scrapy/trunk/scrapy/command/commands/help.py b/scrapy/trunk/scrapy/command/commands/help.py
deleted file mode 100644
index 8a7358763..000000000
--- a/scrapy/trunk/scrapy/command/commands/help.py
+++ /dev/null
@@ -1,26 +0,0 @@
-from scrapy.command import ScrapyCommand, cmdline
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "<command>"
-
- def short_desc(self):
- return "Provides extended help for the given command"
-
- def run(self, args, opts):
- if not args:
- return False
-
- commands = cmdline.builtin_commands_dict()
- commands.update(cmdline.custom_commands_dict())
-
- cmdname = args[0]
- if cmdname in commands:
- cmd = commands[cmdname]
- help = getattr(cmd, 'help', None) or getattr(cmd, 'long_desc', None)
- print "%s: %s" % (cmdname, cmd.short_desc())
- print "usage: %s %s" % (cmdname, cmd.syntax())
- print
- print help()
- else:
- print "Unknown command: %s" % cmdname
diff --git a/scrapy/trunk/scrapy/command/commands/list.py b/scrapy/trunk/scrapy/command/commands/list.py
deleted file mode 100644
index 70f6f43c4..000000000
--- a/scrapy/trunk/scrapy/command/commands/list.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from scrapy.command import ScrapyCommand
-from scrapy.spider import spiders
-
-class Command(ScrapyCommand):
- def syntax(self):
- return ""
-
- def short_desc(self):
- return "List available spiders (both enabled and disabled)"
-
- def run(self, args, opts):
- spiders_dict = spiders.asdict()
- for n, p in spiders_dict.items():
- disabled = "disabled" if getattr(p, 'disabled', False) else "enabled"
- print "%-30s %-30s %s" % (n, p.__class__.__name__, disabled)
- print "Total spiders: %d" % len(spiders_dict)
diff --git a/scrapy/trunk/scrapy/command/commands/log.py b/scrapy/trunk/scrapy/command/commands/log.py
deleted file mode 100644
index fff7ebbd8..000000000
--- a/scrapy/trunk/scrapy/command/commands/log.py
+++ /dev/null
@@ -1,46 +0,0 @@
-import re
-
-from scrapy.command import ScrapyCommand
-
-log_crawled_re = re.compile(r'^(.*?) \[\w+/(.*?)\].*Crawled <(.*?)> from <(.*?)>$')
-log_scraped_re = re.compile('^(.*?) \[\w+/(.*?)\].*Scraped (.*) in <(.*?)>$')
-log_opendomain_re = re.compile('^(.*?) \[\w+.*? Started scraping (.*)$')
-log_closedomain_re = re.compile('^(.*?) \[\w+.*? Finished scraping (.*)$')
-log_debug_re = re.compile(r'\[\w+/(.*?)\] DEBUG')
-log_info_re = re.compile(r'\[\w+/(.*?)\] INFO')
-log_warning_re = re.compile(r'\[\w+/(.*?)\] WARNING')
-log_error_re = re.compile(r'\[\w+/(.*?)\] ERROR')
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "[options] <logfile>"
-
- def short_desc(self):
- return "Several tools to perform scrapy log analysis"
-
- def add_options(self, parser):
- ScrapyCommand.add_options(self, parser)
- parser.add_option("--sitemap", dest="sitemap", action="store_true", help="show sitemap based on given log file")
-
- def sitemap(self, logfile):
- from scrapy.utils.datatypes import Sitemap
-
- sm = Sitemap()
- for l in open(logfile).readlines():
- m = log_crawled_re.search(l.strip())
- if m:
- sm.add_node(m.group(3), m.group(4))
- m = log_scraped_re.search(l.strip())
- if m:
- sm.add_item(m.group(4), m.group(3))
- print sm.to_string()
-
- def run(self, args, opts):
- if not args:
- print "A log file is required"
- return
-
- if opts.sitemap:
- self.sitemap(args[0])
- else:
- print "No analysis method specified"
diff --git a/scrapy/trunk/scrapy/command/commands/start.py b/scrapy/trunk/scrapy/command/commands/start.py
deleted file mode 100644
index fb8786df2..000000000
--- a/scrapy/trunk/scrapy/command/commands/start.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from scrapy.command import ScrapyCommand
-from scrapy.core.manager import scrapymanager
-
-
-class Command(ScrapyCommand):
- def syntax(self):
- return "[options]"
-
- def short_desc(self):
- return "Start the Scrapy server"
-
- def add_options(self, parser):
- ScrapyCommand.add_options(self, parser)
-
- def run(self, args, opts):
- scrapymanager.start(*args, **opts.__dict__)
diff --git a/scrapy/trunk/scrapy/conf/commands/crawl.py b/scrapy/trunk/scrapy/conf/commands/crawl.py
deleted file mode 100644
index 357422ea3..000000000
--- a/scrapy/trunk/scrapy/conf/commands/crawl.py
+++ /dev/null
@@ -1 +0,0 @@
-LOG_STDOUT = True
diff --git a/scrapy/trunk/scrapy/conf/commands/help.py b/scrapy/trunk/scrapy/conf/commands/help.py
deleted file mode 100644
index bcee80b55..000000000
--- a/scrapy/trunk/scrapy/conf/commands/help.py
+++ /dev/null
@@ -1 +0,0 @@
-LOG_ENABLED = False
diff --git a/scrapy/trunk/scrapy/conf/commands/list.py b/scrapy/trunk/scrapy/conf/commands/list.py
deleted file mode 100644
index bcee80b55..000000000
--- a/scrapy/trunk/scrapy/conf/commands/list.py
+++ /dev/null
@@ -1 +0,0 @@
-LOG_ENABLED = False
diff --git a/scrapy/trunk/scrapy/conf/commands/log.py b/scrapy/trunk/scrapy/conf/commands/log.py
deleted file mode 100644
index bcee80b55..000000000
--- a/scrapy/trunk/scrapy/conf/commands/log.py
+++ /dev/null
@@ -1 +0,0 @@
-LOG_ENABLED = False
diff --git a/scrapy/trunk/scrapy/conf/commands/scrape.py b/scrapy/trunk/scrapy/conf/commands/scrape.py
deleted file mode 100644
index 96afeec1a..000000000
--- a/scrapy/trunk/scrapy/conf/commands/scrape.py
+++ /dev/null
@@ -1,2 +0,0 @@
-LOG_ENABLED = False
-
diff --git a/scrapy/trunk/scrapy/conf/commands/stats.py b/scrapy/trunk/scrapy/conf/commands/stats.py
deleted file mode 100644
index bcee80b55..000000000
--- a/scrapy/trunk/scrapy/conf/commands/stats.py
+++ /dev/null
@@ -1 +0,0 @@
-LOG_ENABLED = False
diff --git a/scrapy/trunk/scrapy/conf/commands/test.py b/scrapy/trunk/scrapy/conf/commands/test.py
deleted file mode 100644
index bcee80b55..000000000
--- a/scrapy/trunk/scrapy/conf/commands/test.py
+++ /dev/null
@@ -1 +0,0 @@
-LOG_ENABLED = False
diff --git a/scrapy/trunk/scrapy/contrib/cluster/worker/__init__.py b/scrapy/trunk/scrapy/contrib/cluster/worker/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/__init__.py b/scrapy/trunk/scrapy/contrib/downloadermiddleware/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/errorpages.py b/scrapy/trunk/scrapy/contrib/downloadermiddleware/errorpages.py
deleted file mode 100644
index d9d0931ad..000000000
--- a/scrapy/trunk/scrapy/contrib/downloadermiddleware/errorpages.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from scrapy.core.exceptions import HttpException
-
-class ErrorPagesMiddleware(object):
- """This middleware allows the spiders to receive error (non 200) responses,
- the same way the receive normal responses"""
-
- def process_exception(self, request, exception, spider):
- if isinstance(exception, HttpException):
- statuses = getattr(spider, 'handle_httpstatus_list', None)
- httpstatus = exception.response.status
- if statuses and httpstatus in statuses:
- return exception.response
-
diff --git a/scrapy/trunk/scrapy/contrib/groupsettings.py b/scrapy/trunk/scrapy/contrib/groupsettings.py
deleted file mode 100644
index 4bad4100b..000000000
--- a/scrapy/trunk/scrapy/contrib/groupsettings.py
+++ /dev/null
@@ -1,26 +0,0 @@
-"""
-Extensions to override scrapy settings with per-group settings according to the
-group the spider belongs to. It only overrides the settings when running the
-crawl command with *only one domain as argument*.
-"""
-
-from scrapy.conf import settings
-from scrapy.core.exceptions import NotConfigured
-from scrapy.command.cmdline import command_executed
-
-class GroupSettings(object):
-
- def __init__(self):
- if not settings.getbool("GROUPSETTINGS_ENABLED"):
- raise NotConfigured
-
- if command_executed and command_executed['name'] == 'crawl':
- mod = __import__(settings['GROUPSETTINGS_MODULE'], {}, {}, [''])
- args = command_executed['args']
- if len(args) == 1 and not args[0].startswith('http://'):
- domain = args[0]
- settings.overrides.update(mod.default_settings)
- for group, domains in mod.group_spiders.iteritems():
- if domain in domains:
- settings.overrides.update(mod.group_settings.get(group, {}))
-
diff --git a/scrapy/trunk/scrapy/contrib/item/__init__.py b/scrapy/trunk/scrapy/contrib/item/__init__.py
deleted file mode 100644
index a6226fec9..000000000
--- a/scrapy/trunk/scrapy/contrib/item/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from scrapy.contrib.item.models import RobustScrapedItem, RobustItemDelta, ValidationError, ValidationPipeline
diff --git a/scrapy/trunk/scrapy/contrib/pipeline/__init__.py b/scrapy/trunk/scrapy/contrib/pipeline/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/prioritizers.py b/scrapy/trunk/scrapy/contrib/prioritizers.py
deleted file mode 100644
index e23a6c74a..000000000
--- a/scrapy/trunk/scrapy/contrib/prioritizers.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import time
-
-from scrapy.core.exceptions import NotConfigured
-from scrapy.store.db import DomainDataHistory
-from scrapy.conf import settings
-
-class LessScrapedPrioritizer(object):
- """
- A spider prioritizer based on these few simple rules:
- 1. if spider was never scraped, it has top priority
- 2. if spider was scraped before, then the less recently the spider
- has been scraped, the more priority it has
- """
- def __init__(self, elements):
- if not settings['SCRAPING_DB']:
- raise NotConfigured("SCRAPING_DB setting is required")
-
- self.ddh = DomainDataHistory(settings['SCRAPING_DB'], 'domain_data_history')
- domains_to_scrape = set(elements)
-
- self.priorities = {}
-
- for domain in domains_to_scrape:
- stat = self.ddh.getlast(domain, path="start_time")
- if stat and stat[1]:
- last_started = stat[1]
- # spider is the timestamp of last start time
- self.priorities[domain] = time.mktime(last_started.timetuple())
- else:
- # if domain was never scraped, it has top priority
- self.priorities[domain] = 1
-
- def get_priority(self, element):
- return self.priorities[element]
diff --git a/scrapy/trunk/scrapy/contrib/response/__init__.py b/scrapy/trunk/scrapy/contrib/response/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/schedulermiddleware/__init__.py b/scrapy/trunk/scrapy/contrib/schedulermiddleware/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/spider/__init__.py b/scrapy/trunk/scrapy/contrib/spider/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/spider/profiler.py b/scrapy/trunk/scrapy/contrib/spider/profiler.py
deleted file mode 100644
index 2c8638bd7..000000000
--- a/scrapy/trunk/scrapy/contrib/spider/profiler.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""
-SpiderProfiler is an extension that hooks itself into every Request callback
-returned from spiders to measure the processing time and memory allocation
-caused by spiders code.
-
-The results are collected using the StatsCollector.
-
-This extension introduces a big impact on crawling performance, so enable only
-when needed.
-"""
-
-import datetime
-
-from pydispatch import dispatcher
-
-from scrapy.extension import extensions
-from scrapy.core import signals
-from scrapy.core.exceptions import NotConfigured
-from scrapy.stats import stats
-from scrapy.conf import settings
-
-class SpiderProfiler(object):
-
- def __init__(self):
- if not settings.getbool('SPIDERPROFILER_ENABLED'):
- raise NotConfigured
- dispatcher.connect(self._request_received, signals.request_received)
- dispatcher.connect(self._engine_started, signals.engine_started)
-
- def _engine_started(self):
- self.memusage = extensions.enabled.get('MemoryUsage', None)
-
- def _request_received(self, request, spider):
- old_cbs = request.deferred.callbacks[0]
- new_cbs = ((self._profiled_callback(old_cbs[0][0], spider), old_cbs[0][1], old_cbs[0][2]), old_cbs[1])
- request.deferred.callbacks[0] = new_cbs
-
- def _profiled_callback(self, function, spider):
- def new_callback(*args, **kwargs):
- tbefore = datetime.datetime.now()
- mbefore = self._memusage()
- r = function(*args, **kwargs)
- tafter = datetime.datetime.now()
- mafter = self._memusage()
- ct = tafter-tbefore
- tcc = stats.getpath('%s/profiling/total_callback_time' % spider.domain_name, datetime.timedelta(0))
- sct = stats.getpath('%s/profiling/slowest_callback_time' % spider.domain_name, datetime.timedelta(0))
- stats.setpath('%s/profiling/total_callback_time' % spider.domain_name, tcc+ct)
- if ct > sct:
- stats.setpath('%s/profiling/slowest_callback_time' % spider.domain_name, ct)
- stats.setpath('%s/profiling/slowest_callback_name' % spider.domain_name, function.__name__)
- stats.setpath('%s/profiling/slowest_callback_url' % spider.domain_name, args[0].url)
- if self.memusage:
- tma = stats.getpath('%s/profiling/total_mem_allocated_in_callbacks' % spider.domain_name, 0)
- stats.setpath('%s/profiling/total_mem_allocated_in_callbacks' % spider.domain_name, tma+mafter-mbefore)
- return r
- return new_callback
-
- def _memusage(self):
- return self.memusage.virtual if self.memusage else 0.0
diff --git a/scrapy/trunk/scrapy/contrib/spider/reloader.py b/scrapy/trunk/scrapy/contrib/spider/reloader.py
deleted file mode 100644
index 1aa116f12..000000000
--- a/scrapy/trunk/scrapy/contrib/spider/reloader.py
+++ /dev/null
@@ -1,19 +0,0 @@
-"""
-Reload spider modules once they are finished scraping
-
-This is to release any resources held on to by scraping spiders.
-"""
-import sys
-from pydispatch import dispatcher
-from scrapy.core import signals
-from scrapy import log
-
-class SpiderReloader(object):
-
- def __init__(self):
- dispatcher.connect(self.domain_closed, signal=signals.domain_closed)
-
- def domain_closed(self, domain, spider):
- module = spider.__module__
- log.msg("reloading module %s" % module, domain=domain)
- reload(sys.modules[module])
diff --git a/scrapy/trunk/scrapy/contrib/spidermiddleware/__init__.py b/scrapy/trunk/scrapy/contrib/spidermiddleware/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/web/__init__.py b/scrapy/trunk/scrapy/contrib/web/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/web/http.py b/scrapy/trunk/scrapy/contrib/web/http.py
deleted file mode 100644
index dcc7732b0..000000000
--- a/scrapy/trunk/scrapy/contrib/web/http.py
+++ /dev/null
@@ -1,115 +0,0 @@
-"""A django alike request-response model
-
-most of this code is borrowed from django
-"""
-
-from Cookie import SimpleCookie
-from scrapy.utils.datatypes import MultiValueDict, CaselessDict
-
-
-def build_httprequest(twistedrequest):
- """Translate twisted request object to a django request approach"""
- request = HttpRequest()
- request.path = twistedrequest.path
- request.method = twistedrequest.method.upper()
- request.COOKIES = SimpleCookie(twistedrequest.received_cookies)
- request.HEADERS = Headers(twistedrequest.received_headers)
- request.ARGS = MultiValueDict(twistedrequest.args)
- request.FILES = {} # not yet supported
- request.content = twistedrequest.content
- request.twistedrequest = twistedrequest
- return request
-
-
-class HttpRequest(object):
- def __init__(self):
- self.path = ''
- self.method = None
- self.COOKIES = {}
- self.HEADERS = {}
- self.ARGS = {}
- self.FILES = {}
-
-
-class HttpResponse(object):
- status_code = 200
-
- def __init__(self, content='', status=None, content_type=None):
- content_type = content_type or "text/html; charset=utf-8"
- self._headers = {'content-type': content_type}
- self.content = content
- self.cookies = SimpleCookie()
- self.status_code = status
-
- def __str__(self):
- "Full HTTP message, including headers"
- return '\n'.join(['%s: %s' % (key, value)
- for key, value in self._headers.items()]) \
- + '\n\n' + self.content
-
- def __setitem__(self, header, value):
- self._headers[header.lower()] = value
-
- def __delitem__(self, header):
- try:
- del self._headers[header.lower()]
- except KeyError:
- pass
-
- def __getitem__(self, header):
- return self._headers[header.lower()]
-
- def has_header(self, header):
- "Case-insensitive check for a header"
- return self._headers.has_key(header.lower())
-
- __contains__ = has_header
-
- def items(self):
- return self._headers.items()
-
- def get(self, header, alternate):
- return self._headers.get(header, alternate)
-
- def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
- self.cookies[key] = value
- for var in ('max_age', 'path', 'domain', 'secure', 'expires'):
- val = locals()[var]
- if val is not None:
- self.cookies[key][var.replace('_', '-')] = val
-
- def delete_cookie(self, key, path='/', domain=None):
- self.cookies[key] = ''
- if path is not None:
- self.cookies[key]['path'] = path
- if domain is not None:
- self.cookies[key]['domain'] = domain
- self.cookies[key]['expires'] = 0
- self.cookies[key]['max-age'] = 0
-
-
-class Headers(CaselessDict):
- def __init__(self, source=None, encoding='utf-8'):
- self.encoding = encoding
-
- if getattr(source, 'iteritems', None):
- d = source.iteritems()
- else:
- d = source # best effort
-
- # can't use CaselessDict.__init__(self, d) because it doesn't call __setitem__
- for k,v in d:
- self.__setitem__(k.lower(), v)
-
- def normkey(self, key):
- return key.title() # 'Content-Type' styles headers
-
- def __setitem__(self, key, value):
- """Headers must not be unicode"""
- if isinstance(key, unicode):
- key = key.encode(self.encoding)
- if isinstance(value, unicode):
- value = value.encode(self.encoding)
- super(Headers, self).__setitem__(key, value)
-
-
diff --git a/scrapy/trunk/scrapy/contrib/web/json.py b/scrapy/trunk/scrapy/contrib/web/json.py
deleted file mode 100644
index 1987b1dc9..000000000
--- a/scrapy/trunk/scrapy/contrib/web/json.py
+++ /dev/null
@@ -1,99 +0,0 @@
-from functools import wraps
-
-from scrapy.utils.defer import mustbe_deferred
-from scrapy.utils.serialization import serialize as _serialize, unserialize as _unserialize
-
-from .http import HttpResponse
-
-JSON_CONTENT_TYPES = ('application/json',)
-
-serialize = lambda x: _serialize(x, 'json')
-unserialize = lambda x: _unserialize(x, 'json')
-
-class JsonException(Exception):
- pass
-
-class JsonResponse(HttpResponse):
- def __init__(self, content=None, callback=None, serialize=serialize, *args, **kwargs):
- content = serialize(content)
- if callback: # JSONP support
- status, content = 200, '%s(%s)' % (callback, content)
- kwargs.setdefault('content_type', 'application/x-javascript')
- HttpResponse.__init__(self, content=content, *args, **kwargs)
-
-class JsonResponseAccepted(JsonResponse):
- status_code = 202
-
-class JsonResponseNoContent(JsonResponse):
- status_code = 204
-
-class JsonResponseNotModified(JsonResponse):
- status_code = 304
-
-class JsonResponseBadRequest(JsonResponse):
- status_code = 400
-
-class JsonResponseUnauthorized(JsonResponse):
- status_code = 401
-
-class JsonResponseForbidden(JsonResponse):
- status_code = 403
-
-class JsonResponseNotFound(JsonResponse):
- status_code = 404
-
-class JsonResponseInternalServerError(JsonResponse):
- status_code = 500
-
-class JsonResponseNotImplemented(JsonResponse):
- status_code = 501
-
-
-def json(func):
- """ Decorator to wrap a json prepared view and return a JsonResponse
-
- if content-type is application/json, sets request.JSON to unserialized request body.
- in case of unserialization failure, returns JsonResponseBadRequest()
-
- if returned data from func is a dictionary, serialize it and returns JsonResponse()
- """
- if not hasattr(func, '__call__'):
- raise TypeError('The argument should be a callable')
-
- @wraps(func)
- def wrapper(request, *args, **kwargs):
- json_callback = request.ARGS.get('callback') # JSONP support
- request.method = method = _x_http_method_override(request)
- request.content_type = ct = content_type(request)
- request.JSON = None
-
- if method in ('POST', 'PUT'):
- if ct in JSON_CONTENT_TYPES:
- body = request.content.read()
- try:
- request.JSON = unserialize(body)
- except Exception, e:
- return JsonResponseBadRequest('Invalid json: %s' % e )
-
- def _onsuccess(response):
- if not isinstance(response, HttpResponse):
- return JsonResponse(response, json_callback) # best effort
- return response
-
- ret = mustbe_deferred(func, request, *args, **kwargs)
- ret.addCallback(_onsuccess)
- return ret
- return wrapper
-
-def content_type(request):
- ct = request.HEADERS.get('content-type','')
- return ct.split(';')[0].strip()
-
-def _x_http_method_override(request):
- """ support for X-Http-Method-Override hack
-
- some clients does not support methods others than GET and POST, that clients
- has a chance to set an extra header to indicate intended method.
- """
- return request.HEADERS.get('x-http-method-override', request.method).upper()
-
diff --git a/scrapy/trunk/scrapy/contrib/web/service.py b/scrapy/trunk/scrapy/contrib/web/service.py
deleted file mode 100644
index 8db4cc1ac..000000000
--- a/scrapy/trunk/scrapy/contrib/web/service.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import re
-import urllib
-import hashlib
-from twisted.internet import defer
-
-from scrapy.core.engine import scrapyengine
-from scrapy.spider import spiders
-from scrapy.http import Request
-from scrapy.item import ScrapedItem
-from scrapy.core.exceptions import NotConfigured
-from scrapy.conf import settings
-from scrapy.utils.misc import memoize
-from lrucache import LRUCache
-
-from .site import WebSite, WebResource
-from .http import HttpResponse
-from .json import JsonResponse
-
-JSONCALLBACK_RE = '^[a-zA-Z][a-zA-Z_.-]*$'
-CACHESIZE = settings.get('WS_CACHESIZE', 20)
-
-
-def _urlhash(request):
- h = hashlib.sha1()
- for a in sorted(request.ARGS):
- h.update(request.ARGS[a])
- return h.hexdigest()
-
-
-@memoize(cache=LRUCache(CACHESIZE), hash=_urlhash)
-def url_to_guid(httprequest):
- url = httprequest.ARGS.get('url')
- if not url:
- return HttpResponse('Bad Request', 400)
- url = urllib.unquote(url)
-
- jsoncb = httprequest.ARGS.get('callback')
- if jsoncb and not re.match(JSONCALLBACK_RE, jsoncb):
- return HttpResponse('Bad callback argument', 400)
-
- def _response(guids=(), message=None):
- content = {
- 'guids': list(guids),
- 'domain': getattr(spider, 'domain_name', None),
- 'message': message,
- }
- return JsonResponse(content=content, callback=jsoncb)
-
- spider = spiders.fromurl(url)
- if not spider:
- return _response(message='No crawler found for site')
-
- if httprequest.ARGS.get('dontcrawl'):
- return _response()
-
-
- def _on_error(_failure):
- return _response(message='Error downloading url from site')
-
- def _on_success(pagedata):
- try:
- items = spider.identify(pagedata)
- except Exception, ex:
- return _response(message='Error processing url')
-
- guids = [i.guid for i in items if isinstance(i, ScrapedItem)]
- return _response(guids=guids)
-
- deferred = defer.Deferred().addCallbacks(_on_success, _on_error)
- request = Request(url=url, callback=deferred, dont_filter=True)
- schd = scrapyengine.schedule(request, spider)
- schd.chainDeferred(deferred)
- return deferred
-
-
-urlmapping = (
- ('^ws/tools/url_to_guid/$', url_to_guid),
-)
-
-
-class UrlToGuidService(WebSite):
- def __init__(self):
- if not settings.getbool('WS_ENABLED'):
- raise NotConfigured
-
- port = settings.getint('WS_PORT') or 8088
- timeout = settings.getint('WS_TIMEOUT') or 15 # seconds
- resource = WebResource(urlmapping, timeout=timeout)
- WebSite.__init__(self, port=port, resource=resource)
diff --git a/scrapy/trunk/scrapy/contrib/web/site.py b/scrapy/trunk/scrapy/contrib/web/site.py
deleted file mode 100644
index 40c23772b..000000000
--- a/scrapy/trunk/scrapy/contrib/web/site.py
+++ /dev/null
@@ -1,133 +0,0 @@
-"""Twisted website object as django
-
-################################################################################
-## Simple Usage example:
-
-from twisted.internet import reactor
-from scrapy.contrib.web.http import WebSite, HttpResponse
-
-def helloword(request):
- return HttpResponse('Hello World!')
-
-def hello(request, name):
- return HttpResponse('Hello %s' % name)
-
-urls = (
- ('^hello/(?P<name>\w+)/$', hello),
- ('^$', helloword),
- )
-
-
-resource = WebResource(urls)
-site = WebSite(port=8081, resource=resource)
-reactor.run()
-
-# now go to http://localhost:8081/
-
-
-
-################################################################################
-## Complex usage example:
-
-from twisted.internet import reactor, defer
-from scrapy.contrib.web.http import WebSite, HttpResponse
-
-def delayed(request):
- def _callback(result):
- return HttpResponse('Heavy task completed: %s' % result)
-
- def _errback(_failure):
- return HttpResponse('Internal Server Error: %s' % _failure, status=500)
-
- def heavytask(_):
- import random
- assert random.randint(0,1), "Exception found processing request"
- return _
-
- d = defer.Deferred().addCallback(heavytask)
- d.addCallbacks(_callback, _errback)
- reactor.callLater(1, d.callback, "Well done")
- return d
-
-urls = (('^delayed/$', delayed),)
-
-resource = WebResource(urls)
-site = WebSite(port=8081, resource=resource)
-reactor.run()
-
-"""
-
-import re
-
-from twisted.web import server, resource
-from twisted.internet import reactor
-from scrapy.utils.defer import mustbe_deferred
-
-from .http import HttpResponse, build_httprequest
-
-
-def urlresolver(urls, path):
- """Simple path to view mapper"""
- path = path.lstrip('/')
- for pathre, view in urls:
- m = re.search(pathre, path)
- if m:
- kwargs = m.groupdict()
- args = () if kwargs else m.groups()
- return view, args, kwargs
- return None, (), {}
-
-
-class WebSite(server.Site):
- def __init__(self, port=None, *args, **kwargs):
- server.Site.__init__(self, *args, **kwargs)
- if port:
- self.bind(port)
-
- def bind(self, port):
- from scrapy.core.engine import scrapyengine
- scrapyengine.listenTCP(port, self)
-
-
-class WebResource(resource.Resource):
- """Translate twisted web approach to django alike way"""
- isLeaf = True
- debug = True
-
- def __init__(self, urls, timeout=3, urlresolver=urlresolver):
- resource.Resource.__init__(self)
- self.urlresolver = urlresolver
- self.timeout = timeout
- self.urls = urls
-
- def render(self, twistedrequest):
- httprequest = build_httprequest(twistedrequest)
-
- def _send_response(response):
- assert isinstance(response, HttpResponse), 'view should return a HttpResponse object'
- twistedrequest.setResponseCode(response.status_code or 200)
- for key, val in response.items():
- twistedrequest.setHeader(key, response[key])
- twistedrequest.write(response.content)
- twistedrequest.finish()
-
- def _on_error(_failure):
- content = _failure.getTraceback() if self.debug else 'Internal Error'
- response = HttpResponse(content=str(_failure), status=500)
- return _send_response(response)
-
- view, args, kwargs = self.urlresolver(self.urls, httprequest.path)
- if not view:
- response = HttpResponse(content='Not Found', status=404)
- _send_response(response)
- return server.NOT_DONE_YET
-
- deferred = mustbe_deferred(view, httprequest, *args, **kwargs)
- deferred.addCallback(_send_response)
- deferred.addErrback(_on_error)
- if not deferred.timeoutCall:
- deferred.setTimeout(self.timeout)
-
- return server.NOT_DONE_YET
-
-
diff --git a/scrapy/trunk/scrapy/contrib/web/stats.py b/scrapy/trunk/scrapy/contrib/web/stats.py
deleted file mode 100644
index b86961482..000000000
--- a/scrapy/trunk/scrapy/contrib/web/stats.py
+++ /dev/null
@@ -1,55 +0,0 @@
-from functools import partial
-from scrapy.core.exceptions import NotConfigured
-from scrapy.utils.serialization import serialize
-from scrapy.conf import settings
-
-from .site import WebSite, WebResource
-from .json import JsonResponse
-
-STATS_WSPORT = settings.getint('STATS_WSPORT', 8089)
-STATS_WSTIMEOUT = settings.getint('STATS_WSTIMEOUT', 15)
-
-jsonserialize = partial(serialize, format='json')
-
-
-def stats(request):
- service = request.ARGS.get('service', 'getstats')
- if service == 'getstats':
- domain = request.ARGS.get('domain')
- count = request.ARGS.get('count', 1)
- if not domain:
- path = request.ARGS.get('path')
- offset = request.ARGS.get('offset')
- order = request.ARGS.get('order', 'domain')
- olist = request.ARGS.get('olist', 'ASC')
-
- from scrapy.store.db import DomainDataHistory
- ddh = DomainDataHistory(settings['SCRAPING_DB'], 'domain_data_history')
-
- if service == 'countdomains':
- stats = [ddh.domain_count()]
- elif domain:
- stats = list(ddh.get(domain, count=int(count)))
- else:
- stats = list(ddh.getlast_alldomains(count, offset, order, olist, path=path))
-
- content = {'data': stats if stats else "No stats found"}
- return JsonResponse(content=content, serialize=jsonserialize)
-
-
-urlmapping = (
- ('^ws/tools/stats/$', stats),
- )
-
-
-class StatsService(WebSite):
- def __init__(self):
- if not settings['WS_ENABLED']:
- raise NotConfigured
-
- if not settings['SCRAPING_DB']:
- print "SCRAPING_DB setting is required for the stats web service"
- raise NotConfigured
-
- resource = WebResource(urlmapping, timeout=STATS_WSTIMEOUT)
- WebSite.__init__(self, port=STATS_WSPORT, resource=resource)
diff --git a/scrapy/trunk/scrapy/contrib/webconsole/__init__.py b/scrapy/trunk/scrapy/contrib/webconsole/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib/webconsole/enginestatus.py b/scrapy/trunk/scrapy/contrib/webconsole/enginestatus.py
deleted file mode 100644
index e90b9ab30..000000000
--- a/scrapy/trunk/scrapy/contrib/webconsole/enginestatus.py
+++ /dev/null
@@ -1,27 +0,0 @@
-"""
-Scheduler information module for Scrapy webconsole
-"""
-from pydispatch import dispatcher
-from scrapy.core.engine import scrapyengine
-from scrapy.management.web import banner
-
-class EngineStatus(object):
- webconsole_id = 'enginestatus'
- webconsole_name = 'Engine status'
-
- def __init__(self):
- from scrapy.management.web import webconsole_discover_module
- dispatcher.connect(self.webconsole_discover_module, signal=webconsole_discover_module)
-
- def webconsole_render(self, wc_request):
- s = banner(self)
- s += "<pre><code>\n"
- s += scrapyengine.getstatus()
- s += "</pre></code>\n"
- s += "</body>\n"
- s += "</html>\n"
-
- return s
-
- def webconsole_discover_module(self):
- return self
diff --git a/scrapy/trunk/scrapy/contrib/webconsole/spiderstats.py b/scrapy/trunk/scrapy/contrib/webconsole/spiderstats.py
deleted file mode 100644
index df8d56515..000000000
--- a/scrapy/trunk/scrapy/contrib/webconsole/spiderstats.py
+++ /dev/null
@@ -1,80 +0,0 @@
-"""
-Extension for persistent statistics by domain
-"""
-import re
-import pprint
-
-from pydispatch import dispatcher
-
-from scrapy.spider import spiders
-from scrapy.core.exceptions import NotConfigured
-from scrapy.management.web import banner
-from scrapy.conf import settings
-
-class SpiderStats(object):
- webconsole_id = 'spiderstats'
- webconsole_name = 'Spider stats (all-time)'
-
- stats_mainpage = [
- ('item_scraped_count', "Items scraped <br>(last run)"),
- ('item_passed_count', "Items passed <br>(last run)"),
- ('response_count', "Pages crawled <br>(last run)"),
- ('start_time', "Start time <br>(last run)"),
- ('finish_time', "Finish time <br>(last run)"),
- ('finish_status', "Finish status<br>(last run)"),
- ]
-
- PATH_RE = re.compile("/spiderstats/([^/]+)")
-
- def __init__(self):
- if not settings['SCRAPING_DB']:
- raise NotConfigured("SpiderStats: Requires SCRAPING_DB setting")
-
- from scrapy.store.db import DomainDataHistory
- self.ddh = DomainDataHistory(settings['SCRAPING_DB'], 'domain_data_history')
-
- from scrapy.management.web import webconsole_discover_module
- dispatcher.connect(self.webconsole_discover_module, signal=webconsole_discover_module)
-
- def webconsole_render(self, wc_request):
- m = self.PATH_RE.search(wc_request.path)
- if m:
- return self.render_domain(m.group(1))
- else:
- return self.render_main()
-
- def render_main(self):
- s = banner(self)
- s += "<table border='1'>\n"
- s += "<tr>\n"
- s += "<th>Domain</th>"
- for path, title in self.stats_mainpage:
- s += "<th>%s</th>" % title
- s += "</tr>\n"
- for domain in spiders.asdict().keys():
- s += "<tr>\n"
- s += "<td><a href='%s'>%s</a></td>" % (domain, domain)
- for path, title in self.stats_mainpage:
- stat = self.ddh.getlast(domain, path=path)
- value = stat[1] if stat else "None"
- s += "<td>%s</td>" % value
- s += "</tr>\n"
- s += "</table>\n"
- s += "</body>\n"
- s += "</html>\n"
-
- return str(s)
-
- def render_domain(self, domain):
- s = banner(self)
- stats = self.ddh.getall(domain)
- s += "<pre>\n"
- s += pprint.pformat(list(stats))
- s += "</pre>\n"
- s += "</body>\n"
- s += "</html>\n"
-
- return str(s)
-
- def webconsole_discover_module(self):
- return self
diff --git a/scrapy/trunk/scrapy/contrib/webconsole/stats.py b/scrapy/trunk/scrapy/contrib/webconsole/stats.py
deleted file mode 100644
index f58cb50e8..000000000
--- a/scrapy/trunk/scrapy/contrib/webconsole/stats.py
+++ /dev/null
@@ -1,26 +0,0 @@
-import pprint
-
-from pydispatch import dispatcher
-
-from scrapy.stats import stats
-from scrapy.management.web import banner, webconsole_discover_module
-
-class StatsDump(object):
- webconsole_id = 'stats'
- webconsole_name = 'StatsCollector dump'
-
- def __init__(self):
- dispatcher.connect(self.webconsole_discover_module, signal=webconsole_discover_module)
-
- def webconsole_render(self, wc_request):
- s = banner(self)
- s += "<pre><code>\n"
- s += pprint.pformat(stats)
- s += "</pre></code>\n"
- s += "</body>\n"
- s += "</html>\n"
-
- return str(s)
-
- def webconsole_discover_module(self):
- return self
diff --git a/scrapy/trunk/scrapy/contrib_exp/downloadermiddleware/__init__.py b/scrapy/trunk/scrapy/contrib_exp/downloadermiddleware/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/contrib_exp/history/__init__.py b/scrapy/trunk/scrapy/contrib_exp/history/__init__.py
deleted file mode 100644
index 81eb201d6..000000000
--- a/scrapy/trunk/scrapy/contrib_exp/history/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from scrapy.contrib.history.history import ItemHistory
-from scrapy.contrib.history.scheduler import RulesScheduler
-from scrapy.contrib.history.store import SQLHistoryStore
diff --git a/scrapy/trunk/scrapy/contrib_exp/history/history.py b/scrapy/trunk/scrapy/contrib_exp/history/history.py
deleted file mode 100644
index 6767ef260..000000000
--- a/scrapy/trunk/scrapy/contrib_exp/history/history.py
+++ /dev/null
@@ -1,162 +0,0 @@
-"""
-History management
-"""
-import re
-from datetime import datetime
-
-import MySQLdb
-
-class History(object):
- """Base class for tracking different kinds of histories"""
-
- def __init__(self, db_uri):
- self.db_uri = db_uri
- self._mysql_conn = None
-
- def connect(self):
- """
- Connect to PDB and open mysql connect to PRODUCT_DB
- """
- m = re.search(r"mysql:\/\/(?P<user>[^:]+)(:(?P<passwd>[^@]+))?@(?P<host>[^/]+)/(?P<db>.*)$", self.db_uri)
- if m:
- d = m.groupdict()
- if d['passwd'] is None:
- del(d['passwd'])
-
- d['charset'] = "utf8"
- self._mysql_conn = MySQLdb.connect(**d)
-
- def get_mysql_conn(self):
- if self._mysql_conn is None:
- self.connect()
- return self._mysql_conn
- mysql_conn = property(get_mysql_conn)
-
-
-class ItemHistory(History):
- """
- Class instance registers item guids, and versions with check_item method.
- It also gives access to stored ItemTicket and ItemVersion objects.
- """
- NEW = 0
- UPDATE = 1
- DUPLICATE = 2
-
- def check_item(self, domain, item):
- """
- Store item's guid and version to the database along
- with date and time of last occurence.
- Return:
- * ItemHistory.NEW - if guid hasn't been met
- * ItemHistory.UPDATE - if history already contains guid, but versions doesn't match
- * ItemHistory.DUPLICATE - both guid and version are not new
- """
- version = item.version
-
- c = self.mysql_conn.cursor(MySQLdb.cursors.DictCursor)
-
- def add_version(version):
- insert = "INSERT INTO version (guid, version, seen) VALUES (%s,%s,%s)"
- c.execute(insert, (item.guid, version, datetime.now()))
-
- select = "SELECT * FROM ticket WHERE guid=%s"
- c.execute(select, item.guid)
- r = c.fetchone()
- if r:
- select = "SELECT * FROM version WHERE version=%s"
- if c.execute(select, version):
- update = "UPDATE version SET seen=%s WHERE version=%s"
- c.execute(update, (datetime.now(), version))
- self.mysql_conn.commit()
- return ItemHistory.DUPLICATE
- else:
- add_version(version)
- self.mysql_conn.commit()
- return ItemHistory.UPDATE
- else:
- insert = "INSERT INTO ticket (guid, domain, url, url_hash) VALUES (%s,%s,%s,%s)"
- c.execute(insert, (item.guid, domain, item.url, hash(item.url)))
- add_version(version)
- self.mysql_conn.commit()
- return ItemHistory.NEW
-
- def get_ticket(self, guid):
- """
- Return ItemTicket object for guid.
- ItemVersion objects can be accessed via 'versions' list.
- """
- c = self.mysql_conn.cursor(MySQLdb.cursors.DictCursor)
- select = "SELECT * FROM ticket WHERE guid=%s"
- c.execute(select, guid)
- ticket = c.fetchone()
- if not ticket:
- raise Exception("Item ticket with guid = '%s' not found" % guid)
- ticket['versions'] = []
- select = "SELECT * FROM version WHERE guid=%s"
- c.execute(select, guid)
- for version in c.fetchall():
- ticket['versions'].append(version)
- return ticket
-
- def delete_ticket(self, guid):
- """Delete item ticket and associated versions from DB"""
- c = self.mysql_conn.cursor()
- delete = "DELETE FROM ticket WHERE guid=%s"
- c.execute(delete, guid)
- self.mysql_conn.commit()
-
-
-class URLHistory(History):
- """
- Access URL status and history for the scraping engine
-
- This is degsigned to have an instance per domain where typically
- a call will be made to get_url_status, followed by either
- update_checked or record_version.
- """
-
- def get_url_status(self, urlkey):
- """
- Get the url status (url, last_version, last_checked),
- or None if the url data has not been seen before
- """
- c = self.mysql_conn.cursor(MySQLdb.cursors.DictCursor)
- select = "SELECT * FROM url_status WHERE url_hash=%s"
- c.execute(select, urlkey)
- r = c.fetchone()
- return (r['url'], r['last_version'], r['last_checked']) if r else None
-
- def record_version(self, urlkey, url, parent_key, version, postdata_hash=None):
- """
- Record a version of a page and update the last checked time.
-
- If the same version (or None) is passed, the last checked time is still updated.
- """
- now = datetime.now()
- c = self.mysql_conn.cursor(MySQLdb.cursors.DictCursor)
- select = "SELECT * FROM url_status WHERE url_hash=%s"
- c.execute(select, urlkey)
- r = c.fetchone()
-
- if not r:
- insert = "INSERT INTO url_status (url_hash, url, parent_hash, last_version, last_checked) VALUES (%s,%s,%s,%s,%s)"
- c.execute(insert, (urlkey, url, parent_key, version, now))
- else:
- update = "UPDATE url_status SET last_version=%s, last_checked=%s WHERE url_hash=%s"
- c.execute(update, (version, now, urlkey))
- self.mysql_conn.commit()
-
- last_version = r['last_version'] if r else None
- if version and version != last_version:
- if not c.execute("SELECT url_hash FROM url_history WHERE version=%s", version):
- insert = "INSERT INTO url_history (url_hash, version, postdata_hash, created) VALUES (%s,%s,%s,%s)"
- c.execute(insert, (urlkey, version, postdata_hash, now))
- self.mysql_conn.commit()
-
- def get_version_info(self, version):
- """Simple accessor method"""
- c = self.mysql_conn.cursor(MySQLdb.cursors.DictCursor)
- select = "SELECT * FROM url_history WHERE version=%s"
- c.execute(select, version)
- r = c.fetchone()
- return (r['url_hash'], r['created']) if r else None
diff --git a/scrapy/trunk/scrapy/contrib_exp/history/store.py b/scrapy/trunk/scrapy/contrib_exp/history/store.py
deleted file mode 100644
index bd9d01681..000000000
--- a/scrapy/trunk/scrapy/contrib_exp/history/store.py
+++ /dev/null
@@ -1,47 +0,0 @@
-"""
-SQLHistoryStore
-
-Persistent history storage using relational database
-"""
-from scrapy.contrib.history.history import URLHistory
-from scrapy import log
-from scrapy.conf import settings
-
-class SQLHistoryStore(object) :
- """Implementation of a data store that stores information in a relation
- database
-
- This maintains a URLHistory object per site. That means each domain
- has it's own session and is isolated from the others.
- """
-
- def __init__(self):
- self._store = {}
- self._dbinfo = settings['SCRAPING_DB']
- self._debug = settings['DEBUG_SQL_HISTORY_STORE']
-
- def open(self, site):
- self._store[site] = URLHistory(self._dbinfo)
-
- def close_site(self, site):
- self._store[site].close()
- del self._store[site]
-
- def store(self, site, key, url, parent=None, version=None, post_version=None):
- history = self._store[site]
- if self._debug:
- log.msg("record_version(key=%s, url=%s, parent=%s, version=%s, post_version=%s)" %
- (key, url, parent, version, post_version), domain=site, level=log.DEBUG)
- history.record_version(key, url, parent, version, post_version)
-
- def has_site(self, site):
- return site in self._store
-
- def status(self, site, key):
- if site in self._store:
- history = self._store[site]
- return history.get_url_status(key)
-
- def version_info(self, site, version):
- history = self._store[site]
- return history.get_version_info(version)
diff --git a/scrapy/trunk/scrapy/core/__init__.py b/scrapy/trunk/scrapy/core/__init__.py
deleted file mode 100644
index 59e07e643..000000000
--- a/scrapy/trunk/scrapy/core/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-"""
-Scrapy core library classes and functions.
-"""
diff --git a/scrapy/trunk/scrapy/core/downloader/__init__.py b/scrapy/trunk/scrapy/core/downloader/__init__.py
deleted file mode 100644
index cecc64c8e..000000000
--- a/scrapy/trunk/scrapy/core/downloader/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from scrapy.core.downloader.manager import Downloader
diff --git a/scrapy/trunk/scrapy/core/prioritizers.py b/scrapy/trunk/scrapy/core/prioritizers.py
deleted file mode 100644
index 214a475a3..000000000
--- a/scrapy/trunk/scrapy/core/prioritizers.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""
-The Prioritizer is a class which receives a list of elements and prioritizes
-it. It's used for defining the order in which domains are to be scraped.
-
-A Prioritizer basically consists of a class which receives a list of elements
-in its constructs and contains only one method: get_priority() which returns
-the priority of the given element. The element passed to get_priority() must
-exists in the list of elements passed in the constructor.
-
-This module contains several basic prioritizers.
-
-For more advanced prioritizers see: scrapy.contrib.prioritizers
-"""
-import random
-
-class NullPrioritizer(object):
- """
- This prioritizer always return the same priority (1)
- """
- def __init__(self, elements):
- pass
-
- def get_priority(self, element):
- return 1
-
-class RandomPrioritizer(object):
- """
- This prioritizer always return a random priority
- """
- def __init__(self, elements):
- self.count = len(elements)
-
- def get_priority(self, element):
- return random.randrange(0, self.count)
-
-class AlphabeticPrioritizer(object):
- """
- This prioritizer priotizes based on the alphabetic order of the element
- """
- def __init__(self, elements):
- self.elements = elements[:]
- self.elements.sort()
-
- def get_priority(self, element):
- return self.elements.index(element)
diff --git a/scrapy/trunk/scrapy/core/scheduler/store.py b/scrapy/trunk/scrapy/core/scheduler/store.py
deleted file mode 100644
index b7eddfcf4..000000000
--- a/scrapy/trunk/scrapy/core/scheduler/store.py
+++ /dev/null
@@ -1,35 +0,0 @@
-"""
-The datastore module contains implementations of data storage engines for the
-crawling process. These are used to track metrics on each site and on each
-page visited.
-"""
-from datetime import datetime
-
-class MemoryStore(object) :
- """Simple implementation of a data store. This is useful if no persistent
- history is required (e.g. unit testing or development) and provides a
- simpler reference implementation.
- """
- def __init__(self) :
- """The store will just be a dict with an entry for each site, that
- entry will contain dicts and lists of data.
- """
- self._store = {}
-
- def open(self, site):
- self._store[site] = {}
-
- def close_site(self, site):
- del self._store[site]
-
- def store(self, site, key, url, parent=None, version=None, post_version=None):
- checked = datetime.now()
- self._store[key] = (version, checked)
-
- def status(self, site, key):
- """Get the version and last checked time for a key.
-
- this will be changed later to support checking (lazily) the last modified
- time and perhaps other statistics needed by the scheduling algorithms
- """
- return self._store.get(key)
diff --git a/scrapy/trunk/scrapy/fetcher/__init__.py b/scrapy/trunk/scrapy/fetcher/__init__.py
deleted file mode 100644
index 29fbde74a..000000000
--- a/scrapy/trunk/scrapy/fetcher/__init__.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import urlparse
-
-from scrapy.spider import spiders
-from scrapy.http import Request
-from scrapy.core.manager import scrapymanager
-from scrapy.spider import BaseSpider
-
-def fetch(urls, perdomain=False):
- """Download a set of urls. This is starts a reactor and is suitable
- for calling from a main method - not for calling from within the
- framework.
-
- It will return a list of Response objects for all pages successfully
- downloaded.
- """
- bigbucket = {} # big bucket to store response objects (per domain)
-
- def _add(response, domain):
- if not domain in bigbucket:
- bigbucket[domain] = []
- bigbucket[domain] += [response]
-
- # url clasification by domain
- requestdata = set()
- for url in urls:
- domain = get_or_create_spider(url).domain_name
- request = Request(url=url, callback=lambda r: _add(r, domain), dont_filter=True)
- requestdata.add(request)
-
- scrapymanager.runonce(*requestdata)
-
- # returns bigbucket as dict or flatted
- if perdomain:
- return bigbucket
-
- flatbucket = []
- for domain, responses in bigbucket.iteritems():
- flatbucket.extend(responses)
- return flatbucket
-
-
-def get_or_create_spider(url):
- # dirty hack to allow downloading pages from unknown domains
- spider = spiders.fromurl(url)
- if not spider:
- domain = str(urlparse.urlparse(url).hostname or spiders.default_domain)
- spider = BaseSpider()
- spider.domain_name = domain
- spiders._alldict[domain] = spider
- return spider
-
diff --git a/scrapy/trunk/scrapy/http/url.py b/scrapy/trunk/scrapy/http/url.py
deleted file mode 100644
index 098150be1..000000000
--- a/scrapy/trunk/scrapy/http/url.py
+++ /dev/null
@@ -1,57 +0,0 @@
-"""
-The Url class is similar to the urlparse.ParseResult class (it has the same
-attributes) with the following differences:
-
-- it inherits from str
-- it's lazy, so it only parses the url when needed
-"""
-
-import urlparse
-
-class Url(str):
-
- @property
- def parsedurl(self):
- if not hasattr(self, '_parsedurl'):
- self._parsedurl = urlparse.urlparse(self)
- return self._parsedurl
-
- @property
- def scheme(self):
- return self.parsedurl.scheme
-
- @property
- def netloc(self):
- return self.parsedurl.netloc
-
- @property
- def path(self):
- return self.parsedurl.path
-
- @property
- def params(self):
- return self.parsedurl.params
-
- @property
- def query(self):
- return self.parsedurl.query
-
- @property
- def fragment(self):
- return self.parsedurl.fragment
-
- @property
- def username(self):
- return self.parsedurl.username
-
- @property
- def password(self):
- return self.parsedurl.password
-
- @property
- def hostname(self):
- return self.parsedurl.hostname
-
- @property
- def port(self):
- return self.parsedurl.port
diff --git a/scrapy/trunk/scrapy/management/__init__.py b/scrapy/trunk/scrapy/management/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/management/telnet.py b/scrapy/trunk/scrapy/management/telnet.py
deleted file mode 100644
index 52178785c..000000000
--- a/scrapy/trunk/scrapy/management/telnet.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import pprint
-
-from twisted.internet import reactor
-from twisted.conch import manhole, telnet
-from twisted.conch.insults import insults
-from twisted.internet import protocol
-
-from scrapy.extension import extensions
-from scrapy.core.manager import scrapymanager
-from scrapy.core.engine import scrapyengine
-from scrapy.stats import stats
-from scrapy.conf import settings
-
-try:
- import guppy
- hpy = guppy.hpy()
-except ImportError:
- hpy = None
-
-telnet_namespace = {'ee': scrapyengine,
- 'em': scrapymanager,
- 'ex': extensions.enabled,
- 'st': stats,
- 'h': hpy,
- 'p': pprint.pprint} # useful shortcut for debugging
-
-def makeProtocol():
- return telnet.TelnetTransport(telnet.TelnetBootstrapProtocol,
- insults.ServerProtocol,
- manhole.Manhole, telnet_namespace)
-
-class TelnetConsole(protocol.ServerFactory):
-
- def __init__(self):
- if not settings.getbool('TELNETCONSOLE_ENABLED'):
- return
-
- #protocol.ServerFactory.__init__(self)
- self.protocol = makeProtocol
- self.noisy = False
- port = settings.getint('TELNETCONSOLE_PORT')
- scrapyengine.listenTCP(port, self)
diff --git a/scrapy/trunk/scrapy/patches/__init__.py b/scrapy/trunk/scrapy/patches/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/spider/__init__.py b/scrapy/trunk/scrapy/spider/__init__.py
deleted file mode 100644
index 2a88816de..000000000
--- a/scrapy/trunk/scrapy/spider/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from scrapy.spider.models import BaseSpider
-from scrapy.spider.manager import SpiderManager
-
-spiders = SpiderManager()
diff --git a/scrapy/trunk/scrapy/stats/__init__.py b/scrapy/trunk/scrapy/stats/__init__.py
deleted file mode 100644
index 2b2b2fb61..000000000
--- a/scrapy/trunk/scrapy/stats/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from scrapy.stats.statscollector import StatsCollector
-
-stats = StatsCollector()
diff --git a/scrapy/trunk/scrapy/stats/statscollector.py b/scrapy/trunk/scrapy/stats/statscollector.py
deleted file mode 100644
index 2ff1f3e37..000000000
--- a/scrapy/trunk/scrapy/stats/statscollector.py
+++ /dev/null
@@ -1,77 +0,0 @@
-"""
-Scrapy extension for collecting scraping stats
-"""
-import pprint
-
-from pydispatch import dispatcher
-
-from scrapy.core import signals
-from scrapy import log
-from scrapy.utils.misc import stats_getpath
-from scrapy.conf import settings
-
-class StatsCollector(dict):
- # signal sent after a domain is opened for stats collection and its resorces have been allocated. args: domain
- domain_open = object()
- # signal sent before a domain is closed, and before the stats are persisted. it can be catched to add additional stats. args: domain
- domain_closing = object()
- # signal sent after a domain is closed and its resources have been freed. args: domain
- domain_closed = object()
-
- def __init__(self, enabled=None):
- self.db = None
- self.debug = settings.getbool('STATS_DEBUG')
- self.enabled = enabled if enabled is not None else settings.getbool('STATS_ENABLED')
- self.cleanup = settings.getbool('STATS_CLEANUP')
-
- if self.enabled:
- if settings['SCRAPING_DB']:
- from scrapy.store.db import DomainDataHistory
- self.db = DomainDataHistory(settings['SCRAPING_DB'], table_name='domain_data_history')
-
- dispatcher.connect(self._domain_open, signal=signals.domain_open)
- dispatcher.connect(self._domain_closed, signal=signals.domain_closed)
- else:
- self.setpath = lambda *args, **kwargs: None
- self.getpath = lambda path, default=None: default
- self.incpath = lambda *args, **kwargs: None
- self.delpath = lambda *args, **kwargs: None
-
- def setpath(self, path, value):
- d = self
- keys = path.split('/')
- for key in keys[:-1]:
- if key not in d:
- d[key] = {}
- d = d[key]
- d[keys[-1]] = value
-
- def getpath(self, path, default=None):
- return stats_getpath(self, path, default)
-
- def delpath(self, path):
- d = self
- keys = path.split('/')
- for key in keys[:-1]:
- if key in d:
- d = d[key]
- else:
- return
- del d[keys[-1]]
-
- def incpath(self, path, value_diff=1):
- curvalue = self.getpath(path) or 0
- self.setpath(path, curvalue + value_diff)
-
- def _domain_open(self, domain, spider):
- dispatcher.send(signal=self.domain_open, sender=self.__class__, domain=domain, spider=spider)
-
- def _domain_closed(self, domain, spider, status):
- dispatcher.send(signal=self.domain_closing, sender=self.__class__, domain=domain, spider=spider, status=status)
- if self.debug:
- log.msg(pprint.pformat(self[domain]), domain=domain, level=log.DEBUG)
- if self.db:
- self.db.put(domain, self[domain])
- if self.cleanup:
- del self[domain]
- dispatcher.send(signal=self.domain_closed, sender=self.__class__, domain=domain, spider=spider, status=status)
diff --git a/scrapy/trunk/scrapy/store/__init__.py b/scrapy/trunk/scrapy/store/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/store/db.py b/scrapy/trunk/scrapy/store/db.py
deleted file mode 100644
index f38e6edda..000000000
--- a/scrapy/trunk/scrapy/store/db.py
+++ /dev/null
@@ -1,130 +0,0 @@
-"""
-Store implementations using a MySQL DB
-"""
-import cPickle as pickle
-from datetime import datetime
-
-from scrapy.utils.misc import stats_getpath
-from scrapy.utils.db import mysql_connect
-
-class DomainDataHistory(object):
- """
- This is a store for domain data, with history.
- """
-
- def __init__(self, db_uri, table_name):
- self.db_uri = db_uri
- self._mysql_conn = None
- self._table = table_name
-
- def get_mysql_conn(self):
- if self._mysql_conn is None:
- self._mysql_conn = mysql_connect(self.db_uri, use_unicode=False)
- return self._mysql_conn
- mysql_conn = property(get_mysql_conn)
-
- def get(self, domain, count=1, offset=0, stored_after=None, stored_before=None, path=None):
- """
- Get the last records stored for the given domain.
- If count is given that number of records is retunred, otherwise all records.
- If stored_{after,before} is given the results are restricted to that time interval.
- The result is a list of tuples: (timestamp, data)
- If path is given it only returns stats of that given path (only for dict objects like stats)
- """
- sqlsuf = ""
- if count is not None:
- sqlsuf += "LIMIT %d " % count
- if offset:
- sqlsuf += "OFFSET %d " % offset
- filter = ""
- if stored_after:
- filter += "AND stored>='%s'" % stored_after.strftime("%Y-%m-%d %H:%M:%S")
- if stored_before:
- filter += "AND stored<='%s'" % stored_before.strftime("%Y-%m-%d %H:%M:%S")
-
- c = self.mysql_conn.cursor()
- select = "SELECT stored,data FROM %s WHERE domain=%%s %s ORDER BY stored DESC %s" % (self._table, filter, sqlsuf)
- c.execute(select, domain)
- for stored, datas in c:
- obj = pickle.loads(datas)
- if path and isinstance(obj, dict):
- yield stored, stats_getpath(obj, path)
- else:
- yield stored, obj
-
- def getlast(self, domain, offset=0, path=None):
- """
- Get the Nth last data stored for the given domain
- If offset=0 get the last data stored
- If offset=1 get the previous data stored
- ...and so on
- """
- datal = list(self.get(domain, count=1, offset=offset, path=path))
- if datal:
- return datal[0]
-
- def getall(self, domain, path=None):
- """
- Get all data stored for the given domain as a list of tuples:
- (stored, timestamp)
- """
- return self.get(domain, count=None, path=path)
-
- def getlast_alldomains(self, count=None, offset=None, order='domain', olist='ASC', path=None):
- """
- Get all last data for all domains as a list of tuples, unless
- data is sliced by count and offset values.
- Ordered by domain is the default.
- TODO: This could be merged with: get(domain=None, ..., +order)
-
- Return a list of tuples (domain, timestamp, data)
- """
- sqlsuf = ""
- if count is not None:
- sqlsuf += "LIMIT %s " % count
- if offset:
- sqlsuf += "OFFSET %s " % offset
-
- c = self.mysql_conn.cursor()
- select = "SELECT domain, MAX(stored) as stored, data \
- FROM ( \
- SELECT * FROM %s ORDER BY stored DESC \
- ) AS inner_ordered \
- GROUP BY domain \
- ORDER BY %s %s %s" % (self._table, order, olist, sqlsuf)
- c.execute(select)
- for domain, stored, datas in c:
- obj = pickle.loads(datas)
- if path and isinstance(obj, dict):
- yield domain, stored, stats_getpath(obj, path)
- else:
- yield domain, stored, obj
-
- def domain_count(self):
- """
- Return the number of domains stored in the database
- """
- c = self.mysql_conn.cursor()
- c.execute("SELECT COUNT(DISTINCT(domain)) FROM %s" % self._table)
- return c.fetchone()[0]
-
- def put(self, domain, data, timestamp=None):
- """
- Store data in history using the given timestamp (or now if omitted).
- data can be any pickable object
- """
- stored = timestamp if timestamp else datetime.now()
- datas = pickle.dumps(data)
-
- c = self.mysql_conn.cursor()
- c.execute("INSERT INTO %s (domain,stored,data) VALUES (%%s,%%s,%%s)" % self._table, (domain, stored, datas))
- self.mysql_conn.commit()
-
- def remove(self, domain):
- """
- Remove all data stored for the given domain
- """
- c = self.mysql_conn.cursor()
- c.execute("DELETE FROM %s WHERE domain=%%s" % self._table, domain)
- self.mysql_conn.commit()
-
diff --git a/scrapy/trunk/scrapy/templates/project/module/__init__.py b/scrapy/trunk/scrapy/templates/project/module/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/templates/project/module/spiders/__init__.py b/scrapy/trunk/scrapy/templates/project/module/spiders/__init__.py
deleted file mode 100644
index 59d02a55f..000000000
--- a/scrapy/trunk/scrapy/templates/project/module/spiders/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# Place here all your scrapy spiders
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.tar b/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.tar
deleted file mode 100644
index 361751ec2..000000000
Binary files a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.tar and /dev/null differ
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml b/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml
deleted file mode 100644
index 7849e5631..000000000
--- a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
- <products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://path_to_scrape.xsd"><!-- THIS MUST BE SET FOR VALIDATION TO WORK IN YOUR IDE -->
-
- <product id="17685">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_twice_as_mice_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Twice As Mice]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_twice_as_mice.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[no]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17682">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_cuddles_mounted_and_framed_picture]]></url>
- <name><![CDATA[Mounted And Framed Picture: Cuddles]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_cuddles.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Home Accessories]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17683">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_playtime_mounted_and_framed_picture]]></url>
- <name><![CDATA[Mounted And Framed Picture: Playtime]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_playtime.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17686">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_hat_trick_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Hat Trick]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_hat_trick.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17689">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_happy_cat_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Happy Cat]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_happy_cat.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17691">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_quiet_night_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Quiet Night]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_quiet_night.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>An original and delightful christening gift , perfect nursery decoration. </p><p>FREE hand finished, &quot;Quiet night&quot; greeting card included!</p><p>Picture can be personalised! </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;). </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17692">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_sunshine_lullaby_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Sunshine Lullaby]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_sunshine_lullaby.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>An original and delightful christening gift , perfect nursery decoration. </p><p>FREE hand finished, &quot;Sunshine lullaby&quot; greeting card included!</p><p>Picture can be personalised! </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;). </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17693">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_tiddlywinks_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Tiddlywinks]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_tiddlywinks.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- </products>
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml.bz2 b/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml.bz2
deleted file mode 100644
index 245c7846a..000000000
Binary files a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml.bz2 and /dev/null differ
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml.gz b/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml.gz
deleted file mode 100644
index c59ba8f05..000000000
Binary files a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.xml.gz and /dev/null differ
diff --git a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.zip b/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.zip
deleted file mode 100644
index f1c35af34..000000000
Binary files a/scrapy/trunk/scrapy/tests/sample_data/compressed/feed-sample1.zip and /dev/null differ
diff --git a/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample1.xml b/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample1.xml
deleted file mode 100644
index 7849e5631..000000000
--- a/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample1.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
- <products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://path_to_scrape.xsd"><!-- THIS MUST BE SET FOR VALIDATION TO WORK IN YOUR IDE -->
-
- <product id="17685">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_twice_as_mice_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Twice As Mice]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_twice_as_mice.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[no]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17682">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_cuddles_mounted_and_framed_picture]]></url>
- <name><![CDATA[Mounted And Framed Picture: Cuddles]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_cuddles.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Home Accessories]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17683">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_playtime_mounted_and_framed_picture]]></url>
- <name><![CDATA[Mounted And Framed Picture: Playtime]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_playtime.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17686">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_hat_trick_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Hat Trick]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_hat_trick.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17689">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_happy_cat_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Happy Cat]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_happy_cat.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17691">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_quiet_night_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Quiet Night]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_quiet_night.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>An original and delightful christening gift , perfect nursery decoration. </p><p>FREE hand finished, &quot;Quiet night&quot; greeting card included!</p><p>Picture can be personalised! </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;). </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17692">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_sunshine_lullaby_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Sunshine Lullaby]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_sunshine_lullaby.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>An original and delightful christening gift , perfect nursery decoration. </p><p>FREE hand finished, &quot;Sunshine lullaby&quot; greeting card included!</p><p>Picture can be personalised! </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;). </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- <product id="17693">
- <url><![CDATA[http://www.example.com/agathajasinskagallery/product/_tiddlywinks_]]></url>
- <name><![CDATA[Mounted And Framed Picture: Tiddlywinks]]></name>
- <image_url><![CDATA[http://www.example.com/uploads/partners/agathajasinskagallery/500/a_tiddlywinks.jpg]]></image_url>
- <price>28.00</price>
- <availability><![CDATA[yes]]></availability>
- <supplier><![CDATA[example.com]]></supplier>
- <designer><![CDATA[Agatha Jasinska Gallery]]></designer>
- <description><![CDATA[<p>Beautiful, open edition giclee print from Agatha's original watercolours, reprinted onto watercolour paper, reproducing all the qualities of the original painting. </p><p>The print is conservation mounted and individually signed by the artist.</p><p>Picture can be personalised! </p><p>An original and delightful gift, perfect as a bedroom or nursery decoration. (Especially pleasing for any cat lover!) </p><p>Picture size: 17cm x 17cm Framed picture size: 30cm x 30cm (12&quot; x 12&quot;) </p>]]></description>
- <category><![CDATA[Art]]></category>
- <delivery_within><![CDATA[1-2 days]]></delivery_within>
- </product>
- </products>
diff --git a/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample2.xml b/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample2.xml
deleted file mode 100644
index 0261ae903..000000000
--- a/scrapy/trunk/scrapy/tests/sample_data/feeds/feed-sample2.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0"?>
-<rss version ="2.0"
-xmlns:g="http://base.google.com/ns/1.0">
-<channel>
-<title>Example.com</title>
-<description>Example.com</description>
-<link>http://www.example.com/</link>
-<item><title>Abadeh 7500.924 - 67cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt; </description>
-<link>http://www.example.com/product.asp?P_ID=1602</link>
-<g:image_link>http://www.example.com/uploads/images_products/1602.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>69</g:price>
-</item>
-<item><title>Abadeh 7500.924 - 83cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt; </description>
-<link>http://www.example.com/product.asp?P_ID=1602</link>
-<g:image_link>http://www.example.com/uploads/images_products/1602.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>89</g:price>
-</item>
-<item><title>Abadeh 7500.929 - 83cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1603</link>
-<g:image_link>http://www.example.com/uploads/images_products/1603.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>89</g:price>
-</item>
-<item><title>Abadeh 7500.929 - 67cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1603</link>
-<g:image_link>http://www.example.com/uploads/images_products/1603.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>69</g:price>
-</item>
-<item><title>Abadeh 7500.938 - 67cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1604</link>
-<g:image_link>http://www.example.com/uploads/images_products/1604.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>69</g:price>
-</item>
-<item><title>Abadeh 7500.938 - 83cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1604</link>
-<g:image_link>http://www.example.com/uploads/images_products/1604.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>89</g:price>
-</item>
-<item><title>Abadeh 7500.944 - 83cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1605</link>
-<g:image_link>http://www.example.com/uploads/images_products/1605.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>89</g:price>
-</item>
-<item><title>Abadeh 7500.944 - 67cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1605</link>
-<g:image_link>http://www.example.com/uploads/images_products/1605.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>69</g:price>
-</item>
-<item><title>Abadeh 7501.938 - 67cm Wide </title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=939</link>
-<g:image_link>http://www.example.com/uploads/images_products/939.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>69</g:price>
-</item>
-<item><title>Abadeh 7501.938 - 83cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=939</link>
-<g:image_link>http://www.example.com/uploads/images_products/939.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>89</g:price>
-</item>
-<item><title>Abadeh 7501.958 - 83cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1606</link>
-<g:image_link>http://www.example.com/uploads/images_products/1606.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>89</g:price>
-</item>
-<item><title>Abadeh 7501.958 - 67cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt;</description>
-<link>http://www.example.com/product.asp?P_ID=1606</link>
-<g:image_link>http://www.example.com/uploads/images_products/1606.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>69</g:price>
-</item>
-<item><title>Abadeh 7502.938 - 67cm Wide</title>
-<description>&lt;strong&gt;Price shown per linear metre&lt;br&gt;&lt;br&gt;Minimum purchase 3 linear metres&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Quantity discounts available on 30m rolls.&lt;br&gt;&lt;br&gt; </description>
-<link>http://www.example.com/product.asp?P_ID=936</link>
-<g:image_link>http://www.example.com/uploads/images_products/936.jpg</g:image_link>
-<label>Traditional Stairs</label>
-<g:price>69</g:price>
-</item>
-</channel>
-</rss>
diff --git a/scrapy/trunk/scrapy/tests/sample_data/test_site/index.html b/scrapy/trunk/scrapy/tests/sample_data/test_site/index.html
deleted file mode 100644
index d268c846a..000000000
--- a/scrapy/trunk/scrapy/tests/sample_data/test_site/index.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<html>
-
-<head>
-<title>Scrapy test site</title>
-</head>
-
-<body>
-
-<h1>Scrapy test site</h1>
-
-<ul>
-<li><a href="item1.html">Item 1</li>
-<li><a href="item2.html">Item 2</li>
-<li><a href="item999.html">Item 999 (not found)</li>
-</ul>
-
-</body>
-</html>
diff --git a/scrapy/trunk/scrapy/tests/sample_data/test_site/item1.html b/scrapy/trunk/scrapy/tests/sample_data/test_site/item1.html
deleted file mode 100644
index ceeb6dc87..000000000
--- a/scrapy/trunk/scrapy/tests/sample_data/test_site/item1.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<html>
-
-<head>
-<title>Item 1 - Scrapy test site</title>
-</head>
-
-<body>
-
-<h1>Item 1 name</h1>
-
-<ul>
-<li>Price: $100</li>
-<li>Stock: 12</li>
-</ul>
-
-</body>
-</html>
diff --git a/scrapy/trunk/scrapy/tests/sample_data/test_site/item2.html b/scrapy/trunk/scrapy/tests/sample_data/test_site/item2.html
deleted file mode 100644
index a64c92810..000000000
--- a/scrapy/trunk/scrapy/tests/sample_data/test_site/item2.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<html>
-
-<head>
-<title>Item 2 - Scrapy test site</title>
-</head>
-
-<body>
-
-<h1>Item 2 name</h1>
-
-<ul>
-<li>Price: $200</li>
-<li>Stock: 5</li>
-</ul>
-
-</body>
-</html>
diff --git a/scrapy/trunk/scrapy/tests/test_c14nurls.py b/scrapy/trunk/scrapy/tests/test_c14nurls.py
deleted file mode 100644
index e0a8e8166..000000000
--- a/scrapy/trunk/scrapy/tests/test_c14nurls.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import unittest
-from scrapy.utils.c14n import canonicalize
-
-class C14nTest(unittest.TestCase):
- """ c14n comparison functions """
-
- def test_canonicalize(self):
- """Test URL canonicalization function"""
- urls = [
- ('http://www.maddiebrown.co.uk//cgi-bin//html_parser.cgi?web_page_id=12&template_file=catalogue_list_items_template&category-id=1000070&category-type=1&page=3&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2&page=2',
- 'http://www.maddiebrown.co.uk//cgi-bin//html_parser.cgi?web_page_id=12&template_file=catalogue_list_items_template&category-id=1000070&category-type=1&page=3&page=2'),
-
-
- ('http://www.mfi.co.uk/mfi/productinfo.asp?CT=/1010/YourHomeOffice&CT=/1025/YourHomeOffice/Packages',
- 'http://www.mfi.co.uk/mfi/productinfo.asp?CT=/1010/YourHomeOffice&CT=/1025/YourHomeOffice/Packages'),
-
- ('http://www.test-nice-url.com/index.html',
- 'http://www.test-nice-url.com/index.html'),
-
- ('http://www.homebase.co.uk/webapp/wcs/stores/servlet/ProductDisplay?storeId=20001&langId=-1&catalogId=10701&productId=729482&Trail=C$cip=50704&categoryId=50704',
- 'http://www.homebase.co.uk/webapp/wcs/stores/servlet/ProductDisplay?storeId=20001&langId=-1&catalogId=10701&productId=729482&Trail=C$cip=50704&categoryId=50704'),
- ]
- for origurl, c14nurl in urls:
- self.assertEqual(canonicalize(origurl), c14nurl)
-
-if __name__ == "__main__":
- unittest.main()
-
diff --git a/scrapy/trunk/scrapy/tests/test_dependencies.py b/scrapy/trunk/scrapy/tests/test_dependencies.py
deleted file mode 100644
index 5109edee8..000000000
--- a/scrapy/trunk/scrapy/tests/test_dependencies.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from unittest import TestCase, main
-
-class ScrapyUtilsTest(TestCase):
- def test_openssl(self):
- try:
- module = __import__('OpenSSL', {}, {}, [''])
- except ImportError, ex:
- return # no openssl installed
-
- required_version = '0.6'
- if hasattr(module, '__version__'):
- for cur, req in zip(module.__version__.split('.'), required_version.split('.')):
- self.assertFalse(cur < req, "module %s >= %s required" % ('OpenSSL', required_version))
-
-if __name__ == "__main__":
- main()
diff --git a/scrapy/trunk/scrapy/tests/test_spidermonkey.py b/scrapy/trunk/scrapy/tests/test_spidermonkey.py
deleted file mode 100644
index 52b753d32..000000000
--- a/scrapy/trunk/scrapy/tests/test_spidermonkey.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from twisted.trial import unittest
-
-class SpidermonkeyTest(unittest.TestCase):
-
- def setUp(self):
- try:
- from spidermonkey import Runtime
- r = Runtime()
- self.cx = r.new_context()
- except ImportError:
- raise unittest.SkipTest("Spidermonkey C library not available")
-
- def test_spidermonkey(self):
- """Spidermonkey basic functionality tests"""
-
- self.cx.eval_script("var item0={'price':50}")
- self.cx.eval_script("var item1={'price':20}")
- self.assertEqual(self.cx.eval_script("item0"), {'price': 50})
- self.assertEqual(self.cx.eval_script("item1"), {'price': 20})
- self.cx.eval_script("var itemArray=new Array(item0, item1)")
- self.assertEqual(self.cx.eval_script("itemArray"), [{'price': 50}, {'price':20}])
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/scrapy/trunk/scrapy/tests/test_spiders/__init__.py b/scrapy/trunk/scrapy/tests/test_spiders/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/tests/test_stats.py b/scrapy/trunk/scrapy/tests/test_stats.py
deleted file mode 100644
index 3b7c2ac2d..000000000
--- a/scrapy/trunk/scrapy/tests/test_stats.py
+++ /dev/null
@@ -1,52 +0,0 @@
-from unittest import TestCase, main
-from scrapy.conf import settings
-from scrapy.stats.statscollector import StatsCollector
-
-class StatsTest(TestCase):
- def test_stats(self):
- stats = StatsCollector(enabled=False)
- self.assertEqual(stats, {})
- self.assertEqual(stats.getpath('anything'), None)
- self.assertEqual(stats.getpath('anything', 'default'), 'default')
- stats.setpath('test', 'value')
- self.assertEqual(stats, {})
-
- stats = StatsCollector(enabled=True)
- self.assertEqual(stats, {})
- self.assertEqual(stats.getpath('anything'), None)
- self.assertEqual(stats.getpath('anything', 'default'), 'default')
- stats.setpath('test', 'value')
- self.assertEqual(stats, {'test': 'value'})
- stats.setpath('test2', 23)
- self.assertEqual(stats, {'test': 'value', 'test2': 23})
- stats.setpath('one/two', 'val2')
- self.assertEqual(stats, {'test': 'value', 'test2': 23, 'one': {'two': 'val2'}})
- self.assertEqual(stats.getpath('one/two'), 'val2')
- self.assertEqual(stats.getpath('one/three'), None)
- self.assertEqual(stats.getpath('one/three', 'four'), 'four')
- self.assertEqual(stats.getpath('one'), {'two': 'val2'})
-
- # nodes must contain either data or other nodes, but not both!
- self.assertRaises(TypeError, stats.setpath, 'one/two/three', 22)
-
- stats.delpath('test2')
- self.assertEqual(stats, {'test': 'value', 'one': {'two': 'val2'}})
- stats.delpath('one/two')
- self.assertEqual(stats, {'test': 'value', 'one': {}})
- stats.delpath('one')
- self.assertEqual(stats, {'test': 'value'})
-
- stats.setpath('one/other/three', 20)
- self.assertEqual(stats.getpath('one/other/three'), 20)
- stats.incpath('one/other/three')
- self.assertEqual(stats.getpath('one/other/three'), 21)
- stats.incpath('one/other/three', 4)
- self.assertEqual(stats.getpath('one/other/three'), 25)
-
- stats.incpath('one/newnode', 1)
- self.assertEqual(stats.getpath('one/newnode'), 1)
- stats.incpath('one/newnode', -1)
- self.assertEqual(stats.getpath('one/newnode'), 0)
-
-if __name__ == "__main__":
- main()
diff --git a/scrapy/trunk/scrapy/utils/__init__.py b/scrapy/trunk/scrapy/utils/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/scrapy/trunk/scrapy/utils/c14n.py b/scrapy/trunk/scrapy/utils/c14n.py
deleted file mode 100644
index 88cdd16df..000000000
--- a/scrapy/trunk/scrapy/utils/c14n.py
+++ /dev/null
@@ -1,110 +0,0 @@
-"""
-Canonicalization routine for URLs
-"""
-import re
-import urlparse
-
-_hexmatcher = re.compile("\%[0-9A-Fa-f]{2}")
-
-def get_canonized_port(port):
- if port and port != 80:
- cport = ":" + str(port)
- else:
- cport = ""
- return cport
-
-def create_params_dict(params):
- param_dict = {}
- for param in params.split("&"):
- nvpair = param.split("=")
- if len(nvpair) >= 2:
- param_dict[nvpair[0]] = '='.join(nvpair[1:])
- else:
- param_dict[nvpair[0]] = None
- return param_dict
-
-def create_unique_params_list(params):
- """
- This function build a query string from unique params only.
- Unique params are params with unique key=>value pair. So param=qwe and param=123
- are diffrent and a query string will be param=qwe&param=123.
- If input params will contain pairs like this param=123 and param=123 a query
- string will be just param=123
- We have to do this because some ASP sites uses the same parameters names in the URLs,
- but with diffrent values. Such queries are interpreted as arrays in the ASP framework.
- """
- param_list = []
- if params:
- for param in params.split("&"):
- nvpair = param.split("=", 1)
- if len(nvpair) >= 2:
- param_list.append(nvpair[0] + '=' + nvpair[1])
- else:
- param_list.append(nvpair[0] + '=')
- if param_list:
- p_list = []
- # select only unique pairs, it is possible to use set() for this but change order of pairs...
- for param in param_list:
- if param not in p_list:
- p_list.append(param)
- return '&'.join(p_list)
- return ''
-
-def convert_escaped(string_to_convert):
- hexvalues = _hexmatcher.findall(string_to_convert)
- for hexvalue in hexvalues:
- string_to_convert = string_to_convert.replace(
- hexvalue, chr(int(hexvalue[1:len(hexvalue)],16)))
- return string_to_convert
-
-def remove_dirs(path):
- dirs = path.split("/")
- dirs.reverse()
- stripped_dirs = []
- ellipsis = 0
- for dir in dirs:
- if dir == ".." :
- ellipsis += 1
- elif dir == "." :
- pass
- else:
- if ellipsis > 0 :
- ellipsis -= 1
- else:
- stripped_dirs.append(dir)
- stripped_dirs.reverse()
- return "/".join(stripped_dirs)
-
-def canonicalize(url):
- """
- This method c14ns the url we are passed by doing the following
- 1) lowercasing the hostname and scheme
- 2) removing the port if it is 80
- 3) making the query params unique and alphabetized
- 4) removing url encoding
- 5) Removing any ./
- 6) Removing and ../ and their preceding directories
- """
-
- # Remove the fragment marker, even if it's url encoded
- defragmented_url = urlparse.urldefrag(url)[0]
-
- # This automatically converts the scheme and hostname to lower case
- parsed = urlparse.urlparse(defragmented_url)
-
- # Get the port in the correct format
- cport = get_canonized_port(parsed.port)
-
- query = create_unique_params_list(parsed.query)
-
- # Remove the url encoded params from the path and query string
- query = convert_escaped(query)
- if query :
- query = "?" + query
- path = convert_escaped(parsed.path)
-
- # Remove the ../ and the previous directories and remove the ./
- path = remove_dirs(path)
-
- # Now put it all back together
- return "%s://%s%s%s%s" % (parsed.scheme, parsed.hostname, cport, path, query)
diff --git a/scrapy/trunk/scrapy/utils/display.py b/scrapy/trunk/scrapy/utils/display.py
deleted file mode 100644
index 710e7d743..000000000
--- a/scrapy/trunk/scrapy/utils/display.py
+++ /dev/null
@@ -1,49 +0,0 @@
-"""
-Helper functions for formatting and pretty printing some objects
-"""
-import sys
-import pprint as pypprint
-
-from scrapy.item import ScrapedItem
-from scrapy.http import Request, Response
-
-nocolour = False
-
-def colorize(text):
- if nocolour or not sys.stdout.isatty():
- return text
- try:
- from pygments import highlight
- from pygments.formatters import TerminalFormatter
- from pygments.lexers import PythonLexer
- return highlight(text, PythonLexer(), TerminalFormatter())
- except ImportError:
- return text
-
-def pformat_dictobj(obj):
- clsname = obj.__class__.__name__
- return "%s(%s)\n" % (clsname, colorize(pypprint.pformat(obj.__dict__)))
-
-def pprint_dictobj(obj):
- print pformat_dictobj(obj)
-
-def pformat(obj, *args, **kwargs):
- """
- Wrapper which autodetects the object type and uses the proper formatting
- function
- """
-
- if isinstance(obj, (list, tuple)):
- return "".join([pformat(i, *args, **kwargs) for i in obj])
- elif isinstance(obj, (ScrapedItem, Request, Response)):
- return pformat_dictobj(obj)
- else:
- return colorize(pypprint.pformat(obj))
-
-def pprint(obj, *args, **kwargs):
- """
- Wrapper which autodetects the object type and uses the proper printing
- function
- """
-
- print pformat(obj, *args, **kwargs)
diff --git a/scrapy/trunk/scrapy/utils/serialization.py b/scrapy/trunk/scrapy/utils/serialization.py
deleted file mode 100644
index 82bd01eb3..000000000
--- a/scrapy/trunk/scrapy/utils/serialization.py
+++ /dev/null
@@ -1,74 +0,0 @@
-"""
-This module provides a universal API for different serialization formats.
-
-Keep in mind that not all formats support all types for serialization, and some
-formats (like pprint) may be unsafe for unserialization (like pprint) but it
-may still very convenient for serialization.
-"""
-
-import datetime
-import decimal
-import cPickle as pickle
-import pprint
-
-import simplejson
-
-class ScrapyJSONEncoder(simplejson.JSONEncoder):
- """
- JSONEncoder subclass that knows how to encode date/time and decimal types.
- """
-
- DATE_FORMAT = "%Y-%m-%d"
- TIME_FORMAT = "%H:%M:%S"
-
- def default(self, o):
- if isinstance(o, datetime.datetime):
- return o.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT))
- elif isinstance(o, datetime.date):
- return o.strftime(self.DATE_FORMAT)
- elif isinstance(o, datetime.time):
- return o.strftime(self.TIME_FORMAT)
- elif isinstance(o, decimal.Decimal):
- return str(o)
- else:
- return super(ScrapyJSONEncoder, self).default(o)
-
-serialize_funcs = {
- 'json': lambda obj: simplejson.dumps(obj, cls=ScrapyJSONEncoder),
- 'pprint': lambda obj: pprint.pformat(obj),
- 'pickle': lambda obj: pickle.dumps(obj),
-}
-
-unserialize_funcs = {
- 'json': lambda text: simplejson.loads(text),
- 'pprint': lambda text: eval(text),
- 'pickle': lambda text: pickle.loads(text),
-}
-
-def serialize(obj, format='pickle'):
- """
- Main entrance point for serialization.
-
- Supported formats: pickle, json, pprint
- """
- try:
- func = serialize_funcs[format]
- return func(obj)
- except KeyError:
- raise TypeError("Unknown serialization format: %s" % format)
-
-def unserialize(text, format='pickle'):
- """
- Main entrance point for unserialization.
- """
- try:
- func = unserialize_funcs[format]
- return func(text)
- except KeyError:
- raise TypeError("Unknown serialization format: %s" % format)
-
-def parse_jsondatetime(text):
- if isinstance(text, basestring):
- return datetime.datetime.strptime(text, "%s %s" % \
- (ScrapyJSONEncoder.DATE_FORMAT, ScrapyJSONEncoder.TIME_FORMAT))
-
diff --git a/scrapy/trunk/scrapy/xlib/BeautifulSoup.py b/scrapy/trunk/scrapy/xlib/BeautifulSoup.py
deleted file mode 100644
index 0e55abaf8..000000000
--- a/scrapy/trunk/scrapy/xlib/BeautifulSoup.py
+++ /dev/null
@@ -1,1931 +0,0 @@
-"""Beautiful Soup
-Elixir and Tonic
-"The Screen-Scraper's Friend"
-http://www.crummy.com/software/BeautifulSoup/
-
-Beautiful Soup parses a (possibly invalid) XML or HTML document into a
-tree representation. It provides methods and Pythonic idioms that make
-it easy to navigate, search, and modify the tree.
-
-A well-formed XML/HTML document yields a well-formed data
-structure. An ill-formed XML/HTML document yields a correspondingly
-ill-formed data structure. If your document is only locally
-well-formed, you can use this library to find and process the
-well-formed part of it.
-
-Beautiful Soup works with Python 2.2 and up. It has no external
-dependencies, but you'll have more success at converting data to UTF-8
-if you also install these three packages:
-
-* chardet, for auto-detecting character encodings
- http://chardet.feedparser.org/
-* cjkcodecs and iconv_codec, which add more encodings to the ones supported
- by stock Python.
- http://cjkpython.i18n.org/
-
-Beautiful Soup defines classes for two main parsing strategies:
-
- * BeautifulStoneSoup, for parsing XML, SGML, or your domain-specific
- language that kind of looks like XML.
-
- * BeautifulSoup, for parsing run-of-the-mill HTML code, be it valid
- or invalid. This class has web browser-like heuristics for
- obtaining a sensible parse tree in the face of common HTML errors.
-
-Beautiful Soup also defines a class (UnicodeDammit) for autodetecting
-the encoding of an HTML or XML document, and converting it to
-Unicode. Much of this code is taken from Mark Pilgrim's Universal Feed Parser.
-
-For more than you ever wanted to know about Beautiful Soup, see the
-documentation:
-http://www.crummy.com/software/BeautifulSoup/documentation.html
-
-Here, have some legalese:
-
-Copyright (c) 2004-2007, Leonard Richardson
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of the the Beautiful Soup Consortium and All
- Night Kosher Bakery nor the names of its contributors may be
- used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE, DAMMIT.
-
-"""
-from __future__ import generators
-
-__author__ = "Leonard Richardson ([email protected])"
-__version__ = "3.0.6"
-__copyright__ = "Copyright (c) 2004-2008 Leonard Richardson"
-__license__ = "New-style BSD"
-
-from sgmllib import SGMLParser, SGMLParseError
-import codecs
-import types
-import re
-import sgmllib
-try:
- from htmlentitydefs import name2codepoint
-except ImportError:
- name2codepoint = {}
-
-#This hack makes Beautiful Soup able to parse XML with namespaces
-sgmllib.tagfind = re.compile('[a-zA-Z][-_.:a-zA-Z0-9]*')
-
-DEFAULT_OUTPUT_ENCODING = "utf-8"
-
-# First, the classes that represent markup elements.
-
-class PageElement:
- """Contains the navigational information for some part of the page
- (either a tag or a piece of text)"""
-
- def setup(self, parent=None, previous=None):
- """Sets up the initial relations between this element and
- other elements."""
- self.parent = parent
- self.previous = previous
- self.next = None
- self.previousSibling = None
- self.nextSibling = None
- if self.parent and self.parent.contents:
- self.previousSibling = self.parent.contents[-1]
- self.previousSibling.nextSibling = self
-
- def replaceWith(self, replaceWith):
- oldParent = self.parent
- myIndex = self.parent.contents.index(self)
- if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent:
- # We're replacing this element with one of its siblings.
- index = self.parent.contents.index(replaceWith)
- if index and index < myIndex:
- # Furthermore, it comes before this element. That
- # means that when we extract it, the index of this
- # element will change.
- myIndex = myIndex - 1
- self.extract()
- oldParent.insert(myIndex, replaceWith)
-
- def extract(self):
- """Destructively rips this element out of the tree."""
- if self.parent:
- try:
- self.parent.contents.remove(self)
- except ValueError:
- pass
-
- #Find the two elements that would be next to each other if
- #this element (and any children) hadn't been parsed. Connect
- #the two.
- lastChild = self._lastRecursiveChild()
- nextElement = lastChild.next
-
- if self.previous:
- self.previous.next = nextElement
- if nextElement:
- nextElement.previous = self.previous
- self.previous = None
- lastChild.next = None
-
- self.parent = None
- if self.previousSibling:
- self.previousSibling.nextSibling = self.nextSibling
- if self.nextSibling:
- self.nextSibling.previousSibling = self.previousSibling
- self.previousSibling = self.nextSibling = None
- return self
-
- def _lastRecursiveChild(self):
- "Finds the last element beneath this object to be parsed."
- lastChild = self
- while hasattr(lastChild, 'contents') and lastChild.contents:
- lastChild = lastChild.contents[-1]
- return lastChild
-
- def insert(self, position, newChild):
- if (isinstance(newChild, basestring)
- or isinstance(newChild, unicode)) \
- and not isinstance(newChild, NavigableString):
- newChild = NavigableString(newChild)
-
- position = min(position, len(self.contents))
- if hasattr(newChild, 'parent') and newChild.parent != None:
- # We're 'inserting' an element that's already one
- # of this object's children.
- if newChild.parent == self:
- index = self.find(newChild)
- if index and index < position:
- # Furthermore we're moving it further down the
- # list of this object's children. That means that
- # when we extract this element, our target index
- # will jump down one.
- position = position - 1
- newChild.extract()
-
- newChild.parent = self
- previousChild = None
- if position == 0:
- newChild.previousSibling = None
- newChild.previous = self
- else:
- previousChild = self.contents[position-1]
- newChild.previousSibling = previousChild
- newChild.previousSibling.nextSibling = newChild
- newChild.previous = previousChild._lastRecursiveChild()
- if newChild.previous:
- newChild.previous.next = newChild
-
- newChildsLastElement = newChild._lastRecursiveChild()
-
- if position >= len(self.contents):
- newChild.nextSibling = None
-
- parent = self
- parentsNextSibling = None
- while not parentsNextSibling:
- parentsNextSibling = parent.nextSibling
- parent = parent.parent
- if not parent: # This is the last element in the document.
- break
- if parentsNextSibling:
- newChildsLastElement.next = parentsNextSibling
- else:
- newChildsLastElement.next = None
- else:
- nextChild = self.contents[position]
- newChild.nextSibling = nextChild
- if newChild.nextSibling:
- newChild.nextSibling.previousSibling = newChild
- newChildsLastElement.next = nextChild
-
- if newChildsLastElement.next:
- newChildsLastElement.next.previous = newChildsLastElement
- self.contents.insert(position, newChild)
-
- def append(self, tag):
- """Appends the given tag to the contents of this tag."""
- self.insert(len(self.contents), tag)
-
- def findNext(self, name=None, attrs={}, text=None, **kwargs):
- """Returns the first item that matches the given criteria and
- appears after this Tag in the document."""
- return self._findOne(self.findAllNext, name, attrs, text, **kwargs)
-
- def findAllNext(self, name=None, attrs={}, text=None, limit=None,
- **kwargs):
- """Returns all items that match the given criteria and appear
- after this Tag in the document."""
- return self._findAll(name, attrs, text, limit, self.nextGenerator,
- **kwargs)
-
- def findNextSibling(self, name=None, attrs={}, text=None, **kwargs):
- """Returns the closest sibling to this Tag that matches the
- given criteria and appears after this Tag in the document."""
- return self._findOne(self.findNextSiblings, name, attrs, text,
- **kwargs)
-
- def findNextSiblings(self, name=None, attrs={}, text=None, limit=None,
- **kwargs):
- """Returns the siblings of this Tag that match the given
- criteria and appear after this Tag in the document."""
- return self._findAll(name, attrs, text, limit,
- self.nextSiblingGenerator, **kwargs)
- fetchNextSiblings = findNextSiblings # Compatibility with pre-3.x
-
- def findPrevious(self, name=None, attrs={}, text=None, **kwargs):
- """Returns the first item that matches the given criteria and
- appears before this Tag in the document."""
- return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs)
-
- def findAllPrevious(self, name=None, attrs={}, text=None, limit=None,
- **kwargs):
- """Returns all items that match the given criteria and appear
- before this Tag in the document."""
- return self._findAll(name, attrs, text, limit, self.previousGenerator,
- **kwargs)
- fetchPrevious = findAllPrevious # Compatibility with pre-3.x
-
- def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs):
- """Returns the closest sibling to this Tag that matches the
- given criteria and appears before this Tag in the document."""
- return self._findOne(self.findPreviousSiblings, name, attrs, text,
- **kwargs)
-
- def findPreviousSiblings(self, name=None, attrs={}, text=None,
- limit=None, **kwargs):
- """Returns the siblings of this Tag that match the given
- criteria and appear before this Tag in the document."""
- return self._findAll(name, attrs, text, limit,
- self.previousSiblingGenerator, **kwargs)
- fetchPreviousSiblings = findPreviousSiblings # Compatibility with pre-3.x
-
- def findParent(self, name=None, attrs={}, **kwargs):
- """Returns the closest parent of this Tag that matches the given
- criteria."""
- # NOTE: We can't use _findOne because findParents takes a different
- # set of arguments.
- r = None
- l = self.findParents(name, attrs, 1)
- if l:
- r = l[0]
- return r
-
- def findParents(self, name=None, attrs={}, limit=None, **kwargs):
- """Returns the parents of this Tag that match the given
- criteria."""
-
- return self._findAll(name, attrs, None, limit, self.parentGenerator,
- **kwargs)
- fetchParents = findParents # Compatibility with pre-3.x
-
- #These methods do the real heavy lifting.
-
- def _findOne(self, method, name, attrs, text, **kwargs):
- r = None
- l = method(name, attrs, text, 1, **kwargs)
- if l:
- r = l[0]
- return r
-
- def _findAll(self, name, attrs, text, limit, generator, **kwargs):
- "Iterates over a generator looking for things that match."
-
- if isinstance(name, SoupStrainer):
- strainer = name
- else:
- # Build a SoupStrainer
- strainer = SoupStrainer(name, attrs, text, **kwargs)
- results = ResultSet(strainer)
- g = generator()
- while True:
- try:
- i = g.next()
- except StopIteration:
- break
- if i:
- found = strainer.search(i)
- if found:
- results.append(found)
- if limit and len(results) >= limit:
- break
- return results
-
- #These Generators can be used to navigate starting from both
- #NavigableStrings and Tags.
- def nextGenerator(self):
- i = self
- while i:
- i = i.next
- yield i
-
- def nextSiblingGenerator(self):
- i = self
- while i:
- i = i.nextSibling
- yield i
-
- def previousGenerator(self):
- i = self
- while i:
- i = i.previous
- yield i
-
- def previousSiblingGenerator(self):
- i = self
- while i:
- i = i.previousSibling
- yield i
-
- def parentGenerator(self):
- i = self
- while i:
- i = i.parent
- yield i
-
- # Utility methods
- def substituteEncoding(self, str, encoding=None):
- encoding = encoding or "utf-8"
- return str.replace("%SOUP-ENCODING%", encoding)
-
- def toEncoding(self, s, encoding=None):
- """Encodes an object to a string in some encoding, or to Unicode.
- ."""
- if isinstance(s, unicode):
- if encoding:
- s = s.encode(encoding)
- elif isinstance(s, str):
- if encoding:
- s = s.encode(encoding)
- else:
- s = unicode(s)
- else:
- if encoding:
- s = self.toEncoding(str(s), encoding)
- else:
- s = unicode(s)
- return s
-
-class NavigableString(unicode, PageElement):
-
- def __getnewargs__(self):
- return (NavigableString.__str__(self),)
-
- def __getattr__(self, attr):
- """text.string gives you text. This is for backwards
- compatibility for Navigable*String, but for CData* it lets you
- get the string without the CData wrapper."""
- if attr == 'string':
- return self
- else:
- raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr)
-
- def __unicode__(self):
- return str(self).decode(DEFAULT_OUTPUT_ENCODING)
-
- def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
- if encoding:
- return self.encode(encoding)
- else:
- return self
-
-class CData(NavigableString):
-
- def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
- return "<![CDATA[%s]]>" % NavigableString.__str__(self, encoding)
-
-class ProcessingInstruction(NavigableString):
- def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
- output = self
- if "%SOUP-ENCODING%" in output:
- output = self.substituteEncoding(output, encoding)
- return "<?%s?>" % self.toEncoding(output, encoding)
-
-class Comment(NavigableString):
- def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
- return "<!--%s-->" % NavigableString.__str__(self, encoding)
-
-class Declaration(NavigableString):
- def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
- return "<!%s>" % NavigableString.__str__(self, encoding)
-
-class Tag(PageElement):
-
- """Represents a found HTML tag with its attributes and contents."""
-
- def _invert(h):
- "Cheap function to invert a hash."
- i = {}
- for k,v in h.items():
- i[v] = k
- return i
-
- XML_ENTITIES_TO_SPECIAL_CHARS = { "apos" : "'",
- "quot" : '"',
- "amp" : "&",
- "lt" : "<",
- "gt" : ">" }
-
- XML_SPECIAL_CHARS_TO_ENTITIES = _invert(XML_ENTITIES_TO_SPECIAL_CHARS)
-
- def _convertEntities(self, match):
- """Used in a call to re.sub to replace HTML, XML, and numeric
- entities with the appropriate Unicode characters. If HTML
- entities are being converted, any unrecognized entities are
- escaped."""
- x = match.group(1)
- if self.convertHTMLEntities and x in name2codepoint:
- return unichr(name2codepoint[x])
- elif x in self.XML_ENTITIES_TO_SPECIAL_CHARS:
- if self.convertXMLEntities:
- return self.XML_ENTITIES_TO_SPECIAL_CHARS[x]
- else:
- return u'&%s;' % x
- elif len(x) > 0 and x[0] == '#':
- # Handle numeric entities
- if len(x) > 1 and x[1] == 'x':
- return unichr(int(x[2:], 16))
- else:
- return unichr(int(x[1:]))
-
- elif self.escapeUnrecognizedEntities:
- return u'&amp;%s;' % x
- else:
- return u'&%s;' % x
-
- def __init__(self, parser, name, attrs=None, parent=None,
- previous=None):
- "Basic constructor."
-
- # We don't actually store the parser object: that lets extracted
- # chunks be garbage-collected
- self.parserClass = parser.__class__
- self.isSelfClosing = parser.isSelfClosingTag(name)
- self.name = name
- if attrs == None:
- attrs = []
- self.attrs = attrs
- self.contents = []
- self.setup(parent, previous)
- self.hidden = False
- self.containsSubstitutions = False
- self.convertHTMLEntities = parser.convertHTMLEntities
- self.convertXMLEntities = parser.convertXMLEntities
- self.escapeUnrecognizedEntities = parser.escapeUnrecognizedEntities
-
- # Convert any HTML, XML, or numeric entities in the attribute values.
- convert = lambda(k, val): (k,
- re.sub("&(#\d+|#x[0-9a-fA-F]+|\w+);",
- self._convertEntities,
- val))
- self.attrs = map(convert, self.attrs)
-
- def get(self, key, default=None):
- """Returns the value of the 'key' attribute for the tag, or
- the value given for 'default' if it doesn't have that
- attribute."""
- return self._getAttrMap().get(key, default)
-
- def has_key(self, key):
- return self._getAttrMap().has_key(key)
-
- def __getitem__(self, key):
- """tag[key] returns the value of the 'key' attribute for the tag,
- and throws an exception if it's not there."""
- return self._getAttrMap()[key]
-
- def __iter__(self):
- "Iterating over a tag iterates over its contents."
- return iter(self.contents)
-
- def __len__(self):
- "The length of a tag is the length of its list of contents."
- return len(self.contents)
-
- def __contains__(self, x):
- return x in self.contents
-
- def __nonzero__(self):
- "A tag is non-None even if it has no contents."
- return True
-
- def __setitem__(self, key, value):
- """Setting tag[key] sets the value of the 'key' attribute for the
- tag."""
- self._getAttrMap()
- self.attrMap[key] = value
- found = False
- for i in range(0, len(self.attrs)):
- if self.attrs[i][0] == key:
- self.attrs[i] = (key, value)
- found = True
- if not found:
- self.attrs.append((key, value))
- self._getAttrMap()[key] = value
-
- def __delitem__(self, key):
- "Deleting tag[key] deletes all 'key' attributes for the tag."
- for item in self.attrs:
- if item[0] == key:
- self.attrs.remove(item)
- #We don't break because bad HTML can define the same
- #attribute multiple times.
- self._getAttrMap()
- if self.attrMap.has_key(key):
- del self.attrMap[key]
-
- def __call__(self, *args, **kwargs):
- """Calling a tag like a function is the same as calling its
- findAll() method. Eg. tag('a') returns a list of all the A tags
- found within this tag."""
- return apply(self.findAll, args, kwargs)
-
- def __getattr__(self, tag):
- #print "Getattr %s.%s" % (self.__class__, tag)
- if len(tag) > 3 and tag.rfind('Tag') == len(tag)-3:
- return self.find(tag[:-3])
- elif tag.find('__') != 0:
- return self.find(tag)
- raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__, tag)
-
- def __eq__(self, other):
- """Returns true iff this tag has the same name, the same attributes,
- and the same contents (recursively) as the given tag.
-
- NOTE: right now this will return false if two tags have the
- same attributes in a different order. Should this be fixed?"""
- if not hasattr(other, 'name') or not hasattr(other, 'attrs') or not hasattr(other, 'contents') or self.name != other.name or self.attrs != other.attrs or len(self) != len(other):
- return False
- for i in range(0, len(self.contents)):
- if self.contents[i] != other.contents[i]:
- return False
- return True
-
- def __ne__(self, other):
- """Returns true iff this tag is not identical to the other tag,
- as defined in __eq__."""
- return not self == other
-
- def __repr__(self, encoding=DEFAULT_OUTPUT_ENCODING):
- """Renders this tag as a string."""
- return self.__str__(encoding)
-
- def __unicode__(self):
- return self.__str__(None)
-
- BARE_AMPERSAND_OR_BRACKET = re.compile("([<>]|"
- + "&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)"
- + ")")
-
- def _sub_entity(self, x):
- """Used with a regular expression to substitute the
- appropriate XML entity for an XML special character."""
- return "&" + self.XML_SPECIAL_CHARS_TO_ENTITIES[x.group(0)[0]] + ";"
-
- def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING,
- prettyPrint=False, indentLevel=0):
- """Returns a string or Unicode representation of this tag and
- its contents. To get Unicode, pass None for encoding.
-
- NOTE: since Python's HTML parser consumes whitespace, this
- method is not certain to reproduce the whitespace present in
- the original string."""
-
- encodedName = self.toEncoding(self.name, encoding)
-
- attrs = []
- if self.attrs:
- for key, val in self.attrs:
- fmt = '%s="%s"'
- if isString(val):
- if self.containsSubstitutions and '%SOUP-ENCODING%' in val:
- val = self.substituteEncoding(val, encoding)
-
- # The attribute value either:
- #
- # * Contains no embedded double quotes or single quotes.
- # No problem: we enclose it in double quotes.
- # * Contains embedded single quotes. No problem:
- # double quotes work here too.
- # * Contains embedded double quotes. No problem:
- # we enclose it in single quotes.
- # * Embeds both single _and_ double quotes. This
- # can't happen naturally, but it can happen if
- # you modify an attribute value after parsing
- # the document. Now we have a bit of a
- # problem. We solve it by enclosing the
- # attribute in single quotes, and escaping any
- # embedded single quotes to XML entities.
- if '"' in val:
- fmt = "%s='%s'"
- if "'" in val:
- # TODO: replace with apos when
- # appropriate.
- val = val.replace("'", "&squot;")
-
- # Now we're okay w/r/t quotes. But the attribute
- # value might also contain angle brackets, or
- # ampersands that aren't part of entities. We need
- # to escape those to XML entities too.
- val = self.BARE_AMPERSAND_OR_BRACKET.sub(self._sub_entity, val)
-
- attrs.append(fmt % (self.toEncoding(key, encoding),
- self.toEncoding(val, encoding)))
- close = ''
- closeTag = ''
- if self.isSelfClosing:
- close = ' /'
- else:
- closeTag = '</%s>' % encodedName
-
- indentTag, indentContents = 0, 0
- if prettyPrint:
- indentTag = indentLevel
- space = (' ' * (indentTag-1))
- indentContents = indentTag + 1
- contents = self.renderContents(encoding, prettyPrint, indentContents)
- if self.hidden:
- s = contents
- else:
- s = []
- attributeString = ''
- if attrs:
- attributeString = ' ' + ' '.join(attrs)
- if prettyPrint:
- s.append(space)
- s.append('<%s%s%s>' % (encodedName, attributeString, close))
- if prettyPrint:
- s.append("\n")
- s.append(contents)
- if prettyPrint and contents and contents[-1] != "\n":
- s.append("\n")
- if prettyPrint and closeTag:
- s.append(space)
- s.append(closeTag)
- if prettyPrint and closeTag and self.nextSibling:
- s.append("\n")
- s = ''.join(s)
- return s
-
- def decompose(self):
- """Recursively destroys the contents of this tree."""
- contents = [i for i in self.contents]
- for i in contents:
- if isinstance(i, Tag):
- i.decompose()
- else:
- i.extract()
- self.extract()
-
- def prettify(self, encoding=DEFAULT_OUTPUT_ENCODING):
- return self.__str__(encoding, True)
-
- def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING,
- prettyPrint=False, indentLevel=0):
- """Renders the contents of this tag as a string in the given
- encoding. If encoding is None, returns a Unicode string.."""
- s=[]
- for c in self:
- text = None
- if isinstance(c, NavigableString):
- text = c.__str__(encoding)
- elif isinstance(c, Tag):
- s.append(c.__str__(encoding, prettyPrint, indentLevel))
- if text and prettyPrint:
- text = text.strip()
- if text:
- if prettyPrint:
- s.append(" " * (indentLevel-1))
- s.append(text)
- if prettyPrint:
- s.append("\n")
- return ''.join(s)
-
- #Soup methods
-
- def find(self, name=None, attrs={}, recursive=True, text=None,
- **kwargs):
- """Return only the first child of this Tag matching the given
- criteria."""
- r = None
- l = self.findAll(name, attrs, recursive, text, 1, **kwargs)
- if l:
- r = l[0]
- return r
- findChild = find
-
- def findAll(self, name=None, attrs={}, recursive=True, text=None,
- limit=None, **kwargs):
- """Extracts a list of Tag objects that match the given
- criteria. You can specify the name of the Tag and any
- attributes you want the Tag to have.
-
- The value of a key-value pair in the 'attrs' map can be a
- string, a list of strings, a regular expression object, or a
- callable that takes a string and returns whether or not the
- string matches for some custom definition of 'matches'. The
- same is true of the tag name."""
- generator = self.recursiveChildGenerator
- if not recursive:
- generator = self.childGenerator
- return self._findAll(name, attrs, text, limit, generator, **kwargs)
- findChildren = findAll
-
- # Pre-3.x compatibility methods
- first = find
- fetch = findAll
-
- def fetchText(self, text=None, recursive=True, limit=None):
- return self.findAll(text=text, recursive=recursive, limit=limit)
-
- def firstText(self, text=None, recursive=True):
- return self.find(text=text, recursive=recursive)
-
- #Private methods
-
- def _getAttrMap(self):
- """Initializes a map representation of this tag's attributes,
- if not already initialized."""
- if not getattr(self, 'attrMap'):
- self.attrMap = {}
- for (key, value) in self.attrs:
- self.attrMap[key] = value
- return self.attrMap
-
- #Generator methods
- def childGenerator(self):
- for i in range(0, len(self.contents)):
- yield self.contents[i]
- raise StopIteration
-
- def recursiveChildGenerator(self):
- stack = [(self, 0)]
- while stack:
- tag, start = stack.pop()
- if isinstance(tag, Tag):
- for i in range(start, len(tag.contents)):
- a = tag.contents[i]
- yield a
- if isinstance(a, Tag) and tag.contents:
- if i < len(tag.contents) - 1:
- stack.append((tag, i+1))
- stack.append((a, 0))
- break
- raise StopIteration
-
-# Next, a couple classes to represent queries and their results.
-class SoupStrainer:
- """Encapsulates a number of ways of matching a markup element (tag or
- text)."""
-
- def __init__(self, name=None, attrs={}, text=None, **kwargs):
- self.name = name
- if isString(attrs):
- kwargs['class'] = attrs
- attrs = None
- if kwargs:
- if attrs:
- attrs = attrs.copy()
- attrs.update(kwargs)
- else:
- attrs = kwargs
- self.attrs = attrs
- self.text = text
-
- def __str__(self):
- if self.text:
- return self.text
- else:
- return "%s|%s" % (self.name, self.attrs)
-
- def searchTag(self, markupName=None, markupAttrs={}):
- found = None
- markup = None
- if isinstance(markupName, Tag):
- markup = markupName
- markupAttrs = markup
- callFunctionWithTagData = callable(self.name) \
- and not isinstance(markupName, Tag)
-
- if (not self.name) \
- or callFunctionWithTagData \
- or (markup and self._matches(markup, self.name)) \
- or (not markup and self._matches(markupName, self.name)):
- if callFunctionWithTagData:
- match = self.name(markupName, markupAttrs)
- else:
- match = True
- markupAttrMap = None
- for attr, matchAgainst in self.attrs.items():
- if not markupAttrMap:
- if hasattr(markupAttrs, 'get'):
- markupAttrMap = markupAttrs
- else:
- markupAttrMap = {}
- for k,v in markupAttrs:
- markupAttrMap[k] = v
- attrValue = markupAttrMap.get(attr)
- if not self._matches(attrValue, matchAgainst):
- match = False
- break
- if match:
- if markup:
- found = markup
- else:
- found = markupName
- return found
-
- def search(self, markup):
- #print 'looking for %s in %s' % (self, markup)
- found = None
- # If given a list of items, scan it for a text element that
- # matches.
- if isList(markup) and not isinstance(markup, Tag):
- for element in markup:
- if isinstance(element, NavigableString) \
- and self.search(element):
- found = element
- break
- # If it's a Tag, make sure its name or attributes match.
- # Don't bother with Tags if we're searching for text.
- elif isinstance(markup, Tag):
- if not self.text:
- found = self.searchTag(markup)
- # If it's text, make sure the text matches.
- elif isinstance(markup, NavigableString) or \
- isString(markup):
- if self._matches(markup, self.text):
- found = markup
- else:
- raise Exception, "I don't know how to match against a %s" \
- % markup.__class__
- return found
-
- def _matches(self, markup, matchAgainst):
- #print "Matching %s against %s" % (markup, matchAgainst)
- result = False
- if matchAgainst == True and type(matchAgainst) == types.BooleanType:
- result = markup != None
- elif callable(matchAgainst):
- result = matchAgainst(markup)
- else:
- #Custom match methods take the tag as an argument, but all
- #other ways of matching match the tag name as a string.
- if isinstance(markup, Tag):
- markup = markup.name
- if markup and not isString(markup):
- markup = unicode(markup)
- #Now we know that chunk is either a string, or None.
- if hasattr(matchAgainst, 'match'):
- # It's a regexp object.
- result = markup and matchAgainst.search(markup)
- elif isList(matchAgainst):
- result = markup in matchAgainst
- elif hasattr(matchAgainst, 'items'):
- result = markup.has_key(matchAgainst)
- elif matchAgainst and isString(markup):
- if isinstance(markup, unicode):
- matchAgainst = unicode(matchAgainst)
- else:
- matchAgainst = str(matchAgainst)
-
- if not result:
- result = matchAgainst == markup
- return result
-
-class ResultSet(list):
- """A ResultSet is just a list that keeps track of the SoupStrainer
- that created it."""
- def __init__(self, source):
- list.__init__([])
- self.source = source
-
-# Now, some helper functions.
-
-def isList(l):
- """Convenience method that works with all 2.x versions of Python
- to determine whether or not something is listlike."""
- return hasattr(l, '__iter__') \
- or (type(l) in (types.ListType, types.TupleType))
-
-def isString(s):
- """Convenience method that works with all 2.x versions of Python
- to determine whether or not something is stringlike."""
- try:
- return isinstance(s, unicode) or isinstance(s, basestring)
- except NameError:
- return isinstance(s, str)
-
-def buildTagMap(default, *args):
- """Turns a list of maps, lists, or scalars into a single map.
- Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and
- NESTING_RESET_TAGS maps out of lists and partial maps."""
- built = {}
- for portion in args:
- if hasattr(portion, 'items'):
- #It's a map. Merge it.
- for k,v in portion.items():
- built[k] = v
- elif isList(portion):
- #It's a list. Map each item to the default.
- for k in portion:
- built[k] = default
- else:
- #It's a scalar. Map it to the default.
- built[portion] = default
- return built
-
-# Now, the parser classes.
-
-class BeautifulStoneSoup(Tag, SGMLParser):
-
- """This class contains the basic parser and search code. It defines
- a parser that knows nothing about tag behavior except for the
- following:
-
- You can't close a tag without closing all the tags it encloses.
- That is, "<foo><bar></foo>" actually means
- "<foo><bar></bar></foo>".
-
- [Another possible explanation is "<foo><bar /></foo>", but since
- this class defines no SELF_CLOSING_TAGS, it will never use that
- explanation.]
-
- This class is useful for parsing XML or made-up markup languages,
- or when BeautifulSoup makes an assumption counter to what you were
- expecting."""
-
- SELF_CLOSING_TAGS = {}
- NESTABLE_TAGS = {}
- RESET_NESTING_TAGS = {}
- QUOTE_TAGS = {}
-
- MARKUP_MASSAGE = [(re.compile('(<[^<>]*)/>'),
- lambda x: x.group(1) + ' />'),
- (re.compile('<!\s+([^<>]*)>'),
- lambda x: '<!' + x.group(1) + '>')
- ]
-
- ROOT_TAG_NAME = u'[document]'
-
- HTML_ENTITIES = "html"
- XML_ENTITIES = "xml"
- XHTML_ENTITIES = "xhtml"
- # TODO: This only exists for backwards-compatibility
- ALL_ENTITIES = XHTML_ENTITIES
-
- # Used when determining whether a text node is all whitespace and
- # can be replaced with a single space. A text node that contains
- # fancy Unicode spaces (usually non-breaking) should be left
- # alone.
- STRIP_ASCII_SPACES = { 9: None, 10: None, 12: None, 13: None, 32: None, }
-
- def __init__(self, markup="", parseOnlyThese=None, fromEncoding=None,
- markupMassage=True, smartQuotesTo=XML_ENTITIES,
- convertEntities=None, selfClosingTags=None):
- """The Soup object is initialized as the 'root tag', and the
- provided markup (which can be a string or a file-like object)
- is fed into the underlying parser.
-
- sgmllib will process most bad HTML, and the BeautifulSoup
- class has some tricks for dealing with some HTML that kills
- sgmllib, but Beautiful Soup can nonetheless choke or lose data
- if your data uses self-closing tags or declarations
- incorrectly.
-
- By default, Beautiful Soup uses regexes to sanitize input,
- avoiding the vast majority of these problems. If the problems
- don't apply to you, pass in False for markupMassage, and
- you'll get better performance.
-
- The default parser massage techniques fix the two most common
- instances of invalid HTML that choke sgmllib:
-
- <br/> (No space between name of closing tag and tag close)
- <! --Comment--> (Extraneous whitespace in declaration)
-
- You can pass in a custom list of (RE object, replace method)
- tuples to get Beautiful Soup to scrub your input the way you
- want."""
-
- self.parseOnlyThese = parseOnlyThese
- self.fromEncoding = fromEncoding
- self.smartQuotesTo = smartQuotesTo
- self.convertEntities = convertEntities
- # Set the rules for how we'll deal with the entities we
- # encounter
- if self.convertEntities:
- # It doesn't make sense to convert encoded characters to
- # entities even while you're converting entities to Unicode.
- # Just convert it all to Unicode.
- self.smartQuotesTo = None
- if convertEntities == self.HTML_ENTITIES:
- self.convertXMLEntities = False
- self.convertHTMLEntities = True
- self.escapeUnrecognizedEntities = True
- elif convertEntities == self.XHTML_ENTITIES:
- self.convertXMLEntities = True
- self.convertHTMLEntities = True
- self.escapeUnrecognizedEntities = False
- elif convertEntities == self.XML_ENTITIES:
- self.convertXMLEntities = True
- self.convertHTMLEntities = False
- self.escapeUnrecognizedEntities = False
- else:
- self.convertXMLEntities = False
- self.convertHTMLEntities = False
- self.escapeUnrecognizedEntities = False
-
- self.instanceSelfClosingTags = buildTagMap(None, selfClosingTags)
- SGMLParser.__init__(self)
-
- if hasattr(markup, 'read'): # It's a file-type object.
- markup = markup.read()
- self.markup = markup
- self.markupMassage = markupMassage
- try:
- self._feed()
- except StopParsing:
- pass
- self.markup = None # The markup can now be GCed
-
- def convert_charref(self, name):
- """This method fixes a bug in Python's SGMLParser."""
- try:
- n = int(name)
- except ValueError:
- return
- if not 0 <= n <= 127 : # ASCII ends at 127, not 255
- return
- return self.convert_codepoint(n)
-
- def _feed(self, inDocumentEncoding=None):
- # Convert the document to Unicode.
- markup = self.markup
- if isinstance(markup, unicode):
- if not hasattr(self, 'originalEncoding'):
- self.originalEncoding = None
- else:
- dammit = UnicodeDammit\
- (markup, [self.fromEncoding, inDocumentEncoding],
- smartQuotesTo=self.smartQuotesTo)
- markup = dammit.unicode
- self.originalEncoding = dammit.originalEncoding
- if markup:
- if self.markupMassage:
- if not isList(self.markupMassage):
- self.markupMassage = self.MARKUP_MASSAGE
- for fix, m in self.markupMassage:
- markup = fix.sub(m, markup)
- # TODO: We get rid of markupMassage so that the
- # soup object can be deepcopied later on. Some
- # Python installations can't copy regexes. If anyone
- # was relying on the existence of markupMassage, this
- # might cause problems.
- del(self.markupMassage)
- self.reset()
-
- SGMLParser.feed(self, markup)
- # Close out any unfinished strings and close all the open tags.
- self.endData()
- while self.currentTag.name != self.ROOT_TAG_NAME:
- self.popTag()
-
- def __getattr__(self, methodName):
- """This method routes method call requests to either the SGMLParser
- superclass or the Tag superclass, depending on the method name."""
- #print "__getattr__ called on %s.%s" % (self.__class__, methodName)
-
- if methodName.find('start_') == 0 or methodName.find('end_') == 0 \
- or methodName.find('do_') == 0:
- return SGMLParser.__getattr__(self, methodName)
- elif methodName.find('__') != 0:
- return Tag.__getattr__(self, methodName)
- else:
- raise AttributeError
-
- def isSelfClosingTag(self, name):
- """Returns true iff the given string is the name of a
- self-closing tag according to this parser."""
- return self.SELF_CLOSING_TAGS.has_key(name) \
- or self.instanceSelfClosingTags.has_key(name)
-
- def reset(self):
- Tag.__init__(self, self, self.ROOT_TAG_NAME)
- self.hidden = 1
- SGMLParser.reset(self)
- self.currentData = []
- self.currentTag = None
- self.tagStack = []
- self.quoteStack = []
- self.pushTag(self)
-
- def popTag(self):
- tag = self.tagStack.pop()
- # Tags with just one string-owning child get the child as a
- # 'string' property, so that soup.tag.string is shorthand for
- # soup.tag.contents[0]
- if len(self.currentTag.contents) == 1 and \
- isinstance(self.currentTag.contents[0], NavigableString):
- self.currentTag.string = self.currentTag.contents[0]
-
- #print "Pop", tag.name
- if self.tagStack:
- self.currentTag = self.tagStack[-1]
- return self.currentTag
-
- def pushTag(self, tag):
- #print "Push", tag.name
- if self.currentTag:
- self.currentTag.contents.append(tag)
- self.tagStack.append(tag)
- self.currentTag = self.tagStack[-1]
-
- def endData(self, containerClass=NavigableString):
- if self.currentData:
- currentData = ''.join(self.currentData)
- if not currentData.translate(self.STRIP_ASCII_SPACES):
- if '\n' in currentData:
- currentData = '\n'
- else:
- currentData = ' '
- self.currentData = []
- if self.parseOnlyThese and len(self.tagStack) <= 1 and \
- (not self.parseOnlyThese.text or \
- not self.parseOnlyThese.search(currentData)):
- return
- o = containerClass(currentData)
- o.setup(self.currentTag, self.previous)
- if self.previous:
- self.previous.next = o
- self.previous = o
- self.currentTag.contents.append(o)
-
-
- def _popToTag(self, name, inclusivePop=True):
- """Pops the tag stack up to and including the most recent
- instance of the given tag. If inclusivePop is false, pops the tag
- stack up to but *not* including the most recent instqance of
- the given tag."""
- #print "Popping to %s" % name
- if name == self.ROOT_TAG_NAME:
- return
-
- numPops = 0
- mostRecentTag = None
- for i in range(len(self.tagStack)-1, 0, -1):
- if name == self.tagStack[i].name:
- numPops = len(self.tagStack)-i
- break
- if not inclusivePop:
- numPops = numPops - 1
-
- for i in range(0, numPops):
- mostRecentTag = self.popTag()
- return mostRecentTag
-
- def _smartPop(self, name):
-
- """We need to pop up to the previous tag of this type, unless
- one of this tag's nesting reset triggers comes between this
- tag and the previous tag of this type, OR unless this tag is a
- generic nesting trigger and another generic nesting trigger
- comes between this tag and the previous tag of this type.
-
- Examples:
- <p>Foo<b>Bar *<p>* should pop to 'p', not 'b'.
- <p>Foo<table>Bar *<p>* should pop to 'table', not 'p'.
- <p>Foo<table><tr>Bar *<p>* should pop to 'tr', not 'p'.
-
- <li><ul><li> *<li>* should pop to 'ul', not the first 'li'.
- <tr><table><tr> *<tr>* should pop to 'table', not the first 'tr'
- <td><tr><td> *<td>* should pop to 'tr', not the first 'td'
- """
-
- nestingResetTriggers = self.NESTABLE_TAGS.get(name)
- isNestable = nestingResetTriggers != None
- isResetNesting = self.RESET_NESTING_TAGS.has_key(name)
- popTo = None
- inclusive = True
- for i in range(len(self.tagStack)-1, 0, -1):
- p = self.tagStack[i]
- if (not p or p.name == name) and not isNestable:
- #Non-nestable tags get popped to the top or to their
- #last occurance.
- popTo = name
- break
- if (nestingResetTriggers != None
- and p.name in nestingResetTriggers) \
- or (nestingResetTriggers == None and isResetNesting
- and self.RESET_NESTING_TAGS.has_key(p.name)):
-
- #If we encounter one of the nesting reset triggers
- #peculiar to this tag, or we encounter another tag
- #that causes nesting to reset, pop up to but not
- #including that tag.
- popTo = p.name
- inclusive = False
- break
- p = p.parent
- if popTo:
- self._popToTag(popTo, inclusive)
-
- def unknown_starttag(self, name, attrs, selfClosing=0):
- #print "Start tag %s: %s" % (name, attrs)
- if self.quoteStack:
- #This is not a real tag.
- #print "<%s> is not real!" % name
- attrs = ''.join(map(lambda(x, y): ' %s="%s"' % (x, y), attrs))
- self.handle_data('<%s%s>' % (name, attrs))
- return
- self.endData()
-
- if not self.isSelfClosingTag(name) and not selfClosing:
- self._smartPop(name)
-
- if self.parseOnlyThese and len(self.tagStack) <= 1 \
- and (self.parseOnlyThese.text or not self.parseOnlyThese.searchTag(name, attrs)):
- return
-
- tag = Tag(self, name, attrs, self.currentTag, self.previous)
- if self.previous:
- self.previous.next = tag
- self.previous = tag
- self.pushTag(tag)
- if selfClosing or self.isSelfClosingTag(name):
- self.popTag()
- if name in self.QUOTE_TAGS:
- #print "Beginning quote (%s)" % name
- self.quoteStack.append(name)
- self.literal = 1
- return tag
-
- def unknown_endtag(self, name):
- #print "End tag %s" % name
- if self.quoteStack and self.quoteStack[-1] != name:
- #This is not a real end tag.
- #print "</%s> is not real!" % name
- self.handle_data('</%s>' % name)
- return
- self.endData()
- self._popToTag(name)
- if self.quoteStack and self.quoteStack[-1] == name:
- self.quoteStack.pop()
- self.literal = (len(self.quoteStack) > 0)
-
- def handle_data(self, data):
- self.currentData.append(data)
-
- def _toStringSubclass(self, text, subclass):
- """Adds a certain piece of text to the tree as a NavigableString
- subclass."""
- self.endData()
- self.handle_data(text)
- self.endData(subclass)
-
- def handle_pi(self, text):
- """Handle a processing instruction as a ProcessingInstruction
- object, possibly one with a %SOUP-ENCODING% slot into which an
- encoding will be plugged later."""
- if text[:3] == "xml":
- text = u"xml version='1.0' encoding='%SOUP-ENCODING%'"
- self._toStringSubclass(text, ProcessingInstruction)
-
- def handle_comment(self, text):
- "Handle comments as Comment objects."
- self._toStringSubclass(text, Comment)
-
- def handle_charref(self, ref):
- "Handle character references as data."
- if self.convertEntities:
- data = unichr(int(ref))
- else:
- data = '&#%s;' % ref
- self.handle_data(data)
-
- def handle_entityref(self, ref):
- """Handle entity references as data, possibly converting known
- HTML and/or XML entity references to the corresponding Unicode
- characters."""
- data = None
- if self.convertHTMLEntities:
- try:
- data = unichr(name2codepoint[ref])
- except KeyError:
- pass
-
- if not data and self.convertXMLEntities:
- data = self.XML_ENTITIES_TO_SPECIAL_CHARS.get(ref)
-
- if not data and self.convertHTMLEntities and \
- not self.XML_ENTITIES_TO_SPECIAL_CHARS.get(ref):
- # TODO: We've got a problem here. We're told this is
- # an entity reference, but it's not an XML entity
- # reference or an HTML entity reference. Nonetheless,
- # the logical thing to do is to pass it through as an
- # unrecognized entity reference.
- #
- # Except: when the input is "&carol;" this function
- # will be called with input "carol". When the input is
- # "AT&T", this function will be called with input
- # "T". We have no way of knowing whether a semicolon
- # was present originally, so we don't know whether
- # this is an unknown entity or just a misplaced
- # ampersand.
- #
- # The more common case is a misplaced ampersand, so I
- # escape the ampersand and omit the trailing semicolon.
- data = "&amp;%s" % ref
- if not data:
- # This case is different from the one above, because we
- # haven't already gone through a supposedly comprehensive
- # mapping of entities to Unicode characters. We might not
- # have gone through any mapping at all. So the chances are
- # very high that this is a real entity, and not a
- # misplaced ampersand.
- data = "&%s;" % ref
- self.handle_data(data)
-
- def handle_decl(self, data):
- "Handle DOCTYPEs and the like as Declaration objects."
- self._toStringSubclass(data, Declaration)
-
- def parse_declaration(self, i):
- """Treat a bogus SGML declaration as raw data. Treat a CDATA
- declaration as a CData object."""
- j = None
- if self.rawdata[i:i+9] == '<![CDATA[':
- k = self.rawdata.find(']]>', i)
- if k == -1:
- k = len(self.rawdata)
- data = self.rawdata[i+9:k]
- j = k+3
- self._toStringSubclass(data, CData)
- else:
- try:
- j = SGMLParser.parse_declaration(self, i)
- except SGMLParseError:
- toHandle = self.rawdata[i:]
- self.handle_data(toHandle)
- j = i + len(toHandle)
- return j
-
-class BeautifulSoup(BeautifulStoneSoup):
-
- """This parser knows the following facts about HTML:
-
- * Some tags have no closing tag and should be interpreted as being
- closed as soon as they are encountered.
-
- * The text inside some tags (ie. 'script') may contain tags which
- are not really part of the document and which should be parsed
- as text, not tags. If you want to parse the text as tags, you can
- always fetch it and parse it explicitly.
-
- * Tag nesting rules:
-
- Most tags can't be nested at all. For instance, the occurance of
- a <p> tag should implicitly close the previous <p> tag.
-
- <p>Para1<p>Para2
- should be transformed into:
- <p>Para1</p><p>Para2
-
- Some tags can be nested arbitrarily. For instance, the occurance
- of a <blockquote> tag should _not_ implicitly close the previous
- <blockquote> tag.
-
- Alice said: <blockquote>Bob said: <blockquote>Blah
- should NOT be transformed into:
- Alice said: <blockquote>Bob said: </blockquote><blockquote>Blah
-
- Some tags can be nested, but the nesting is reset by the
- interposition of other tags. For instance, a <tr> tag should
- implicitly close the previous <tr> tag within the same <table>,
- but not close a <tr> tag in another table.
-
- <table><tr>Blah<tr>Blah
- should be transformed into:
- <table><tr>Blah</tr><tr>Blah
- but,
- <tr>Blah<table><tr>Blah
- should NOT be transformed into
- <tr>Blah<table></tr><tr>Blah
-
- Differing assumptions about tag nesting rules are a major source
- of problems with the BeautifulSoup class. If BeautifulSoup is not
- treating as nestable a tag your page author treats as nestable,
- try ICantBelieveItsBeautifulSoup, MinimalSoup, or
- BeautifulStoneSoup before writing your own subclass."""
-
- def __init__(self, *args, **kwargs):
- if not kwargs.has_key('smartQuotesTo'):
- kwargs['smartQuotesTo'] = self.HTML_ENTITIES
- BeautifulStoneSoup.__init__(self, *args, **kwargs)
-
- SELF_CLOSING_TAGS = buildTagMap(None,
- ['br' , 'hr', 'input', 'img', 'meta',
- 'spacer', 'link', 'frame', 'base'])
-
- QUOTE_TAGS = {'script' : None, 'textarea' : None}
-
- #According to the HTML standard, each of these inline tags can
- #contain another tag of the same type. Furthermore, it's common
- #to actually use these tags this way.
- NESTABLE_INLINE_TAGS = ['span', 'font', 'q', 'object', 'bdo', 'sub', 'sup',
- 'center']
-
- #According to the HTML standard, these block tags can contain
- #another tag of the same type. Furthermore, it's common
- #to actually use these tags this way.
- NESTABLE_BLOCK_TAGS = ['blockquote', 'div', 'fieldset', 'ins', 'del']
-
- #Lists can contain other lists, but there are restrictions.
- NESTABLE_LIST_TAGS = { 'ol' : [],
- 'ul' : [],
- 'li' : ['ul', 'ol'],
- 'dl' : [],
- 'dd' : ['dl'],
- 'dt' : ['dl'] }
-
- #Tables can contain other tables, but there are restrictions.
- NESTABLE_TABLE_TAGS = {'table' : [],
- 'tr' : ['table', 'tbody', 'tfoot', 'thead'],
- 'td' : ['tr'],
- 'th' : ['tr'],
- 'thead' : ['table'],
- 'tbody' : ['table'],
- 'tfoot' : ['table'],
- }
-
- NON_NESTABLE_BLOCK_TAGS = ['address', 'form', 'p', 'pre']
-
- #If one of these tags is encountered, all tags up to the next tag of
- #this type are popped.
- RESET_NESTING_TAGS = buildTagMap(None, NESTABLE_BLOCK_TAGS, 'noscript',
- NON_NESTABLE_BLOCK_TAGS,
- NESTABLE_LIST_TAGS,
- NESTABLE_TABLE_TAGS)
-
- NESTABLE_TAGS = buildTagMap([], NESTABLE_INLINE_TAGS, NESTABLE_BLOCK_TAGS,
- NESTABLE_LIST_TAGS, NESTABLE_TABLE_TAGS)
-
- # Used to detect the charset in a META tag; see start_meta
- CHARSET_RE = re.compile("((^|;)\s*charset=)([^;]*)")
-
- def start_meta(self, attrs):
- """Beautiful Soup can detect a charset included in a META tag,
- try to convert the document to that charset, and re-parse the
- document from the beginning."""
- httpEquiv = None
- contentType = None
- contentTypeIndex = None
- tagNeedsEncodingSubstitution = False
-
- for i in range(0, len(attrs)):
- key, value = attrs[i]
- key = key.lower()
- if key == 'http-equiv':
- httpEquiv = value
- elif key == 'content':
- contentType = value
- contentTypeIndex = i
-
- if httpEquiv and contentType: # It's an interesting meta tag.
- match = self.CHARSET_RE.search(contentType)
- if match:
- if getattr(self, 'declaredHTMLEncoding') or \
- (self.originalEncoding == self.fromEncoding):
- # This is our second pass through the document, or
- # else an encoding was specified explicitly and it
- # worked. Rewrite the meta tag.
- newAttr = self.CHARSET_RE.sub\
- (lambda(match):match.group(1) +
- "%SOUP-ENCODING%", contentType)
- attrs[contentTypeIndex] = (attrs[contentTypeIndex][0],
- newAttr)
- tagNeedsEncodingSubstitution = True
- else:
- # This is our first pass through the document.
- # Go through it again with the new information.
- newCharset = match.group(3)
- if newCharset and newCharset != self.originalEncoding:
- self.declaredHTMLEncoding = newCharset
- self._feed(self.declaredHTMLEncoding)
- raise StopParsing
- tag = self.unknown_starttag("meta", attrs)
- if tag and tagNeedsEncodingSubstitution:
- tag.containsSubstitutions = True
-
-class StopParsing(Exception):
- pass
-
-class ICantBelieveItsBeautifulSoup(BeautifulSoup):
-
- """The BeautifulSoup class is oriented towards skipping over
- common HTML errors like unclosed tags. However, sometimes it makes
- errors of its own. For instance, consider this fragment:
-
- <b>Foo<b>Bar</b></b>
-
- This is perfectly valid (if bizarre) HTML. However, the
- BeautifulSoup class will implicitly close the first b tag when it
- encounters the second 'b'. It will think the author wrote
- "<b>Foo<b>Bar", and didn't close the first 'b' tag, because
- there's no real-world reason to bold something that's already
- bold. When it encounters '</b></b>' it will close two more 'b'
- tags, for a grand total of three tags closed instead of two. This
- can throw off the rest of your document structure. The same is
- true of a number of other tags, listed below.
-
- It's much more common for someone to forget to close a 'b' tag
- than to actually use nested 'b' tags, and the BeautifulSoup class
- handles the common case. This class handles the not-co-common
- case: where you can't believe someone wrote what they did, but
- it's valid HTML and BeautifulSoup screwed up by assuming it
- wouldn't be."""
-
- I_CANT_BELIEVE_THEYRE_NESTABLE_INLINE_TAGS = \
- ['em', 'big', 'i', 'small', 'tt', 'abbr', 'acronym', 'strong',
- 'cite', 'code', 'dfn', 'kbd', 'samp', 'strong', 'var', 'b',
- 'big']
-
- I_CANT_BELIEVE_THEYRE_NESTABLE_BLOCK_TAGS = ['noscript']
-
- NESTABLE_TAGS = buildTagMap([], BeautifulSoup.NESTABLE_TAGS,
- I_CANT_BELIEVE_THEYRE_NESTABLE_BLOCK_TAGS,
- I_CANT_BELIEVE_THEYRE_NESTABLE_INLINE_TAGS)
-
-class MinimalSoup(BeautifulSoup):
- """The MinimalSoup class is for parsing HTML that contains
- pathologically bad markup. It makes no assumptions about tag
- nesting, but it does know which tags are self-closing, that
- <script> tags contain Javascript and should not be parsed, that
- META tags may contain encoding information, and so on.
-
- This also makes it better for subclassing than BeautifulStoneSoup
- or BeautifulSoup."""
-
- RESET_NESTING_TAGS = buildTagMap('noscript')
- NESTABLE_TAGS = {}
-
-class BeautifulSOAP(BeautifulStoneSoup):
- """This class will push a tag with only a single string child into
- the tag's parent as an attribute. The attribute's name is the tag
- name, and the value is the string child. An example should give
- the flavor of the change:
-
- <foo><bar>baz</bar></foo>
- =>
- <foo bar="baz"><bar>baz</bar></foo>
-
- You can then access fooTag['bar'] instead of fooTag.barTag.string.
-
- This is, of course, useful for scraping structures that tend to
- use subelements instead of attributes, such as SOAP messages. Note
- that it modifies its input, so don't print the modified version
- out.
-
- I'm not sure how many people really want to use this class; let me
- know if you do. Mainly I like the name."""
-
- def popTag(self):
- if len(self.tagStack) > 1:
- tag = self.tagStack[-1]
- parent = self.tagStack[-2]
- parent._getAttrMap()
- if (isinstance(tag, Tag) and len(tag.contents) == 1 and
- isinstance(tag.contents[0], NavigableString) and
- not parent.attrMap.has_key(tag.name)):
- parent[tag.name] = tag.contents[0]
- BeautifulStoneSoup.popTag(self)
-
-#Enterprise class names! It has come to our attention that some people
-#think the names of the Beautiful Soup parser classes are too silly
-#and "unprofessional" for use in enterprise screen-scraping. We feel
-#your pain! For such-minded folk, the Beautiful Soup Consortium And
-#All-Night Kosher Bakery recommends renaming this file to
-#"RobustParser.py" (or, in cases of extreme enterprisiness,
-#"RobustParserBeanInterface.class") and using the following
-#enterprise-friendly class aliases:
-class RobustXMLParser(BeautifulStoneSoup):
- pass
-class RobustHTMLParser(BeautifulSoup):
- pass
-class RobustWackAssHTMLParser(ICantBelieveItsBeautifulSoup):
- pass
-class RobustInsanelyWackAssHTMLParser(MinimalSoup):
- pass
-class SimplifyingSOAPParser(BeautifulSOAP):
- pass
-
-######################################################
-#
-# Bonus library: Unicode, Dammit
-#
-# This class forces XML data into a standard format (usually to UTF-8
-# or Unicode). It is heavily based on code from Mark Pilgrim's
-# Universal Feed Parser. It does not rewrite the XML or HTML to
-# reflect a new encoding: that happens in BeautifulStoneSoup.handle_pi
-# (XML) and BeautifulSoup.start_meta (HTML).
-
-# Autodetects character encodings.
-# Download from http://chardet.feedparser.org/
-try:
- import chardet
-# import chardet.constants
-# chardet.constants._debug = 1
-except ImportError:
- chardet = None
-
-# cjkcodecs and iconv_codec make Python know about more character encodings.
-# Both are available from http://cjkpython.i18n.org/
-# They're built in if you use Python 2.4.
-try:
- import cjkcodecs.aliases
-except ImportError:
- pass
-try:
- import iconv_codec
-except ImportError:
- pass
-
-class UnicodeDammit:
- """A class for detecting the encoding of a *ML document and
- converting it to a Unicode string. If the source encoding is
- windows-1252, can replace MS smart quotes with their HTML or XML
- equivalents."""
-
- # This dictionary maps commonly seen values for "charset" in HTML
- # meta tags to the corresponding Python codec names. It only covers
- # values that aren't in Python's aliases and can't be determined
- # by the heuristics in find_codec.
- CHARSET_ALIASES = { "macintosh" : "mac-roman",
- "x-sjis" : "shift-jis" }
-
- def __init__(self, markup, overrideEncodings=[],
- smartQuotesTo='xml'):
- self.markup, documentEncoding, sniffedEncoding = \
- self._detectEncoding(markup)
- self.smartQuotesTo = smartQuotesTo
- self.triedEncodings = []
- if markup == '' or isinstance(markup, unicode):
- self.originalEncoding = None
- self.unicode = unicode(markup)
- return
-
- u = None
- for proposedEncoding in overrideEncodings:
- u = self._convertFrom(proposedEncoding)
- if u: break
- if not u:
- for proposedEncoding in (documentEncoding, sniffedEncoding):
- u = self._convertFrom(proposedEncoding)
- if u: break
-
- # If no luck and we have auto-detection library, try that:
- if not u and chardet and not isinstance(self.markup, unicode):
- u = self._convertFrom(chardet.detect(self.markup)['encoding'])
-
- # As a last resort, try utf-8 and windows-1252:
- if not u:
- for proposed_encoding in ("utf-8", "windows-1252"):
- u = self._convertFrom(proposed_encoding)
- if u: break
- self.unicode = u
- if not u: self.originalEncoding = None
-
- def _subMSChar(self, orig):
- """Changes a MS smart quote character to an XML or HTML
- entity."""
- sub = self.MS_CHARS.get(orig)
- if type(sub) == types.TupleType:
- if self.smartQuotesTo == 'xml':
- sub = '&#x%s;' % sub[1]
- else:
- sub = '&%s;' % sub[0]
- return sub
-
- def _convertFrom(self, proposed):
- proposed = self.find_codec(proposed)
- if not proposed or proposed in self.triedEncodings:
- return None
- self.triedEncodings.append(proposed)
- markup = self.markup
-
- # Convert smart quotes to HTML if coming from an encoding
- # that might have them.
- if self.smartQuotesTo and proposed.lower() in("windows-1252",
- "iso-8859-1",
- "iso-8859-2"):
- markup = re.compile("([\x80-\x9f])").sub \
- (lambda(x): self._subMSChar(x.group(1)),
- markup)
-
- try:
- # print "Trying to convert document to %s" % proposed
- u = self._toUnicode(markup, proposed)
- self.markup = u
- self.originalEncoding = proposed
- except Exception, e:
- # print "That didn't work!"
- # print e
- return None
- #print "Correct encoding: %s" % proposed
- return self.markup
-
- def _toUnicode(self, data, encoding):
- '''Given a string and its encoding, decodes the string into Unicode.
- %encoding is a string recognized by encodings.aliases'''
-
- # strip Byte Order Mark (if present)
- if (len(data) >= 4) and (data[:2] == '\xfe\xff') \
- and (data[2:4] != '\x00\x00'):
- encoding = 'utf-16be'
- data = data[2:]
- elif (len(data) >= 4) and (data[:2] == '\xff\xfe') \
- and (data[2:4] != '\x00\x00'):
- encoding = 'utf-16le'
- data = data[2:]
- elif data[:3] == '\xef\xbb\xbf':
- encoding = 'utf-8'
- data = data[3:]
- elif data[:4] == '\x00\x00\xfe\xff':
- encoding = 'utf-32be'
- data = data[4:]
- elif data[:4] == '\xff\xfe\x00\x00':
- encoding = 'utf-32le'
- data = data[4:]
- newdata = unicode(data, encoding)
- return newdata
-
- def _detectEncoding(self, xml_data):
- """Given a document, tries to detect its XML encoding."""
- xml_encoding = sniffed_xml_encoding = None
- try:
- if xml_data[:4] == '\x4c\x6f\xa7\x94':
- # EBCDIC
- xml_data = self._ebcdic_to_ascii(xml_data)
- elif xml_data[:4] == '\x00\x3c\x00\x3f':
- # UTF-16BE
- sniffed_xml_encoding = 'utf-16be'
- xml_data = unicode(xml_data, 'utf-16be').encode('utf-8')
- elif (len(xml_data) >= 4) and (xml_data[:2] == '\xfe\xff') \
- and (xml_data[2:4] != '\x00\x00'):
- # UTF-16BE with BOM
- sniffed_xml_encoding = 'utf-16be'
- xml_data = unicode(xml_data[2:], 'utf-16be').encode('utf-8')
- elif xml_data[:4] == '\x3c\x00\x3f\x00':
- # UTF-16LE
- sniffed_xml_encoding = 'utf-16le'
- xml_data = unicode(xml_data, 'utf-16le').encode('utf-8')
- elif (len(xml_data) >= 4) and (xml_data[:2] == '\xff\xfe') and \
- (xml_data[2:4] != '\x00\x00'):
- # UTF-16LE with BOM
- sniffed_xml_encoding = 'utf-16le'
- xml_data = unicode(xml_data[2:], 'utf-16le').encode('utf-8')
- elif xml_data[:4] == '\x00\x00\x00\x3c':
- # UTF-32BE
- sniffed_xml_encoding = 'utf-32be'
- xml_data = unicode(xml_data, 'utf-32be').encode('utf-8')
- elif xml_data[:4] == '\x3c\x00\x00\x00':
- # UTF-32LE
- sniffed_xml_encoding = 'utf-32le'
- xml_data = unicode(xml_data, 'utf-32le').encode('utf-8')
- elif xml_data[:4] == '\x00\x00\xfe\xff':
- # UTF-32BE with BOM
- sniffed_xml_encoding = 'utf-32be'
- xml_data = unicode(xml_data[4:], 'utf-32be').encode('utf-8')
- elif xml_data[:4] == '\xff\xfe\x00\x00':
- # UTF-32LE with BOM
- sniffed_xml_encoding = 'utf-32le'
- xml_data = unicode(xml_data[4:], 'utf-32le').encode('utf-8')
- elif xml_data[:3] == '\xef\xbb\xbf':
- # UTF-8 with BOM
- sniffed_xml_encoding = 'utf-8'
- xml_data = unicode(xml_data[3:], 'utf-8').encode('utf-8')
- else:
- sniffed_xml_encoding = 'ascii'
- pass
- xml_encoding_match = re.compile \
- ('^<\?.*encoding=[\'"](.*?)[\'"].*\?>')\
- .match(xml_data)
- except:
- xml_encoding_match = None
- if xml_encoding_match:
- xml_encoding = xml_encoding_match.groups()[0].lower()
- if sniffed_xml_encoding and \
- (xml_encoding in ('iso-10646-ucs-2', 'ucs-2', 'csunicode',
- 'iso-10646-ucs-4', 'ucs-4', 'csucs4',
- 'utf-16', 'utf-32', 'utf_16', 'utf_32',
- 'utf16', 'u16')):
- xml_encoding = sniffed_xml_encoding
- return xml_data, xml_encoding, sniffed_xml_encoding
-
-
- def find_codec(self, charset):
- return self._codec(self.CHARSET_ALIASES.get(charset, charset)) \
- or (charset and self._codec(charset.replace("-", ""))) \
- or (charset and self._codec(charset.replace("-", "_"))) \
- or charset
-
- def _codec(self, charset):
- if not charset: return charset
- codec = None
- try:
- codecs.lookup(charset)
- codec = charset
- except (LookupError, ValueError):
- pass
- return codec
-
- EBCDIC_TO_ASCII_MAP = None
- def _ebcdic_to_ascii(self, s):
- c = self.__class__
- if not c.EBCDIC_TO_ASCII_MAP:
- emap = (0,1,2,3,156,9,134,127,151,141,142,11,12,13,14,15,
- 16,17,18,19,157,133,8,135,24,25,146,143,28,29,30,31,
- 128,129,130,131,132,10,23,27,136,137,138,139,140,5,6,7,
- 144,145,22,147,148,149,150,4,152,153,154,155,20,21,158,26,
- 32,160,161,162,163,164,165,166,167,168,91,46,60,40,43,33,
- 38,169,170,171,172,173,174,175,176,177,93,36,42,41,59,94,
- 45,47,178,179,180,181,182,183,184,185,124,44,37,95,62,63,
- 186,187,188,189,190,191,192,193,194,96,58,35,64,39,61,34,
- 195,97,98,99,100,101,102,103,104,105,196,197,198,199,200,
- 201,202,106,107,108,109,110,111,112,113,114,203,204,205,
- 206,207,208,209,126,115,116,117,118,119,120,121,122,210,
- 211,212,213,214,215,216,217,218,219,220,221,222,223,224,
- 225,226,227,228,229,230,231,123,65,66,67,68,69,70,71,72,
- 73,232,233,234,235,236,237,125,74,75,76,77,78,79,80,81,
- 82,238,239,240,241,242,243,92,159,83,84,85,86,87,88,89,
- 90,244,245,246,247,248,249,48,49,50,51,52,53,54,55,56,57,
- 250,251,252,253,254,255)
- import string
- c.EBCDIC_TO_ASCII_MAP = string.maketrans( \
- ''.join(map(chr, range(256))), ''.join(map(chr, emap)))
- return s.translate(c.EBCDIC_TO_ASCII_MAP)
-
- MS_CHARS = { '\x80' : ('euro', '20AC'),
- '\x81' : ' ',
- '\x82' : ('sbquo', '201A'),
- '\x83' : ('fnof', '192'),
- '\x84' : ('bdquo', '201E'),
- '\x85' : ('hellip', '2026'),
- '\x86' : ('dagger', '2020'),
- '\x87' : ('Dagger', '2021'),
- '\x88' : ('circ', '2C6'),
- '\x89' : ('permil', '2030'),
- '\x8A' : ('Scaron', '160'),
- '\x8B' : ('lsaquo', '2039'),
- '\x8C' : ('OElig', '152'),
- '\x8D' : '?',
- '\x8E' : ('#x17D', '17D'),
- '\x8F' : '?',
- '\x90' : '?',
- '\x91' : ('lsquo', '2018'),
- '\x92' : ('rsquo', '2019'),
- '\x93' : ('ldquo', '201C'),
- '\x94' : ('rdquo', '201D'),
- '\x95' : ('bull', '2022'),
- '\x96' : ('ndash', '2013'),
- '\x97' : ('mdash', '2014'),
- '\x98' : ('tilde', '2DC'),
- '\x99' : ('trade', '2122'),
- '\x9a' : ('scaron', '161'),
- '\x9b' : ('rsaquo', '203A'),
- '\x9c' : ('oelig', '153'),
- '\x9d' : '?',
- '\x9e' : ('#x17E', '17E'),
- '\x9f' : ('Yuml', ''),}
-
-#######################################################################
-
-
-#By default, act as an HTML pretty-printer.
-if __name__ == '__main__':
- import sys
- soup = BeautifulSoup(sys.stdin.read())
- print soup.prettify()
diff --git a/scrapy/trunk/scrapy/xlib/__init__.py b/scrapy/trunk/scrapy/xlib/__init__.py
deleted file mode 100644
index b79d73973..000000000
--- a/scrapy/trunk/scrapy/xlib/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""This directory contains third party modules used by Scrapy"""
diff --git a/scrapy/trunk/scrapy/xlib/lrucache.py b/scrapy/trunk/scrapy/xlib/lrucache.py
deleted file mode 100644
index 7f8752e5d..000000000
--- a/scrapy/trunk/scrapy/xlib/lrucache.py
+++ /dev/null
@@ -1,213 +0,0 @@
-# lrucache.py -- a simple LRU (Least-Recently-Used) cache class
-
-# Copyright 2004 Evan Prodromou <[email protected]>
-# Licensed under the Academic Free License 2.1
-
-# arch-tag: LRU cache main module
-
-"""a simple LRU (Least-Recently-Used) cache module
-
-This module provides very simple LRU (Least-Recently-Used) cache
-functionality.
-
-An *in-memory cache* is useful for storing the results of an
-'expensive' process (one that takes a lot of time or resources) for
-later re-use. Typical examples are accessing data from the filesystem,
-a database, or a network location. If you know you'll need to re-read
-the data again, it can help to keep it in a cache.
-
-You *can* use a Python dictionary as a cache for some purposes.
-However, if the results you're caching are large, or you have a lot of
-possible results, this can be impractical memory-wise.
-
-An *LRU cache*, on the other hand, only keeps _some_ of the results in
-memory, which keeps you from overusing resources. The cache is bounded
-by a maximum size; if you try to add more values to the cache, it will
-automatically discard the values that you haven't read or written to
-in the longest time. In other words, the least-recently-used items are
-discarded. [1]_
-
-.. [1]: 'Discarded' here means 'removed from the cache'.
-
-"""
-
-from __future__ import generators
-import time
-from heapq import heappush, heappop, heapify
-
-__version__ = "0.2"
-__all__ = ['CacheKeyError', 'LRUCache', 'DEFAULT_SIZE']
-__docformat__ = 'reStructuredText en'
-
-DEFAULT_SIZE = 16
-"""Default size of a new LRUCache object, if no 'size' argument is given."""
-
-class CacheKeyError(KeyError):
- """Error raised when cache requests fail
-
- When a cache record is accessed which no longer exists (or never did),
- this error is raised. To avoid it, you may want to check for the existence
- of a cache record before reading or deleting it."""
- pass
-
-class LRUCache(object):
- """Least-Recently-Used (LRU) cache.
-
- Instances of this class provide a least-recently-used (LRU) cache. They
- emulate a Python mapping type. You can use an LRU cache more or less like
- a Python dictionary, with the exception that objects you put into the
- cache may be discarded before you take them out.
-
- Some example usage::
-
- cache = LRUCache(32) # new cache
- cache['foo'] = get_file_contents('foo') # or whatever
-
- if 'foo' in cache: # if it's still in cache...
- # use cached version
- contents = cache['foo']
- else:
- # recalculate
- contents = get_file_contents('foo')
- # store in cache for next time
- cache['foo'] = contents
-
- print cache.size # Maximum size
-
- print len(cache) # 0 <= len(cache) <= cache.size
-
- cache.size = 10 # Auto-shrink on size assignment
-
- for i in range(50): # note: larger than cache size
- cache[i] = i
-
- if 0 not in cache: print 'Zero was discarded.'
-
- if 42 in cache:
- del cache[42] # Manual deletion
-
- for j in cache: # iterate (in LRU order)
- print j, cache[j] # iterator produces keys, not values
- """
-
- class __Node(object):
- """Record of a cached value. Not for public consumption."""
-
- def __init__(self, key, obj, timestamp):
- object.__init__(self)
- self.key = key
- self.obj = obj
- self.atime = timestamp
- self.mtime = self.atime
-
- def __cmp__(self, other):
- return cmp(self.atime, other.atime)
-
- def __repr__(self):
- return "<%s %s => %s (%s)>" % \
- (self.__class__, self.key, self.obj, \
- time.asctime(time.localtime(self.atime)))
-
- def __init__(self, size=DEFAULT_SIZE):
- # Check arguments
- if size <= 0:
- raise ValueError, size
- elif type(size) is not type(0):
- raise TypeError, size
- object.__init__(self)
- self.__heap = []
- self.__dict = {}
- self.size = size
- """Maximum size of the cache.
- If more than 'size' elements are added to the cache,
- the least-recently-used ones will be discarded."""
-
- def __len__(self):
- return len(self.__heap)
-
- def __contains__(self, key):
- return self.__dict.has_key(key)
-
- def __setitem__(self, key, obj):
- if self.__dict.has_key(key):
- node = self.__dict[key]
- node.obj = obj
- node.atime = time.time()
- node.mtime = node.atime
- heapify(self.__heap)
- else:
- # size may have been reset, so we loop
- while len(self.__heap) >= self.size:
- lru = heappop(self.__heap)
- del self.__dict[lru.key]
- node = self.__Node(key, obj, time.time())
- self.__dict[key] = node
- heappush(self.__heap, node)
-
- def __getitem__(self, key):
- if not self.__dict.has_key(key):
- raise CacheKeyError(key)
- else:
- node = self.__dict[key]
- node.atime = time.time()
- heapify(self.__heap)
- return node.obj
-
- def __delitem__(self, key):
- if not self.__dict.has_key(key):
- raise CacheKeyError(key)
- else:
- node = self.__dict[key]
- del self.__dict[key]
- self.__heap.remove(node)
- heapify(self.__heap)
- return node.obj
-
- def __iter__(self):
- copy = self.__heap[:]
- while len(copy) > 0:
- node = heappop(copy)
- yield node.key
- raise StopIteration
-
- def __setattr__(self, name, value):
- object.__setattr__(self, name, value)
- # automagically shrink heap on resize
- if name == 'size':
- while len(self.__heap) > value:
- lru = heappop(self.__heap)
- del self.__dict[lru.key]
-
- def __repr__(self):
- return "<%s (%d elements)>" % (str(self.__class__), len(self.__heap))
-
- def mtime(self, key):
- """Return the last modification time for the cache record with key.
- May be useful for cache instances where the stored values can get
- 'stale', such as caching file or network resource contents."""
- if not self.__dict.has_key(key):
- raise CacheKeyError(key)
- else:
- node = self.__dict[key]
- return node.mtime
-
-if __name__ == "__main__":
- cache = LRUCache(25)
- print cache
- for i in range(50):
- cache[i] = str(i)
- print cache
- if 46 in cache:
- del cache[46]
- print cache
- cache.size = 10
- print cache
- cache[46] = '46'
- print cache
- print len(cache)
- for c in cache:
- print c
- print cache
- print cache.mtime(46)
- for c in cache:
- print c
diff --git a/scrapy/trunk/scrapy/xlib/lsprofcalltree.py b/scrapy/trunk/scrapy/xlib/lsprofcalltree.py
deleted file mode 100644
index efedc5a92..000000000
--- a/scrapy/trunk/scrapy/xlib/lsprofcalltree.py
+++ /dev/null
@@ -1,119 +0,0 @@
-# lsprofcalltree.py: lsprof output which is readable by kcachegrind
-# David Allouche
-# Jp Calderone & Itamar Shtull-Trauring
-# Johan Dahlin
-
-import optparse
-import os
-import sys
-
-try:
- import cProfile
-except ImportError:
- raise SystemExit("This script requires cProfile from Python 2.5")
-
-def label(code):
- if isinstance(code, str):
- return ('~', 0, code) # built-in functions ('~' sorts at the end)
- else:
- return '%s %s:%d' % (code.co_name,
- code.co_filename,
- code.co_firstlineno)
-
-class KCacheGrind(object):
- def __init__(self, profiler):
- self.data = profiler.getstats()
- self.out_file = None
-
- def output(self, out_file):
- self.out_file = out_file
- print >> out_file, 'events: Ticks'
- self._print_summary()
- for entry in self.data:
- self._entry(entry)
-
- def _print_summary(self):
- max_cost = 0
- for entry in self.data:
- totaltime = int(entry.totaltime * 1000)
- max_cost = max(max_cost, totaltime)
- print >> self.out_file, 'summary: %d' % (max_cost,)
-
- def _entry(self, entry):
- out_file = self.out_file
-
- code = entry.code
- #print >> out_file, 'ob=%s' % (code.co_filename,)
- if isinstance(code, str):
- print >> out_file, 'fi=~'
- else:
- print >> out_file, 'fi=%s' % (code.co_filename,)
- print >> out_file, 'fn=%s' % (label(code),)
-
- inlinetime = int(entry.inlinetime * 1000)
- if isinstance(code, str):
- print >> out_file, '0 ', inlinetime
- else:
- print >> out_file, '%d %d' % (code.co_firstlineno, inlinetime)
-
- # recursive calls are counted in entry.calls
- if entry.calls:
- calls = entry.calls
- else:
- calls = []
-
- if isinstance(code, str):
- lineno = 0
- else:
- lineno = code.co_firstlineno
-
- for subentry in calls:
- self._subentry(lineno, subentry)
- print >> out_file
-
- def _subentry(self, lineno, subentry):
- out_file = self.out_file
- code = subentry.code
- #print >> out_file, 'cob=%s' % (code.co_filename,)
- print >> out_file, 'cfn=%s' % (label(code),)
- if isinstance(code, str):
- print >> out_file, 'cfi=~'
- print >> out_file, 'calls=%d 0' % (subentry.callcount,)
- else:
- print >> out_file, 'cfi=%s' % (code.co_filename,)
- print >> out_file, 'calls=%d %d' % (
- subentry.callcount, code.co_firstlineno)
-
- totaltime = int(subentry.totaltime * 1000)
- print >> out_file, '%d %d' % (lineno, totaltime)
-
-def main(args):
- usage = "%s [-o output_file_path] scriptfile [arg] ..."
- parser = optparse.OptionParser(usage=usage % sys.argv[0])
- parser.allow_interspersed_args = False
- parser.add_option('-o', '--outfile', dest="outfile",
- help="Save stats to <outfile>", default=None)
-
- if not sys.argv[1:]:
- parser.print_usage()
- sys.exit(2)
-
- options, args = parser.parse_args()
-
- if not options.outfile:
- options.outfile = '%s.log' % os.path.basename(args[0])
-
- sys.argv[:] = args
-
- prof = cProfile.Profile()
- try:
- try:
- prof = prof.run('execfile(%r)' % (sys.argv[0],))
- except SystemExit:
- pass
- finally:
- kg = KCacheGrind(prof)
- kg.output(file(options.outfile, 'w'))
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/scrapy/trunk/scrapy/xlib/pydispatch/__init__.py b/scrapy/trunk/scrapy/xlib/pydispatch/__init__.py
deleted file mode 100644
index 78511a0d8..000000000
--- a/scrapy/trunk/scrapy/xlib/pydispatch/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-"""Multi-consumer multi-producer dispatching mechanism
-"""
-__version__ = "2.0.0"
-__author__ = "Patrick K. O'Brien"
-__license__ = "BSD-style, see license.txt for details"
-
diff --git a/scrapy/trunk/scrapy/xlib/pydispatch/dispatcher.py b/scrapy/trunk/scrapy/xlib/pydispatch/dispatcher.py
deleted file mode 100644
index 413100b26..000000000
--- a/scrapy/trunk/scrapy/xlib/pydispatch/dispatcher.py
+++ /dev/null
@@ -1,497 +0,0 @@
-"""Multiple-producer-multiple-consumer signal-dispatching
-
-dispatcher is the core of the PyDispatcher system,
-providing the primary API and the core logic for the
-system.
-
-Module attributes of note:
-
- Any -- Singleton used to signal either "Any Sender" or
- "Any Signal". See documentation of the _Any class.
- Anonymous -- Singleton used to signal "Anonymous Sender"
- See documentation of the _Anonymous class.
-
-Internal attributes:
- WEAKREF_TYPES -- tuple of types/classes which represent
- weak references to receivers, and thus must be de-
- referenced on retrieval to retrieve the callable
- object
- connections -- { senderkey (id) : { signal : [receivers...]}}
- senders -- { senderkey (id) : weakref(sender) }
- used for cleaning up sender references on sender
- deletion
- sendersBack -- { receiverkey (id) : [senderkey (id)...] }
- used for cleaning up receiver references on receiver
- deletion, (considerably speeds up the cleanup process
- vs. the original code.)
-"""
-from __future__ import generators
-import types, weakref
-from pydispatch import saferef, robustapply, errors
-
-__author__ = "Patrick K. O'Brien <[email protected]>"
-__cvsid__ = "$Id$"
-__version__ = "$Revision: 1.1.1.1 $"[11:-2]
-
-try:
- True
-except NameError:
- True = 1==1
- False = 1==0
-
-class _Parameter:
- """Used to represent default parameter values."""
- def __repr__(self):
- return self.__class__.__name__
-
-class _Any(_Parameter):
- """Singleton used to signal either "Any Sender" or "Any Signal"
-
- The Any object can be used with connect, disconnect,
- send, or sendExact to signal that the parameter given
- Any should react to all senders/signals, not just
- a particular sender/signal.
- """
-Any = _Any()
-
-class _Anonymous(_Parameter):
- """Singleton used to signal "Anonymous Sender"
-
- The Anonymous object is used to signal that the sender
- of a message is not specified (as distinct from being
- "any sender"). Registering callbacks for Anonymous
- will only receive messages sent without senders. Sending
- with anonymous will only send messages to those receivers
- registered for Any or Anonymous.
-
- Note:
- The default sender for connect is Any, while the
- default sender for send is Anonymous. This has
- the effect that if you do not specify any senders
- in either function then all messages are routed
- as though there was a single sender (Anonymous)
- being used everywhere.
- """
-Anonymous = _Anonymous()
-
-WEAKREF_TYPES = (weakref.ReferenceType, saferef.BoundMethodWeakref)
-
-connections = {}
-senders = {}
-sendersBack = {}
-
-
-def connect(receiver, signal=Any, sender=Any, weak=True):
- """Connect receiver to sender for signal
-
- receiver -- a callable Python object which is to receive
- messages/signals/events. Receivers must be hashable
- objects.
-
- if weak is True, then receiver must be weak-referencable
- (more precisely saferef.safeRef() must be able to create
- a reference to the receiver).
-
- Receivers are fairly flexible in their specification,
- as the machinery in the robustApply module takes care
- of most of the details regarding figuring out appropriate
- subsets of the sent arguments to apply to a given
- receiver.
-
- Note:
- if receiver is itself a weak reference (a callable),
- it will be de-referenced by the system's machinery,
- so *generally* weak references are not suitable as
- receivers, though some use might be found for the
- facility whereby a higher-level library passes in
- pre-weakrefed receiver references.
-
- signal -- the signal to which the receiver should respond
-
- if Any, receiver will receive any signal from the
- indicated sender (which might also be Any, but is not
- necessarily Any).
-
- Otherwise must be a hashable Python object other than
- None (DispatcherError raised on None).
-
- sender -- the sender to which the receiver should respond
-
- if Any, receiver will receive the indicated signals
- from any sender.
-
- if Anonymous, receiver will only receive indicated
- signals from send/sendExact which do not specify a
- sender, or specify Anonymous explicitly as the sender.
-
- Otherwise can be any python object.
-
- weak -- whether to use weak references to the receiver
- By default, the module will attempt to use weak
- references to the receiver objects. If this parameter
- is false, then strong references will be used.
-
- returns None, may raise DispatcherTypeError
- """
- if signal is None:
- raise errors.DispatcherTypeError(
- 'Signal cannot be None (receiver=%r sender=%r)'%( receiver,sender)
- )
- if weak:
- receiver = saferef.safeRef(receiver, onDelete=_removeReceiver)
- senderkey = id(sender)
- if connections.has_key(senderkey):
- signals = connections[senderkey]
- else:
- connections[senderkey] = signals = {}
- # Keep track of senders for cleanup.
- # Is Anonymous something we want to clean up?
- if sender not in (None, Anonymous, Any):
- def remove(object, senderkey=senderkey):
- _removeSender(senderkey=senderkey)
- # Skip objects that can not be weakly referenced, which means
- # they won't be automatically cleaned up, but that's too bad.
- try:
- weakSender = weakref.ref(sender, remove)
- senders[senderkey] = weakSender
- except:
- pass
-
- receiverID = id(receiver)
- # get current set, remove any current references to
- # this receiver in the set, including back-references
- if signals.has_key(signal):
- receivers = signals[signal]
- _removeOldBackRefs(senderkey, signal, receiver, receivers)
- else:
- receivers = signals[signal] = []
- try:
- current = sendersBack.get( receiverID )
- if current is None:
- sendersBack[ receiverID ] = current = []
- if senderkey not in current:
- current.append(senderkey)
- except:
- pass
-
- receivers.append(receiver)
-
-
-
-def disconnect(receiver, signal=Any, sender=Any, weak=True):
- """Disconnect receiver from sender for signal
-
- receiver -- the registered receiver to disconnect
- signal -- the registered signal to disconnect
- sender -- the registered sender to disconnect
- weak -- the weakref state to disconnect
-
- disconnect reverses the process of connect,
- the semantics for the individual elements are
- logically equivalent to a tuple of
- (receiver, signal, sender, weak) used as a key
- to be deleted from the internal routing tables.
- (The actual process is slightly more complex
- but the semantics are basically the same).
-
- Note:
- Using disconnect is not required to cleanup
- routing when an object is deleted, the framework
- will remove routes for deleted objects
- automatically. It's only necessary to disconnect
- if you want to stop routing to a live object.
-
- returns None, may raise DispatcherTypeError or
- DispatcherKeyError
- """
- if signal is None:
- raise errors.DispatcherTypeError(
- 'Signal cannot be None (receiver=%r sender=%r)'%( receiver,sender)
- )
- if weak: receiver = saferef.safeRef(receiver)
- senderkey = id(sender)
- try:
- signals = connections[senderkey]
- receivers = signals[signal]
- except KeyError:
- raise errors.DispatcherKeyError(
- """No receivers found for signal %r from sender %r""" %(
- signal,
- sender
- )
- )
- try:
- # also removes from receivers
- _removeOldBackRefs(senderkey, signal, receiver, receivers)
- except ValueError:
- raise errors.DispatcherKeyError(
- """No connection to receiver %s for signal %s from sender %s""" %(
- receiver,
- signal,
- sender
- )
- )
- _cleanupConnections(senderkey, signal)
-
-def getReceivers( sender = Any, signal = Any ):
- """Get list of receivers from global tables
-
- This utility function allows you to retrieve the
- raw list of receivers from the connections table
- for the given sender and signal pair.
-
- Note:
- there is no guarantee that this is the actual list
- stored in the connections table, so the value
- should be treated as a simple iterable/truth value
- rather than, for instance a list to which you
- might append new records.
-
- Normally you would use liveReceivers( getReceivers( ...))
- to retrieve the actual receiver objects as an iterable
- object.
- """
- try:
- return connections[id(sender)][signal]
- except KeyError:
- return []
-
-def liveReceivers(receivers):
- """Filter sequence of receivers to get resolved, live receivers
-
- This is a generator which will iterate over
- the passed sequence, checking for weak references
- and resolving them, then returning all live
- receivers.
- """
- for receiver in receivers:
- if isinstance( receiver, WEAKREF_TYPES):
- # Dereference the weak reference.
- receiver = receiver()
- if receiver is not None:
- yield receiver
- else:
- yield receiver
-
-
-
-def getAllReceivers( sender = Any, signal = Any ):
- """Get list of all receivers from global tables
-
- This gets all receivers which should receive
- the given signal from sender, each receiver should
- be produced only once by the resulting generator
- """
- receivers = {}
- for set in (
- # Get receivers that receive *this* signal from *this* sender.
- getReceivers( sender, signal ),
- # Add receivers that receive *any* signal from *this* sender.
- getReceivers( sender, Any ),
- # Add receivers that receive *this* signal from *any* sender.
- getReceivers( Any, signal ),
- # Add receivers that receive *any* signal from *any* sender.
- getReceivers( Any, Any ),
- ):
- for receiver in set:
- if receiver: # filter out dead instance-method weakrefs
- try:
- if not receivers.has_key( receiver ):
- receivers[receiver] = 1
- yield receiver
- except TypeError:
- # dead weakrefs raise TypeError on hash...
- pass
-
-def send(signal=Any, sender=Anonymous, *arguments, **named):
- """Send signal from sender to all connected receivers.
-
- signal -- (hashable) signal value, see connect for details
-
- sender -- the sender of the signal
-
- if Any, only receivers registered for Any will receive
- the message.
-
- if Anonymous, only receivers registered to receive
- messages from Anonymous or Any will receive the message
-
- Otherwise can be any python object (normally one
- registered with a connect if you actually want
- something to occur).
-
- arguments -- positional arguments which will be passed to
- *all* receivers. Note that this may raise TypeErrors
- if the receivers do not allow the particular arguments.
- Note also that arguments are applied before named
- arguments, so they should be used with care.
-
- named -- named arguments which will be filtered according
- to the parameters of the receivers to only provide those
- acceptable to the receiver.
-
- Return a list of tuple pairs [(receiver, response), ... ]
-
- if any receiver raises an error, the error propagates back
- through send, terminating the dispatch loop, so it is quite
- possible to not have all receivers called if a raises an
- error.
- """
- # Call each receiver with whatever arguments it can accept.
- # Return a list of tuple pairs [(receiver, response), ... ].
- responses = []
- for receiver in liveReceivers(getAllReceivers(sender, signal)):
- response = robustapply.robustApply(
- receiver,
- signal=signal,
- sender=sender,
- *arguments,
- **named
- )
- responses.append((receiver, response))
- return responses
-def sendExact( signal=Any, sender=Anonymous, *arguments, **named ):
- """Send signal only to those receivers registered for exact message
-
- sendExact allows for avoiding Any/Anonymous registered
- handlers, sending only to those receivers explicitly
- registered for a particular signal on a particular
- sender.
- """
- responses = []
- for receiver in liveReceivers(getReceivers(sender, signal)):
- response = robustapply.robustApply(
- receiver,
- signal=signal,
- sender=sender,
- *arguments,
- **named
- )
- responses.append((receiver, response))
- return responses
-
-
-def _removeReceiver(receiver):
- """Remove receiver from connections."""
- if not sendersBack:
- # During module cleanup the mapping will be replaced with None
- return False
- backKey = id(receiver)
- for senderkey in sendersBack.get(backKey,()):
- try:
- signals = connections[senderkey].keys()
- except KeyError,err:
- pass
- else:
- for signal in signals:
- try:
- receivers = connections[senderkey][signal]
- except KeyError:
- pass
- else:
- try:
- receivers.remove( receiver )
- except Exception, err:
- pass
- _cleanupConnections(senderkey, signal)
- try:
- del sendersBack[ backKey ]
- except KeyError:
- pass
-
-def _cleanupConnections(senderkey, signal):
- """Delete any empty signals for senderkey. Delete senderkey if empty."""
- try:
- receivers = connections[senderkey][signal]
- except:
- pass
- else:
- if not receivers:
- # No more connected receivers. Therefore, remove the signal.
- try:
- signals = connections[senderkey]
- except KeyError:
- pass
- else:
- del signals[signal]
- if not signals:
- # No more signal connections. Therefore, remove the sender.
- _removeSender(senderkey)
-
-def _removeSender(senderkey):
- """Remove senderkey from connections."""
- _removeBackrefs(senderkey)
- try:
- del connections[senderkey]
- except KeyError:
- pass
- # Senderkey will only be in senders dictionary if sender
- # could be weakly referenced.
- try:
- del senders[senderkey]
- except:
- pass
-
-
-def _removeBackrefs( senderkey):
- """Remove all back-references to this senderkey"""
- try:
- signals = connections[senderkey]
- except KeyError:
- signals = None
- else:
- items = signals.items()
- def allReceivers( ):
- for signal,set in items:
- for item in set:
- yield item
- for receiver in allReceivers():
- _killBackref( receiver, senderkey )
-
-def _removeOldBackRefs(senderkey, signal, receiver, receivers):
- """Kill old sendersBack references from receiver
-
- This guards against multiple registration of the same
- receiver for a given signal and sender leaking memory
- as old back reference records build up.
-
- Also removes old receiver instance from receivers
- """
- try:
- index = receivers.index(receiver)
- # need to scan back references here and remove senderkey
- except ValueError:
- return False
- else:
- oldReceiver = receivers[index]
- del receivers[index]
- found = 0
- signals = connections.get(signal)
- if signals is not None:
- for sig,recs in connections.get(signal,{}).iteritems():
- if sig != signal:
- for rec in recs:
- if rec is oldReceiver:
- found = 1
- break
- if not found:
- _killBackref( oldReceiver, senderkey )
- return True
- return False
-
-
-def _killBackref( receiver, senderkey ):
- """Do the actual removal of back reference from receiver to senderkey"""
- receiverkey = id(receiver)
- set = sendersBack.get( receiverkey, () )
- while senderkey in set:
- try:
- set.remove( senderkey )
- except:
- break
- if not set:
- try:
- del sendersBack[ receiverkey ]
- except KeyError:
- pass
- return True
diff --git a/scrapy/trunk/scrapy/xlib/pydispatch/errors.py b/scrapy/trunk/scrapy/xlib/pydispatch/errors.py
deleted file mode 100644
index a2eb32ed7..000000000
--- a/scrapy/trunk/scrapy/xlib/pydispatch/errors.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""Error types for dispatcher mechanism
-"""
-
-class DispatcherError(Exception):
- """Base class for all Dispatcher errors"""
-class DispatcherKeyError(KeyError, DispatcherError):
- """Error raised when unknown (sender,signal) set specified"""
-class DispatcherTypeError(TypeError, DispatcherError):
- """Error raised when inappropriate signal-type specified (None)"""
-
diff --git a/scrapy/trunk/scrapy/xlib/pydispatch/license.txt b/scrapy/trunk/scrapy/xlib/pydispatch/license.txt
deleted file mode 100644
index 0960a6073..000000000
--- a/scrapy/trunk/scrapy/xlib/pydispatch/license.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-PyDispatcher License
-
- Copyright (c) 2001-2006, Patrick K. O'Brien and Contributors
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- The name of Patrick K. O'Brien, or the name of any Contributor,
- may not be used to endorse or promote products derived from this
- software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/scrapy/trunk/scrapy/xlib/pydispatch/robust.py b/scrapy/trunk/scrapy/xlib/pydispatch/robust.py
deleted file mode 100644
index 929f550c6..000000000
--- a/scrapy/trunk/scrapy/xlib/pydispatch/robust.py
+++ /dev/null
@@ -1,57 +0,0 @@
-"""Module implementing error-catching version of send (sendRobust)"""
-from pydispatch.dispatcher import Any, Anonymous, liveReceivers, getAllReceivers
-from pydispatch.robustapply import robustApply
-
-def sendRobust(
- signal=Any,
- sender=Anonymous,
- *arguments, **named
-):
- """Send signal from sender to all connected receivers catching errors
-
- signal -- (hashable) signal value, see connect for details
-
- sender -- the sender of the signal
-
- if Any, only receivers registered for Any will receive
- the message.
-
- if Anonymous, only receivers registered to receive
- messages from Anonymous or Any will receive the message
-
- Otherwise can be any python object (normally one
- registered with a connect if you actually want
- something to occur).
-
- arguments -- positional arguments which will be passed to
- *all* receivers. Note that this may raise TypeErrors
- if the receivers do not allow the particular arguments.
- Note also that arguments are applied before named
- arguments, so they should be used with care.
-
- named -- named arguments which will be filtered according
- to the parameters of the receivers to only provide those
- acceptable to the receiver.
-
- Return a list of tuple pairs [(receiver, response), ... ]
-
- if any receiver raises an error (specifically any subclass of Exception),
- the error instance is returned as the result for that receiver.
- """
- # Call each receiver with whatever arguments it can accept.
- # Return a list of tuple pairs [(receiver, response), ... ].
- responses = []
- for receiver in liveReceivers(getAllReceivers(sender, signal)):
- try:
- response = robustApply(
- receiver,
- signal=signal,
- sender=sender,
- *arguments,
- **named
- )
- except Exception, err:
- responses.append((receiver, err))
- else:
- responses.append((receiver, response))
- return responses
diff --git a/scrapy/trunk/scrapy/xlib/pydispatch/robustapply.py b/scrapy/trunk/scrapy/xlib/pydispatch/robustapply.py
deleted file mode 100644
index 0350e60cf..000000000
--- a/scrapy/trunk/scrapy/xlib/pydispatch/robustapply.py
+++ /dev/null
@@ -1,49 +0,0 @@
-"""Robust apply mechanism
-
-Provides a function "call", which can sort out
-what arguments a given callable object can take,
-and subset the given arguments to match only
-those which are acceptable.
-"""
-
-def function( receiver ):
- """Get function-like callable object for given receiver
-
- returns (function_or_method, codeObject, fromMethod)
-
- If fromMethod is true, then the callable already
- has its first argument bound
- """
- if hasattr(receiver, '__call__'):
- # receiver is a class instance; assume it is callable.
- # Reassign receiver to the actual method that will be called.
- if hasattr( receiver.__call__, 'im_func') or hasattr( receiver.__call__, 'im_code'):
- receiver = receiver.__call__
- if hasattr( receiver, 'im_func' ):
- # an instance-method...
- return receiver, receiver.im_func.func_code, 1
- elif not hasattr( receiver, 'func_code'):
- raise ValueError('unknown reciever type %s %s'%(receiver, type(receiver)))
- return receiver, receiver.func_code, 0
-
-def robustApply(receiver, *arguments, **named):
- """Call receiver with arguments and an appropriate subset of named
- """
- receiver, codeObject, startIndex = function( receiver )
- acceptable = codeObject.co_varnames[startIndex+len(arguments):codeObject.co_argcount]
- for name in codeObject.co_varnames[startIndex:startIndex+len(arguments)]:
- if named.has_key( name ):
- raise TypeError(
- """Argument %r specified both positionally and as a keyword for calling %r"""% (
- name, receiver,
- )
- )
- if not (codeObject.co_flags & 8):
- # fc does not have a **kwds type parameter, therefore
- # remove unacceptable arguments.
- for arg in named.keys():
- if arg not in acceptable:
- del named[arg]
- return receiver(*arguments, **named)
-
-
\ No newline at end of file
diff --git a/scrapy/trunk/scrapy/xlib/pydispatch/saferef.py b/scrapy/trunk/scrapy/xlib/pydispatch/saferef.py
deleted file mode 100644
index 6b3eda1d3..000000000
--- a/scrapy/trunk/scrapy/xlib/pydispatch/saferef.py
+++ /dev/null
@@ -1,165 +0,0 @@
-"""Refactored "safe reference" from dispatcher.py"""
-import weakref, traceback
-
-def safeRef(target, onDelete = None):
- """Return a *safe* weak reference to a callable target
-
- target -- the object to be weakly referenced, if it's a
- bound method reference, will create a BoundMethodWeakref,
- otherwise creates a simple weakref.
- onDelete -- if provided, will have a hard reference stored
- to the callable to be called after the safe reference
- goes out of scope with the reference object, (either a
- weakref or a BoundMethodWeakref) as argument.
- """
- if hasattr(target, 'im_self'):
- if target.im_self is not None:
- # Turn a bound method into a BoundMethodWeakref instance.
- # Keep track of these instances for lookup by disconnect().
- assert hasattr(target, 'im_func'), """safeRef target %r has im_self, but no im_func, don't know how to create reference"""%( target,)
- reference = BoundMethodWeakref(
- target=target,
- onDelete=onDelete
- )
- return reference
- if callable(onDelete):
- return weakref.ref(target, onDelete)
- else:
- return weakref.ref( target )
-
-class BoundMethodWeakref(object):
- """'Safe' and reusable weak references to instance methods
-
- BoundMethodWeakref objects provide a mechanism for
- referencing a bound method without requiring that the
- method object itself (which is normally a transient
- object) is kept alive. Instead, the BoundMethodWeakref
- object keeps weak references to both the object and the
- function which together define the instance method.
-
- Attributes:
- key -- the identity key for the reference, calculated
- by the class's calculateKey method applied to the
- target instance method
- deletionMethods -- sequence of callable objects taking
- single argument, a reference to this object which
- will be called when *either* the target object or
- target function is garbage collected (i.e. when
- this object becomes invalid). These are specified
- as the onDelete parameters of safeRef calls.
- weakSelf -- weak reference to the target object
- weakFunc -- weak reference to the target function
-
- Class Attributes:
- _allInstances -- class attribute pointing to all live
- BoundMethodWeakref objects indexed by the class's
- calculateKey(target) method applied to the target
- objects. This weak value dictionary is used to
- short-circuit creation so that multiple references
- to the same (object, function) pair produce the
- same BoundMethodWeakref instance.
-
- """
- _allInstances = weakref.WeakValueDictionary()
- def __new__( cls, target, onDelete=None, *arguments,**named ):
- """Create new instance or return current instance
-
- Basically this method of construction allows us to
- short-circuit creation of references to already-
- referenced instance methods. The key corresponding
- to the target is calculated, and if there is already
- an existing reference, that is returned, with its
- deletionMethods attribute updated. Otherwise the
- new instance is created and registered in the table
- of already-referenced methods.
- """
- key = cls.calculateKey(target)
- current =cls._allInstances.get(key)
- if current is not None:
- current.deletionMethods.append( onDelete)
- return current
- else:
- base = super( BoundMethodWeakref, cls).__new__( cls )
- cls._allInstances[key] = base
- base.__init__( target, onDelete, *arguments,**named)
- return base
- def __init__(self, target, onDelete=None):
- """Return a weak-reference-like instance for a bound method
-
- target -- the instance-method target for the weak
- reference, must have im_self and im_func attributes
- and be reconstructable via:
- target.im_func.__get__( target.im_self )
- which is true of built-in instance methods.
- onDelete -- optional callback which will be called
- when this weak reference ceases to be valid
- (i.e. either the object or the function is garbage
- collected). Should take a single argument,
- which will be passed a pointer to this object.
- """
- def remove(weak, self=self):
- """Set self.isDead to true when method or instance is destroyed"""
- methods = self.deletionMethods[:]
- del self.deletionMethods[:]
- try:
- del self.__class__._allInstances[ self.key ]
- except KeyError:
- pass
- for function in methods:
- try:
- if callable( function ):
- function( self )
- except Exception, e:
- try:
- traceback.print_exc()
- except AttributeError, err:
- print '''Exception during saferef %s cleanup function %s: %s'''%(
- self, function, e
- )
- self.deletionMethods = [onDelete]
- self.key = self.calculateKey( target )
- self.weakSelf = weakref.ref(target.im_self, remove)
- self.weakFunc = weakref.ref(target.im_func, remove)
- self.selfName = str(target.im_self)
- self.funcName = str(target.im_func.__name__)
- def calculateKey( cls, target ):
- """Calculate the reference key for this reference
-
- Currently this is a two-tuple of the id()'s of the
- target object and the target function respectively.
- """
- return (id(target.im_self),id(target.im_func))
- calculateKey = classmethod( calculateKey )
- def __str__(self):
- """Give a friendly representation of the object"""
- return """%s( %s.%s )"""%(
- self.__class__.__name__,
- self.selfName,
- self.funcName,
- )
- __repr__ = __str__
- def __nonzero__( self ):
- """Whether we are still a valid reference"""
- return self() is not None
- def __cmp__( self, other ):
- """Compare with another reference"""
- if not isinstance (other,self.__class__):
- return cmp( self.__class__, type(other) )
- return cmp( self.key, other.key)
- def __call__(self):
- """Return a strong reference to the bound method
-
- If the target cannot be retrieved, then will
- return None, otherwise returns a bound instance
- method for our object and function.
-
- Note:
- You may call this method any number of times,
- as it does not invalidate the reference.
- """
- target = self.weakSelf()
- if target is not None:
- function = self.weakFunc()
- if function is not None:
- return function.__get__(target)
- return None
diff --git a/scrapy/trunk/scrapy/xlib/spidermonkey/INSTALL.scrapy b/scrapy/trunk/scrapy/xlib/spidermonkey/INSTALL.scrapy
deleted file mode 100644
index 6eef8b6ee..000000000
--- a/scrapy/trunk/scrapy/xlib/spidermonkey/INSTALL.scrapy
+++ /dev/null
@@ -1,27 +0,0 @@
-Spidermonkey bindings for python (based on standard library ctypes)
-
-Quick instructions to install with scrapy package.
-
-* go to http://ftp.mozilla.org/pub/mozilla.org/js/ and download the
-release 1.7.0.
-
-* Extract the source, go to js/src and run make -f Makefile.ref
-
-* copy the file src/Linux_All_DBG.OBJ/libjs.so to /usr/lib
-and run ldconfig
-
-Testing
--------
-
-Please run python jstest.py after installation. This script contains
-some tests to corroborate that python bindings installation is OK.
-
-Known issues
-------------
-ctypes fails when loading the library, with old versions of libgcc. We have succeded tests with libgcc version 4.1.2 and higher, and failed with libgcc version libgcc-3.4.6. The exact error message in this case is:
-
-Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "/usr/lib64/python2.5/ctypes/__init__.py", line 340, in __init__
- self._handle = _dlopen(self._name, mode)
-OSError: /usr/lib/libjs.so.0: undefined symbol: __clzdi2
diff --git a/scrapy/trunk/scrapy/xlib/spidermonkey/__init__.py b/scrapy/trunk/scrapy/xlib/spidermonkey/__init__.py
deleted file mode 100644
index d29fbe2c5..000000000
--- a/scrapy/trunk/scrapy/xlib/spidermonkey/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from spidermonkey import *
\ No newline at end of file
diff --git a/scrapy/trunk/scrapy/xlib/spidermonkey/sm_settings.py b/scrapy/trunk/scrapy/xlib/spidermonkey/sm_settings.py
deleted file mode 100644
index 9b37284c3..000000000
--- a/scrapy/trunk/scrapy/xlib/spidermonkey/sm_settings.py
+++ /dev/null
@@ -1,2 +0,0 @@
-#defines order in which spidermonkey bin library will be searched
-try_libs = ["libmozjs.so.0d", "libjs.so", "libjs.so.0"]
\ No newline at end of file
diff --git a/scrapy/trunk/scrapy/xlib/spidermonkey/spidermonkey.py b/scrapy/trunk/scrapy/xlib/spidermonkey/spidermonkey.py
deleted file mode 100644
index 89e57da84..000000000
--- a/scrapy/trunk/scrapy/xlib/spidermonkey/spidermonkey.py
+++ /dev/null
@@ -1,2254 +0,0 @@
-# this is a ctypes-based python wrapper for mozilla spidermonkey
-
-# ************************************************************************
-# This is an alpha release. It has many known faults, and interfaces will
-# change.
-
-# Note that code listed with JavaScript error messages can be the WRONG
-# CODE! Don't take it seriously.
-# ************************************************************************
-
-# spidermonkey 0.0.2a: Python / JavaScript bridge.
-# Copyright (C) 2003 John J. Lee <[email protected]>
-# Copyright (C) 2006 Leonard Ritter <[email protected]>
-
-# Partly derived from Spidermonkey.xs, Copyright (C) 2001, Claes
-# Jacobsson, All Rights Reserved (Perl Artistic License).
-# Partly derived from PerlConnect (part of spidermonkey) Copyright (C)
-# 1998 Netscape Communications Corporation (GPL).
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-# Security constraints:
-# Can't add attributes to Python objects.
-# *Can* add JS properties to JS proxies of Python objects, as long as it
-# won't hide a Python attribute of the same name.
-# Can't assign to Python methods.
-# Can't access any Python attribute starting with "_".
-# Also, bound Python objects can of course implement their own
-# protection, as the Window class does.
-
-# XXX
-# Does JS expect some exceptions on reading a non-existent property?
-# Currently, this code has the effect of returning undef in that case,
-# which seems odd. Look in O'Reilly book / spidermonkey code.
-# Exception propagation. IIRC, I'm waiting for except * to be fixed in
-# Pyrex.
-# Code listings on JS errors are wrong.
-# Review code
-# Replace Object with Py_INCREF and just keeping python object in JS
-# object (need to think first, though, to check this will work).
-# API call return values and bad function arguments!
-# Memory management.
-# Check strcpy's, malloc's / free's / Destroy*'s.
-# Look for and fix any memory leaks.
-# To prevent people crashing module, would be nice to make some things
-# private. Ask on Pyrex list.
-# Make use of JS API security model?
-# GC issues (see spidermonkey GC tips page).
-# Threading issues (see GC tips again).
-
-from ctypes import *
-
-# predefines
-size_t = c_ulong
-_IO_FILE = c_ulong
-__ssize_t = c_int
-ssize_t = c_uint
-
-JSWord = c_long
-jsword = JSWord
-jsval = jsword
-
-class JSObject(Structure):
- _fields_ = [
- ]
-class ObjectJSVALUnion(Union):
- _fields_ = [
- ('jsval', jsval),
- ('obj', POINTER(JSObject)),
- ]
-
-def OBJECT_TO_JSVAL(obj):
- objectJSVALUnion = ObjectJSVALUnion()
- objectJSVALUnion.obj = obj
- return objectJSVALUnion.jsval
-
-# defines
-EOF = (-1)
-FILENAME_MAX = 4096
-FOPEN_MAX = 16
-def JS_BIT(n):
- return 1 << n
-def JS_BITMASK(n):
- return JS_BIT(n) - 1
-def JSVAL_SETTAG(v,t):
- if type(v) == c_long:
- v = v.value
- return v | t
-def BOOLEAN_TO_JSVAL(b):
- return JSVAL_SETTAG(b << JSVAL_TAGBITS, JSVAL_BOOLEAN)
-def JSVAL_INT_POW2(n):
- return 1 << n
-def INT_TO_JSVAL(i):
- return (i << 1) | JSVAL_INT
-def JSVAL_IS_PRIMITIVE(v):
- return ((not JSVAL_IS_OBJECT(v)) or JSVAL_IS_NULL(v))
-def JSVAL_IS_OBJECT(v):
- return (JSVAL_TAG(v) == JSVAL_OBJECT)
-def JSVAL_IS_INT(v):
- if type(v) == c_long:
- v = v.value
- return ((v & JSVAL_INT) and (v != JSVAL_VOID))
-def JSVAL_TO_INT(v):
- if type(v) == c_long:
- v = v.value
- return v >> 1
-def JSVAL_IS_DOUBLE(v):
- return (JSVAL_TAG(v) == JSVAL_DOUBLE)
-def JSVAL_TO_DOUBLE(v):
- return cast(JSVAL_TO_GCTHING(v),POINTER(jsdouble))
-def JSVAL_IS_BOOLEAN(v):
- return (JSVAL_TAG(v) == JSVAL_BOOLEAN)
-def JSVAL_TO_BOOLEAN(v):
- if type(v) == c_long:
- v = v.value
- return v >> JSVAL_TAGBITS
-def JSVAL_IS_STRING(v):
- return JSVAL_TAG(v) == JSVAL_STRING
-def JSVAL_TO_STRING(v):
- return cast(JSVAL_TO_GCTHING(v),POINTER(JSString))
-def STRING_TO_JSVAL(str):
- return JSVAL_SETTAG(cast(addressof(str),POINTER(jsval)).contents, JSVAL_STRING)
-def DOUBLE_TO_JSVAL(dp):
- return JSVAL_SETTAG(cast(addressof(dp),POINTER(jsval)).contents, JSVAL_DOUBLE)
-def JSVAL_TO_GCTHING(v):
- return cast(JSVAL_CLRTAG(v),c_void_p)
-def JSVAL_CLRTAG(v):
- if type(v) == c_long:
- v = v.value
- return v & (~JSVAL_TAGMASK)
-def JSVAL_TAG(v):
- if type(v) == c_long:
- v = v.value
- return v & JSVAL_TAGMASK
-def JSVAL_IS_NULL(v):
- if type(v) == c_long:
- v = v.value
- return v == JSVAL_NULL
-def JSVAL_IS_VOID(v):
- if type(v) == c_long:
- v = v.value
- return v == JSVAL_VOID
-def JSVAL_TO_OBJECT(v):
- return cast(JSVAL_TO_GCTHING(v), POINTER(JSObject))
-JSCLASS_HAS_PRIVATE = (1<<0)
-JSCLASS_NEW_ENUMERATE = (1<<1)
-JSCLASS_NEW_RESOLVE = (1<<2)
-JSCLASS_NEW_RESOLVE_GETS_START = (1<<5)
-JSCLASS_NO_OPTIONAL_MEMBERS = 0,0,0,0,0,0,0,0
-JSCLASS_PRIVATE_IS_NSISUPPORTS = (1<<3)
-JSCLASS_RESERVED_SLOTS_WIDTH = 8
-JSCLASS_RESERVED_SLOTS_MASK = JS_BITMASK(JSCLASS_RESERVED_SLOTS_WIDTH)
-JSCLASS_RESERVED_SLOTS_SHIFT = 8
-JSCLASS_SHARE_ALL_PROPERTIES = (1<<4)
-JSFUN_BOUND_METHOD = 0x40
-JSFUN_FLAGS_MASK = 0xf8
-JSFUN_HEAVYWEIGHT = 0x80
-JSFUN_LAMBDA = 0x08
-JSOPTION_COMPILE_N_GO = JS_BIT(4)
-JSOPTION_PRIVATE_IS_NSISUPPORTS = JS_BIT(3)
-JSOPTION_STRICT = JS_BIT(0)
-JSOPTION_VAROBJFIX = JS_BIT(2)
-JSOPTION_WERROR = JS_BIT(1)
-JSPROP_ENUMERATE = 0x01
-JSPROP_EXPORTED = 0x08
-JSPROP_GETTER = 0x10
-JSPROP_INDEX = 0x80
-JSPROP_PERMANENT = 0x04
-JSPROP_READONLY = 0x02
-JSPROP_SETTER = 0x20
-JSPROP_SHARED = 0x40
-JSREG_FOLD = 0x01
-JSREG_GLOB = 0x02
-JSREG_MULTILINE = 0x04
-JSREPORT_ERROR = 0x0
-JSREPORT_EXCEPTION = 0x2
-JSREPORT_STRICT = 0x4
-JSREPORT_WARNING = 0x1
-JSRESOLVE_ASSIGNING = 0x02
-JSRESOLVE_QUALIFIED = 0x01
-JSVAL_TAGBITS = 3
-JSVAL_ALIGN = JS_BIT(JSVAL_TAGBITS)
-JSVAL_BOOLEAN = 0x6
-JSVAL_DOUBLE = 0x2
-JS_FALSE = 0
-JSVAL_FALSE = BOOLEAN_TO_JSVAL(JS_FALSE)
-JSVAL_INT = 0x1
-JSVAL_INT_BITS = 31
-JSVAL_INT_MAX = (JSVAL_INT_POW2(30) - 1)
-JSVAL_INT_MIN = (1 - JSVAL_INT_POW2(30))
-JSVAL_NULL = 0
-JSVAL_OBJECT = 0x0
-JSVAL_ONE = INT_TO_JSVAL(1)
-JSVAL_STRING = 0x4
-JSVAL_TAGMASK = JS_BITMASK(JSVAL_TAGBITS)
-JS_TRUE = 1
-JSVAL_TRUE = BOOLEAN_TO_JSVAL(JS_TRUE)
-JSVAL_VOID = INT_TO_JSVAL(0 - JSVAL_INT_POW2(30))
-JSVAL_ZERO = INT_TO_JSVAL(0)
-JS_DONT_PRETTY_PRINT = (0x8000)
-JS_MAP_GCROOT_NEXT = 0
-JS_MAP_GCROOT_REMOVE = 2
-JS_MAP_GCROOT_STOP = 1
-SEEK_CUR = 1
-SEEK_END = 2
-SEEK_SET = 0
-TMP_MAX = 238328
-
-# using file "/usr/include/smjs/jslong.h"
-# using file "/usr/include/smjs/jscompat.h"
-# using file "/usr/include/smjs/jspubtd.h"
-# using file "/usr/include/smjs/jsapi.h"
-JSUintn = c_uint
-
-uintN = JSUintn
-
-class JSErrorFormatString(Structure):
- _fields_ = [
- ('format', c_char_p),
- ('argCount', uintN),
- ]
-
-JSErrorFormatString = JSErrorFormatString
-
-class JSContext(Structure):
- _fields_ = [
- ]
-
-JSContext = JSContext
-
-JSIntn = c_int
-
-JSBool = JSIntn
-
-JSInt32 = c_int
-
-int32 = JSInt32
-
-jsrefcount = int32
-
-class JSPrincipals(Structure):
- _fields_ = [
- ('codebase', c_char_p),
- ('getPrincipalArray', CFUNCTYPE(c_void_p,POINTER(JSContext),POINTER('JSPrincipals'))),
- ('globalPrivilegesEnabled', CFUNCTYPE(JSBool,POINTER(JSContext),POINTER('JSPrincipals'))),
- ('refcount', jsrefcount),
- ('destroy', CFUNCTYPE(None,POINTER(JSContext),POINTER('JSPrincipals'))),
- ]
-
-JSPrincipals = JSPrincipals
-
-jsid = jsword
-
-class JSProperty(Structure):
- _fields_ = [
- ('id', jsid),
- ]
-
-JSProperty = JSProperty
-
-class JSObjectMap(Structure):
- _fields_ = [
- ]
-
-JSObjectMap = JSObjectMap
-
-class JSXDRState(Structure):
- _fields_ = [
- ]
-
-JSXDRState = JSXDRState
-
-class JSObjectOps(Structure):
- _fields_ = []
-
-JSUint32 = c_uint
-
-uint32 = JSUint32
-
-JSObject = JSObject
-
-JSPropertyOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval))
-
-JSEnumerateOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject))
-
-JSResolveOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long)
-
-# enumeration JSType
-JSTYPE_VOID = 0
-JSTYPE_OBJECT = 1
-JSTYPE_FUNCTION = 2
-JSTYPE_STRING = 3
-JSTYPE_NUMBER = 4
-JSTYPE_BOOLEAN = 5
-JSTYPE_LIMIT = 6
-
-JSConvertOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_int,POINTER(jsval))
-
-JSFinalizeOp = CFUNCTYPE(None,POINTER(JSContext),POINTER(JSObject))
-
-class JSClass(Structure):
- _fields_ = []
-
-JSGetObjectOps = CFUNCTYPE(POINTER(JSObjectOps),POINTER(JSContext),POINTER(JSClass))
-
-# enumeration JSAccessMode
-JSACC_PROTO = 0
-JSACC_PARENT = 1
-JSACC_IMPORT = 2
-JSACC_WATCH = 3
-JSACC_READ = 4
-JSACC_WRITE = 8
-JSACC_LIMIT = 9
-
-JSCheckAccessOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,c_int,POINTER(jsval))
-
-JSNative = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_uint,POINTER(jsval),POINTER(jsval))
-
-JSXDRObjectOp = CFUNCTYPE(JSBool,POINTER(JSXDRState),POINTER(POINTER(JSObject)))
-
-JSHasInstanceOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(JSBool))
-
-JSMarkOp = CFUNCTYPE(uint32,POINTER(JSContext),POINTER(JSObject),c_void_p)
-
-class JSClass(Structure):
- _fields_ = [
- ('name', c_char_p),
- ('flags', uint32),
- ('addProperty', JSPropertyOp),
- ('delProperty', JSPropertyOp),
- ('getProperty', JSPropertyOp),
- ('setProperty', JSPropertyOp),
- ('enumerate', JSEnumerateOp),
- ('resolve', JSResolveOp),
- ('convert', JSConvertOp),
- ('finalize', JSFinalizeOp),
- ('getObjectOps', JSGetObjectOps),
- ('checkAccess', JSCheckAccessOp),
- ('call', JSNative),
- ('construct', JSNative),
- ('xdrObject', JSXDRObjectOp),
- ('hasInstance', JSHasInstanceOp),
- ('mark', JSMarkOp),
- ('spare', jsword),
- ]
-
-JSClass = JSClass
-
-JSNewObjectMapOp = CFUNCTYPE(POINTER(JSObjectMap),POINTER(JSContext),c_int,POINTER(JSObjectOps),POINTER(JSClass),POINTER(JSObject))
-
-JSObjectMapOp = CFUNCTYPE(None,POINTER(JSContext),POINTER(JSObjectMap))
-
-JSLookupPropOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(POINTER(JSObject)),POINTER(POINTER(JSProperty)))
-
-JSDefinePropOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,c_long,CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),c_uint,POINTER(POINTER(JSProperty)))
-
-JSPropertyIdOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval))
-
-JSAttributesOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(JSProperty),POINTER(uintN))
-
-# enumeration JSIterateOp
-JSENUMERATE_INIT = 0
-JSENUMERATE_NEXT = 1
-JSENUMERATE_DESTROY = 2
-
-JSNewEnumerateOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_int,POINTER(jsval),POINTER(jsid))
-
-JSCheckAccessIdOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,c_int,POINTER(jsval),POINTER(uintN))
-
-JSObjectOp = CFUNCTYPE(POINTER(JSObject),POINTER(JSContext),POINTER(JSObject))
-
-JSPropertyRefOp = CFUNCTYPE(None,POINTER(JSContext),POINTER(JSObject),POINTER(JSProperty))
-
-JSSetObjectSlotOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_uint,POINTER(JSObject))
-
-JSGetRequiredSlotOp = CFUNCTYPE(jsval,POINTER(JSContext),POINTER(JSObject),c_uint)
-
-JSSetRequiredSlotOp = CFUNCTYPE(None,POINTER(JSContext),POINTER(JSObject),c_uint,c_long)
-
-class JSObjectOps(Structure):
- _fields_ = [
- ('newObjectMap', JSNewObjectMapOp),
- ('destroyObjectMap', JSObjectMapOp),
- ('lookupProperty', JSLookupPropOp),
- ('defineProperty', JSDefinePropOp),
- ('getProperty', JSPropertyIdOp),
- ('setProperty', JSPropertyIdOp),
- ('getAttributes', JSAttributesOp),
- ('setAttributes', JSAttributesOp),
- ('deleteProperty', JSPropertyIdOp),
- ('defaultValue', JSConvertOp),
- ('enumerate', JSNewEnumerateOp),
- ('checkAccess', JSCheckAccessIdOp),
- ('thisObject', JSObjectOp),
- ('dropProperty', JSPropertyRefOp),
- ('call', JSNative),
- ('construct', JSNative),
- ('xdrObject', JSXDRObjectOp),
- ('hasInstance', JSHasInstanceOp),
- ('setProto', JSSetObjectSlotOp),
- ('setParent', JSSetObjectSlotOp),
- ('mark', JSMarkOp),
- ('clear', JSFinalizeOp),
- ('getRequiredSlot', JSGetRequiredSlotOp),
- ('setRequiredSlot', JSSetRequiredSlotOp),
- ]
-
-JSObjectOps = JSObjectOps
-
-JSUint16 = c_ushort
-
-uint16 = JSUint16
-
-jschar = uint16
-
-class JSErrorReport(Structure):
- _fields_ = [
- ('filename', c_char_p),
- ('lineno', uintN),
- ('linebuf', c_char_p),
- ('tokenptr', c_char_p),
- ('uclinebuf', POINTER(jschar)),
- ('uctokenptr', POINTER(jschar)),
- ('flags', uintN),
- ('errorNumber', uintN),
- ('ucmessage', POINTER(jschar)),
- ('messageArgs', POINTER(POINTER(jschar))),
- ]
-
-class JSString(Structure):
- _fields_ = [
- ]
-
-JSString = JSString
-
-JSLocaleToUpperCase = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSString),POINTER(jsval))
-
-JSLocaleToLowerCase = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSString),POINTER(jsval))
-
-JSLocaleCompare = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSString),POINTER(JSString),POINTER(jsval))
-
-class JSLocaleCallbacks(Structure):
- _fields_ = [
- ('localeToUpperCase', JSLocaleToUpperCase),
- ('localeToLowerCase', JSLocaleToLowerCase),
- ('localeCompare', JSLocaleCompare),
- ]
-
-JSUint8 = c_ubyte
-
-uint8 = JSUint8
-
-class JSFunctionSpec(Structure):
- _fields_ = [
- ('name', c_char_p),
- ('call', JSNative),
- ('nargs', uint8),
- ('flags', uint8),
- ('extra', uint16),
- ]
-
-JSInt8 = c_char
-
-int8 = JSInt8
-
-class JSPropertySpec(Structure):
- _fields_ = [
- ('name', c_char_p),
- ('tinyid', int8),
- ('flags', uint8),
- ('getter', JSPropertyOp),
- ('setter', JSPropertyOp),
- ]
-
-JSFloat64 = c_double
-
-float64 = JSFloat64
-
-jsdouble = float64
-
-class JSConstDoubleSpec(Structure):
- _fields_ = [
- ('dval', jsdouble),
- ('name', c_char_p),
- ('flags', uint8),
- ('spare', uint8*3),
- ]
-
-jsint = int32
-
-class JSIdArray(Structure):
- _fields_ = [
- ('length', jsint),
- ('vector', jsid*1),
- ]
-
-intN = JSIntn
-
-JSErrorReport = JSErrorReport
-
-class JSScript(Structure):
- _fields_ = [
- ]
-
-JSScript = JSScript
-
-# enumeration JSGCStatus
-JSGC_BEGIN = 0
-JSGC_END = 1
-JSGC_MARK_END = 2
-JSGC_FINALIZE_END = 3
-
-JSConstDoubleSpec = JSConstDoubleSpec
-
-JSPropertySpec = JSPropertySpec
-
-jsuint = uint32
-
-JSIdArray = JSIdArray
-
-class JSRuntime(Structure):
- _fields_ = [
- ]
-
-JSRuntime = JSRuntime
-
-JSFunctionSpec = JSFunctionSpec
-
-class JSFunction(Structure):
- _fields_ = [
- ]
-
-JSFunction = JSFunction
-
-JSLocaleCallbacks = JSLocaleCallbacks
-
-class JSExceptionState(Structure):
- _fields_ = [
- ]
-
-JSExceptionState = JSExceptionState
-
-JSInt64 = c_longlong
-
-from sm_settings import try_libs
-for lib in try_libs:
- try:
- libsmjs = CDLL(lib)
- break
- except OSError:
- if lib == try_libs[-1]:
- raise ImportError("The spidermonkey C library is not installed")
-
-JSLL_MaxInt = libsmjs.JSLL_MaxInt
-JSLL_MaxInt.restype = JSInt64
-JSLL_MaxInt.argtypes = []
-
-JSLL_MinInt = libsmjs.JSLL_MinInt
-JSLL_MinInt.restype = JSInt64
-JSLL_MinInt.argtypes = []
-
-JSLL_Zero = libsmjs.JSLL_Zero
-JSLL_Zero.restype = JSInt64
-JSLL_Zero.argtypes = []
-
-JSUword = c_ulong
-
-jsuword = JSUword
-
-float32 = c_float
-
-# enumeration Js-1.7.0.tar.gzSVersion
-JSVERSION_1_0 = 100
-JSVERSION_1_1 = 110
-JSVERSION_1_2 = 120
-JSVERSION_1_3 = 130
-JSVERSION_1_4 = 140
-JSVERSION_ECMA_3 = 148
-JSVERSION_1_5 = 150
-JSVERSION_DEFAULT = 0
-JSVERSION_UNKNOWN = -1
-
-JSVersion = c_int
-
-JSType = c_int
-
-JSAccessMode = c_int
-
-JSIterateOp = c_int
-
-JSTaskState = JSRuntime
-
-JSNewResolveOp = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,c_uint,POINTER(POINTER(JSObject)))
-
-JSStringFinalizeOp = CFUNCTYPE(None,POINTER(JSContext),POINTER(JSString))
-
-JSGCStatus = c_int
-
-JSGCCallback = CFUNCTYPE(JSBool,POINTER(JSContext),c_int)
-
-JSBranchCallback = CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSScript))
-
-JSErrorReporter = CFUNCTYPE(None,POINTER(JSContext),c_char_p,POINTER(JSErrorReport))
-
-JSErrorCallback = CFUNCTYPE(POINTER(JSErrorFormatString),c_void_p,c_char_p,c_uint)
-
-JSPrincipalsTranscoder = CFUNCTYPE(JSBool,POINTER(JSXDRState),POINTER(POINTER(JSPrincipals)))
-
-JSObjectPrincipalsFinder = CFUNCTYPE(POINTER(JSPrincipals),POINTER(JSContext),POINTER(JSObject))
-
-int64 = JSInt64
-
-JS_Now = libsmjs.JS_Now
-JS_Now.restype = int64
-JS_Now.argtypes = []
-
-JS_GetNaNValue = libsmjs.JS_GetNaNValue
-JS_GetNaNValue.restype = jsval
-JS_GetNaNValue.argtypes = [POINTER(JSContext)]
-
-JS_GetNegativeInfinityValue = libsmjs.JS_GetNegativeInfinityValue
-JS_GetNegativeInfinityValue.restype = jsval
-JS_GetNegativeInfinityValue.argtypes = [POINTER(JSContext)]
-
-JS_GetPositiveInfinityValue = libsmjs.JS_GetPositiveInfinityValue
-JS_GetPositiveInfinityValue.restype = jsval
-JS_GetPositiveInfinityValue.argtypes = [POINTER(JSContext)]
-
-JS_GetEmptyStringValue = libsmjs.JS_GetEmptyStringValue
-JS_GetEmptyStringValue.restype = jsval
-JS_GetEmptyStringValue.argtypes = [POINTER(JSContext)]
-
-JS_ConvertArguments = libsmjs.JS_ConvertArguments
-JS_ConvertArguments.restype = JSBool
-JS_ConvertArguments.argtypes = [POINTER(JSContext),c_uint,POINTER(jsval),c_char_p]
-
-JS_PushArguments = libsmjs.JS_PushArguments
-JS_PushArguments.restype = POINTER(jsval)
-JS_PushArguments.argtypes = [POINTER(JSContext),POINTER(c_void_p),c_char_p]
-
-JS_PopArguments = libsmjs.JS_PopArguments
-JS_PopArguments.restype = None
-JS_PopArguments.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_ConvertValue = libsmjs.JS_ConvertValue
-JS_ConvertValue.restype = JSBool
-JS_ConvertValue.argtypes = [POINTER(JSContext),c_long,c_int,POINTER(jsval)]
-
-JS_ValueToObject = libsmjs.JS_ValueToObject
-JS_ValueToObject.restype = JSBool
-JS_ValueToObject.argtypes = [POINTER(JSContext),c_long,POINTER(POINTER(JSObject))]
-
-JS_ValueToFunction = libsmjs.JS_ValueToFunction
-JS_ValueToFunction.restype = POINTER(JSFunction)
-JS_ValueToFunction.argtypes = [POINTER(JSContext),c_long]
-
-JS_ValueToConstructor = libsmjs.JS_ValueToConstructor
-JS_ValueToConstructor.restype = POINTER(JSFunction)
-JS_ValueToConstructor.argtypes = [POINTER(JSContext),c_long]
-
-JS_ValueToString = libsmjs.JS_ValueToString
-JS_ValueToString.restype = POINTER(JSString)
-JS_ValueToString.argtypes = [POINTER(JSContext),c_long]
-
-JS_ValueToNumber = libsmjs.JS_ValueToNumber
-JS_ValueToNumber.restype = JSBool
-JS_ValueToNumber.argtypes = [POINTER(JSContext),c_long,POINTER(jsdouble)]
-
-JS_ValueToECMAInt32 = libsmjs.JS_ValueToECMAInt32
-JS_ValueToECMAInt32.restype = JSBool
-JS_ValueToECMAInt32.argtypes = [POINTER(JSContext),c_long,POINTER(int32)]
-
-JS_ValueToECMAUint32 = libsmjs.JS_ValueToECMAUint32
-JS_ValueToECMAUint32.restype = JSBool
-JS_ValueToECMAUint32.argtypes = [POINTER(JSContext),c_long,POINTER(uint32)]
-
-JS_ValueToInt32 = libsmjs.JS_ValueToInt32
-JS_ValueToInt32.restype = JSBool
-JS_ValueToInt32.argtypes = [POINTER(JSContext),c_long,POINTER(int32)]
-
-JS_ValueToUint16 = libsmjs.JS_ValueToUint16
-JS_ValueToUint16.restype = JSBool
-JS_ValueToUint16.argtypes = [POINTER(JSContext),c_long,POINTER(uint16)]
-
-JS_ValueToBoolean = libsmjs.JS_ValueToBoolean
-JS_ValueToBoolean.restype = JSBool
-JS_ValueToBoolean.argtypes = [POINTER(JSContext),c_long,POINTER(JSBool)]
-
-JS_TypeOfValue = libsmjs.JS_TypeOfValue
-JS_TypeOfValue.restype = JSType
-JS_TypeOfValue.argtypes = [POINTER(JSContext),c_long]
-
-JS_GetTypeName = libsmjs.JS_GetTypeName
-JS_GetTypeName.restype = c_char_p
-JS_GetTypeName.argtypes = [POINTER(JSContext),c_int]
-
-JS_Init = libsmjs.JS_Init
-JS_Init.restype = POINTER(JSRuntime)
-JS_Init.argtypes = [c_uint]
-
-JS_Finish = libsmjs.JS_Finish
-JS_Finish.restype = None
-JS_Finish.argtypes = [POINTER(JSRuntime)]
-
-JS_ShutDown = libsmjs.JS_ShutDown
-JS_ShutDown.restype = None
-JS_ShutDown.argtypes = []
-
-JS_GetRuntimePrivate = libsmjs.JS_GetRuntimePrivate
-JS_GetRuntimePrivate.restype = c_void_p
-JS_GetRuntimePrivate.argtypes = [POINTER(JSRuntime)]
-
-JS_SetRuntimePrivate = libsmjs.JS_SetRuntimePrivate
-JS_SetRuntimePrivate.restype = None
-JS_SetRuntimePrivate.argtypes = [POINTER(JSRuntime),c_void_p]
-
-JS_Lock = libsmjs.JS_Lock
-JS_Lock.restype = None
-JS_Lock.argtypes = [POINTER(JSRuntime)]
-
-JS_Unlock = libsmjs.JS_Unlock
-JS_Unlock.restype = None
-JS_Unlock.argtypes = [POINTER(JSRuntime)]
-
-JS_NewContext = libsmjs.JS_NewContext
-JS_NewContext.restype = POINTER(JSContext)
-JS_NewContext.argtypes = [POINTER(JSRuntime),c_uint]
-
-JS_DestroyContext = libsmjs.JS_DestroyContext
-JS_DestroyContext.restype = None
-JS_DestroyContext.argtypes = [POINTER(JSContext)]
-
-JS_DestroyContextNoGC = libsmjs.JS_DestroyContextNoGC
-JS_DestroyContextNoGC.restype = None
-JS_DestroyContextNoGC.argtypes = [POINTER(JSContext)]
-
-JS_DestroyContextMaybeGC = libsmjs.JS_DestroyContextMaybeGC
-JS_DestroyContextMaybeGC.restype = None
-JS_DestroyContextMaybeGC.argtypes = [POINTER(JSContext)]
-
-JS_GetContextPrivate = libsmjs.JS_GetContextPrivate
-JS_GetContextPrivate.restype = c_void_p
-JS_GetContextPrivate.argtypes = [POINTER(JSContext)]
-
-JS_SetContextPrivate = libsmjs.JS_SetContextPrivate
-JS_SetContextPrivate.restype = None
-JS_SetContextPrivate.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_GetRuntime = libsmjs.JS_GetRuntime
-JS_GetRuntime.restype = POINTER(JSRuntime)
-JS_GetRuntime.argtypes = [POINTER(JSContext)]
-
-JS_ContextIterator = libsmjs.JS_ContextIterator
-JS_ContextIterator.restype = POINTER(JSContext)
-JS_ContextIterator.argtypes = [POINTER(JSRuntime),POINTER(POINTER(JSContext))]
-
-JS_GetVersion = libsmjs.JS_GetVersion
-JS_GetVersion.restype = JSVersion
-JS_GetVersion.argtypes = [POINTER(JSContext)]
-
-JS_SetVersion = libsmjs.JS_SetVersion
-JS_SetVersion.restype = JSVersion
-JS_SetVersion.argtypes = [POINTER(JSContext),c_int]
-
-JS_VersionToString = libsmjs.JS_VersionToString
-JS_VersionToString.restype = c_char_p
-JS_VersionToString.argtypes = [c_int]
-
-JS_StringToVersion = libsmjs.JS_StringToVersion
-JS_StringToVersion.restype = JSVersion
-JS_StringToVersion.argtypes = [c_char_p]
-
-JS_GetOptions = libsmjs.JS_GetOptions
-JS_GetOptions.restype = uint32
-JS_GetOptions.argtypes = [POINTER(JSContext)]
-
-JS_SetOptions = libsmjs.JS_SetOptions
-JS_SetOptions.restype = uint32
-JS_SetOptions.argtypes = [POINTER(JSContext),c_uint]
-
-JS_ToggleOptions = libsmjs.JS_ToggleOptions
-JS_ToggleOptions.restype = uint32
-JS_ToggleOptions.argtypes = [POINTER(JSContext),c_uint]
-
-JS_GetImplementationVersion = libsmjs.JS_GetImplementationVersion
-JS_GetImplementationVersion.restype = c_char_p
-JS_GetImplementationVersion.argtypes = []
-
-JS_GetGlobalObject = libsmjs.JS_GetGlobalObject
-JS_GetGlobalObject.restype = POINTER(JSObject)
-JS_GetGlobalObject.argtypes = [POINTER(JSContext)]
-
-JS_SetGlobalObject = libsmjs.JS_SetGlobalObject
-JS_SetGlobalObject.restype = None
-JS_SetGlobalObject.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_InitStandardClasses = libsmjs.JS_InitStandardClasses
-JS_InitStandardClasses.restype = JSBool
-JS_InitStandardClasses.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_ResolveStandardClass = libsmjs.JS_ResolveStandardClass
-JS_ResolveStandardClass.restype = JSBool
-JS_ResolveStandardClass.argtypes = [POINTER(JSContext),POINTER(JSObject),c_long,POINTER(JSBool)]
-
-JS_EnumerateStandardClasses = libsmjs.JS_EnumerateStandardClasses
-JS_EnumerateStandardClasses.restype = JSBool
-JS_EnumerateStandardClasses.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_GetScopeChain = libsmjs.JS_GetScopeChain
-JS_GetScopeChain.restype = POINTER(JSObject)
-JS_GetScopeChain.argtypes = [POINTER(JSContext)]
-
-JS_malloc = libsmjs.JS_malloc
-JS_malloc.restype = c_void_p
-JS_malloc.argtypes = [POINTER(JSContext),c_uint]
-
-JS_realloc = libsmjs.JS_realloc
-JS_realloc.restype = c_void_p
-JS_realloc.argtypes = [POINTER(JSContext),c_void_p,c_uint]
-
-JS_free = libsmjs.JS_free
-JS_free.restype = None
-JS_free.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_strdup = libsmjs.JS_strdup
-JS_strdup.restype = c_char_p
-JS_strdup.argtypes = [POINTER(JSContext),c_char_p]
-
-JS_NewDouble = libsmjs.JS_NewDouble
-JS_NewDouble.restype = POINTER(jsdouble)
-JS_NewDouble.argtypes = [POINTER(JSContext),c_double]
-
-JS_NewDoubleValue = libsmjs.JS_NewDoubleValue
-JS_NewDoubleValue.restype = JSBool
-JS_NewDoubleValue.argtypes = [POINTER(JSContext),c_double,POINTER(jsval)]
-
-JS_NewNumberValue = libsmjs.JS_NewNumberValue
-JS_NewNumberValue.restype = JSBool
-JS_NewNumberValue.argtypes = [POINTER(JSContext),c_double,POINTER(jsval)]
-
-JS_AddRoot = libsmjs.JS_AddRoot
-JS_AddRoot.restype = JSBool
-JS_AddRoot.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_AddNamedRoot = libsmjs.JS_AddNamedRoot
-JS_AddNamedRoot.restype = JSBool
-JS_AddNamedRoot.argtypes = [POINTER(JSContext),c_void_p,c_char_p]
-
-JS_AddNamedRootRT = libsmjs.JS_AddNamedRootRT
-JS_AddNamedRootRT.restype = JSBool
-JS_AddNamedRootRT.argtypes = [POINTER(JSRuntime),c_void_p,c_char_p]
-
-JS_RemoveRoot = libsmjs.JS_RemoveRoot
-JS_RemoveRoot.restype = JSBool
-JS_RemoveRoot.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_RemoveRootRT = libsmjs.JS_RemoveRootRT
-JS_RemoveRootRT.restype = JSBool
-JS_RemoveRootRT.argtypes = [POINTER(JSRuntime),c_void_p]
-
-JS_ClearNewbornRoots = libsmjs.JS_ClearNewbornRoots
-JS_ClearNewbornRoots.restype = None
-JS_ClearNewbornRoots.argtypes = [POINTER(JSContext)]
-
-JSGCRootMapFun = CFUNCTYPE(intN,c_void_p,c_char_p,c_void_p)
-
-JS_MapGCRoots = libsmjs.JS_MapGCRoots
-JS_MapGCRoots.restype = uint32
-JS_MapGCRoots.argtypes = [POINTER(JSRuntime),CFUNCTYPE(intN,c_void_p,c_char_p,c_void_p),c_void_p]
-
-JS_LockGCThing = libsmjs.JS_LockGCThing
-JS_LockGCThing.restype = JSBool
-JS_LockGCThing.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_LockGCThingRT = libsmjs.JS_LockGCThingRT
-JS_LockGCThingRT.restype = JSBool
-JS_LockGCThingRT.argtypes = [POINTER(JSRuntime),c_void_p]
-
-JS_UnlockGCThing = libsmjs.JS_UnlockGCThing
-JS_UnlockGCThing.restype = JSBool
-JS_UnlockGCThing.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_UnlockGCThingRT = libsmjs.JS_UnlockGCThingRT
-JS_UnlockGCThingRT.restype = JSBool
-JS_UnlockGCThingRT.argtypes = [POINTER(JSRuntime),c_void_p]
-
-JS_MarkGCThing = libsmjs.JS_MarkGCThing
-JS_MarkGCThing.restype = None
-JS_MarkGCThing.argtypes = [POINTER(JSContext),c_void_p,c_char_p,c_void_p]
-
-JS_GC = libsmjs.JS_GC
-JS_GC.restype = None
-JS_GC.argtypes = [POINTER(JSContext)]
-
-JS_MaybeGC = libsmjs.JS_MaybeGC
-JS_MaybeGC.restype = None
-JS_MaybeGC.argtypes = [POINTER(JSContext)]
-
-JS_SetGCCallback = libsmjs.JS_SetGCCallback
-JS_SetGCCallback.restype = JSGCCallback
-JS_SetGCCallback.argtypes = [POINTER(JSContext),CFUNCTYPE(JSBool,POINTER(JSContext),c_int)]
-
-JS_SetGCCallbackRT = libsmjs.JS_SetGCCallbackRT
-JS_SetGCCallbackRT.restype = JSGCCallback
-JS_SetGCCallbackRT.argtypes = [POINTER(JSRuntime),CFUNCTYPE(JSBool,POINTER(JSContext),c_int)]
-
-JS_IsAboutToBeFinalized = libsmjs.JS_IsAboutToBeFinalized
-JS_IsAboutToBeFinalized.restype = JSBool
-JS_IsAboutToBeFinalized.argtypes = [POINTER(JSContext),c_void_p]
-
-JS_AddExternalStringFinalizer = libsmjs.JS_AddExternalStringFinalizer
-JS_AddExternalStringFinalizer.restype = intN
-JS_AddExternalStringFinalizer.argtypes = [CFUNCTYPE(None,POINTER(JSContext),POINTER(JSString))]
-
-JS_RemoveExternalStringFinalizer = libsmjs.JS_RemoveExternalStringFinalizer
-JS_RemoveExternalStringFinalizer.restype = intN
-JS_RemoveExternalStringFinalizer.argtypes = [CFUNCTYPE(None,POINTER(JSContext),POINTER(JSString))]
-
-JS_NewExternalString = libsmjs.JS_NewExternalString
-JS_NewExternalString.restype = POINTER(JSString)
-JS_NewExternalString.argtypes = [POINTER(JSContext),POINTER(jschar),c_uint,c_int]
-
-JS_GetExternalStringGCType = libsmjs.JS_GetExternalStringGCType
-JS_GetExternalStringGCType.restype = intN
-JS_GetExternalStringGCType.argtypes = [POINTER(JSRuntime),POINTER(JSString)]
-
-JS_SetThreadStackLimit = libsmjs.JS_SetThreadStackLimit
-JS_SetThreadStackLimit.restype = None
-JS_SetThreadStackLimit.argtypes = [POINTER(JSContext),c_ulong]
-
-JS_DestroyIdArray = libsmjs.JS_DestroyIdArray
-JS_DestroyIdArray.restype = None
-JS_DestroyIdArray.argtypes = [POINTER(JSContext),POINTER(JSIdArray)]
-
-JS_ValueToId = libsmjs.JS_ValueToId
-JS_ValueToId.restype = JSBool
-JS_ValueToId.argtypes = [POINTER(JSContext),c_long,POINTER(jsid)]
-
-JS_IdToValue = libsmjs.JS_IdToValue
-JS_IdToValue.restype = JSBool
-JS_IdToValue.argtypes = [POINTER(JSContext),c_long,POINTER(jsval)]
-
-JS_PropertyStub = JSPropertyOp(libsmjs.JS_PropertyStub)
-#JS_PropertyStub.restype = JSBool
-#JS_PropertyStub.argtypes = [POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)]
-
-JS_EnumerateStub = JSEnumerateOp(libsmjs.JS_EnumerateStub)
-#JS_EnumerateStub.restype = JSBool
-#JS_EnumerateStub.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_ResolveStub = JSResolveOp(libsmjs.JS_ResolveStub)
-#JS_ResolveStub.restype = JSBool
-#JS_ResolveStub.argtypes = [POINTER(JSContext),POINTER(JSObject),c_long]
-
-JS_ConvertStub = JSConvertOp(libsmjs.JS_ConvertStub)
-#JS_ConvertStub.restype = JSBool
-#JS_ConvertStub.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int,POINTER(jsval)]
-
-JS_FinalizeStub = JSFinalizeOp(libsmjs.JS_FinalizeStub)
-#JS_FinalizeStub.restype = None
-#JS_FinalizeStub.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_InitClass = libsmjs.JS_InitClass
-JS_InitClass.restype = POINTER(JSObject)
-JS_InitClass.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSObject),POINTER(JSClass),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_uint,POINTER(jsval),POINTER(jsval)),c_uint,POINTER(JSPropertySpec),POINTER(JSFunctionSpec),POINTER(JSPropertySpec),POINTER(JSFunctionSpec)]
-
-JS_GetClass = libsmjs.JS_GetClass
-JS_GetClass.restype = POINTER(JSClass)
-JS_GetClass.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-#JS_GetClass.argtypes = [POINTER(JSObject)]
-
-JS_InstanceOf = libsmjs.JS_InstanceOf
-JS_InstanceOf.restype = JSBool
-JS_InstanceOf.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSClass),POINTER(jsval)]
-
-JS_GetPrivate = libsmjs.JS_GetPrivate
-JS_GetPrivate.restype = c_void_p
-JS_GetPrivate.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_SetPrivate = libsmjs.JS_SetPrivate
-JS_SetPrivate.restype = JSBool
-JS_SetPrivate.argtypes = [POINTER(JSContext),POINTER(JSObject),c_void_p]
-
-JS_GetInstancePrivate = libsmjs.JS_GetInstancePrivate
-JS_GetInstancePrivate.restype = c_void_p
-JS_GetInstancePrivate.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSClass),POINTER(jsval)]
-
-JS_GetPrototype = libsmjs.JS_GetPrototype
-JS_GetPrototype.restype = POINTER(JSObject)
-JS_GetPrototype.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_SetPrototype = libsmjs.JS_SetPrototype
-JS_SetPrototype.restype = JSBool
-JS_SetPrototype.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSObject)]
-
-JS_GetParent = libsmjs.JS_GetParent
-JS_GetParent.restype = POINTER(JSObject)
-JS_GetParent.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_SetParent = libsmjs.JS_SetParent
-JS_SetParent.restype = JSBool
-JS_SetParent.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSObject)]
-
-JS_GetConstructor = libsmjs.JS_GetConstructor
-JS_GetConstructor.restype = POINTER(JSObject)
-JS_GetConstructor.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_GetObjectId = libsmjs.JS_GetObjectId
-JS_GetObjectId.restype = JSBool
-JS_GetObjectId.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jsid)]
-
-JS_NewObject = libsmjs.JS_NewObject
-JS_NewObject.restype = POINTER(JSObject)
-JS_NewObject.argtypes = [POINTER(JSContext),POINTER(JSClass),POINTER(JSObject),POINTER(JSObject)]
-
-JS_SealObject = libsmjs.JS_SealObject
-JS_SealObject.restype = JSBool
-JS_SealObject.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int]
-
-JS_ConstructObject = libsmjs.JS_ConstructObject
-JS_ConstructObject.restype = POINTER(JSObject)
-JS_ConstructObject.argtypes = [POINTER(JSContext),POINTER(JSClass),POINTER(JSObject),POINTER(JSObject)]
-
-JS_ConstructObjectWithArguments = libsmjs.JS_ConstructObjectWithArguments
-JS_ConstructObjectWithArguments.restype = POINTER(JSObject)
-JS_ConstructObjectWithArguments.argtypes = [POINTER(JSContext),POINTER(JSClass),POINTER(JSObject),POINTER(JSObject),c_uint,POINTER(jsval)]
-
-JS_DefineObject = libsmjs.JS_DefineObject
-JS_DefineObject.restype = POINTER(JSObject)
-JS_DefineObject.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(JSClass),POINTER(JSObject),c_uint]
-
-JS_DefineConstDoubles = libsmjs.JS_DefineConstDoubles
-JS_DefineConstDoubles.restype = JSBool
-JS_DefineConstDoubles.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSConstDoubleSpec)]
-
-JS_DefineProperties = libsmjs.JS_DefineProperties
-JS_DefineProperties.restype = JSBool
-JS_DefineProperties.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSPropertySpec)]
-
-JS_DefineProperty = libsmjs.JS_DefineProperty
-JS_DefineProperty.restype = JSBool
-#JS_DefineProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_long,CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),c_uint]
-JS_DefineProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_long,c_void_p,c_void_p,c_uint]
-
-JS_GetPropertyAttributes = libsmjs.JS_GetPropertyAttributes
-JS_GetPropertyAttributes.restype = JSBool
-JS_GetPropertyAttributes.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(uintN),POINTER(JSBool)]
-
-JS_SetPropertyAttributes = libsmjs.JS_SetPropertyAttributes
-JS_SetPropertyAttributes.restype = JSBool
-JS_SetPropertyAttributes.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_uint,POINTER(JSBool)]
-
-JS_DefinePropertyWithTinyId = libsmjs.JS_DefinePropertyWithTinyId
-JS_DefinePropertyWithTinyId.restype = JSBool
-JS_DefinePropertyWithTinyId.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_char,c_long,CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),c_uint]
-
-JS_AliasProperty = libsmjs.JS_AliasProperty
-JS_AliasProperty.restype = JSBool
-JS_AliasProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_char_p]
-
-JS_LookupProperty = libsmjs.JS_LookupProperty
-JS_LookupProperty.restype = JSBool
-JS_LookupProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(jsval)]
-
-JS_GetProperty = libsmjs.JS_GetProperty
-JS_GetProperty.restype = JSBool
-JS_GetProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(jsval)]
-
-JS_SetProperty = libsmjs.JS_SetProperty
-JS_SetProperty.restype = JSBool
-JS_SetProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(jsval)]
-
-JS_DeleteProperty = libsmjs.JS_DeleteProperty
-JS_DeleteProperty.restype = JSBool
-JS_DeleteProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p]
-
-JS_DeleteProperty2 = libsmjs.JS_DeleteProperty2
-JS_DeleteProperty2.restype = JSBool
-JS_DeleteProperty2.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(jsval)]
-
-JS_DefineUCProperty = libsmjs.JS_DefineUCProperty
-JS_DefineUCProperty.restype = JSBool
-JS_DefineUCProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,c_long,CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),c_uint]
-
-JS_GetUCPropertyAttributes = libsmjs.JS_GetUCPropertyAttributes
-JS_GetUCPropertyAttributes.restype = JSBool
-JS_GetUCPropertyAttributes.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,POINTER(uintN),POINTER(JSBool)]
-
-JS_SetUCPropertyAttributes = libsmjs.JS_SetUCPropertyAttributes
-JS_SetUCPropertyAttributes.restype = JSBool
-JS_SetUCPropertyAttributes.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,c_uint,POINTER(JSBool)]
-
-JS_DefineUCPropertyWithTinyId = libsmjs.JS_DefineUCPropertyWithTinyId
-JS_DefineUCPropertyWithTinyId.restype = JSBool
-JS_DefineUCPropertyWithTinyId.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,c_char,c_long,CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,POINTER(jsval)),c_uint]
-
-JS_LookupUCProperty = libsmjs.JS_LookupUCProperty
-JS_LookupUCProperty.restype = JSBool
-JS_LookupUCProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,POINTER(jsval)]
-
-JS_GetUCProperty = libsmjs.JS_GetUCProperty
-JS_GetUCProperty.restype = JSBool
-JS_GetUCProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,POINTER(jsval)]
-
-JS_SetUCProperty = libsmjs.JS_SetUCProperty
-JS_SetUCProperty.restype = JSBool
-JS_SetUCProperty.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,POINTER(jsval)]
-
-JS_DeleteUCProperty2 = libsmjs.JS_DeleteUCProperty2
-JS_DeleteUCProperty2.restype = JSBool
-JS_DeleteUCProperty2.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,POINTER(jsval)]
-
-JS_NewArrayObject = libsmjs.JS_NewArrayObject
-JS_NewArrayObject.restype = POINTER(JSObject)
-JS_NewArrayObject.argtypes = [POINTER(JSContext),c_int,POINTER(jsval)]
-
-JS_IsArrayObject = libsmjs.JS_IsArrayObject
-JS_IsArrayObject.restype = JSBool
-JS_IsArrayObject.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_GetArrayLength = libsmjs.JS_GetArrayLength
-JS_GetArrayLength.restype = JSBool
-JS_GetArrayLength.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jsuint)]
-
-JS_SetArrayLength = libsmjs.JS_SetArrayLength
-JS_SetArrayLength.restype = JSBool
-JS_SetArrayLength.argtypes = [POINTER(JSContext),POINTER(JSObject),c_uint]
-
-JS_HasArrayLength = libsmjs.JS_HasArrayLength
-JS_HasArrayLength.restype = JSBool
-JS_HasArrayLength.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jsuint)]
-
-JS_DefineElement = libsmjs.JS_DefineElement
-JS_DefineElement.restype = JSBool
-#JS_DefineElement.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int,c_long,JSPropertyOp,JSPropertyOp,c_uint]
-JS_DefineElement.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int,c_long,c_void_p,c_void_p,c_uint]
-
-JS_AliasElement = libsmjs.JS_AliasElement
-JS_AliasElement.restype = JSBool
-JS_AliasElement.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_int]
-
-JS_LookupElement = libsmjs.JS_LookupElement
-JS_LookupElement.restype = JSBool
-JS_LookupElement.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int,POINTER(jsval)]
-
-JS_GetElement = libsmjs.JS_GetElement
-JS_GetElement.restype = JSBool
-JS_GetElement.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int,POINTER(jsval)]
-
-JS_SetElement = libsmjs.JS_SetElement
-JS_SetElement.restype = JSBool
-JS_SetElement.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int,POINTER(jsval)]
-
-JS_DeleteElement = libsmjs.JS_DeleteElement
-JS_DeleteElement.restype = JSBool
-JS_DeleteElement.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int]
-
-JS_DeleteElement2 = libsmjs.JS_DeleteElement2
-JS_DeleteElement2.restype = JSBool
-JS_DeleteElement2.argtypes = [POINTER(JSContext),POINTER(JSObject),c_int,POINTER(jsval)]
-
-JS_ClearScope = libsmjs.JS_ClearScope
-JS_ClearScope.restype = None
-JS_ClearScope.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_Enumerate = libsmjs.JS_Enumerate
-JS_Enumerate.restype = POINTER(JSIdArray)
-JS_Enumerate.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_CheckAccess = libsmjs.JS_CheckAccess
-JS_CheckAccess.restype = JSBool
-JS_CheckAccess.argtypes = [POINTER(JSContext),POINTER(JSObject),c_long,c_int,POINTER(jsval),POINTER(uintN)]
-
-JS_SetCheckObjectAccessCallback = libsmjs.JS_SetCheckObjectAccessCallback
-JS_SetCheckObjectAccessCallback.restype = JSCheckAccessOp
-JS_SetCheckObjectAccessCallback.argtypes = [POINTER(JSRuntime),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_long,c_int,POINTER(jsval))]
-
-JS_GetReservedSlot = libsmjs.JS_GetReservedSlot
-JS_GetReservedSlot.restype = JSBool
-JS_GetReservedSlot.argtypes = [POINTER(JSContext),POINTER(JSObject),c_uint,POINTER(jsval)]
-
-JS_SetReservedSlot = libsmjs.JS_SetReservedSlot
-JS_SetReservedSlot.restype = JSBool
-JS_SetReservedSlot.argtypes = [POINTER(JSContext),POINTER(JSObject),c_uint,c_long]
-
-JS_SetPrincipalsTranscoder = libsmjs.JS_SetPrincipalsTranscoder
-JS_SetPrincipalsTranscoder.restype = JSPrincipalsTranscoder
-JS_SetPrincipalsTranscoder.argtypes = [POINTER(JSRuntime),CFUNCTYPE(JSBool,POINTER(JSXDRState),POINTER(POINTER(JSPrincipals)))]
-
-JS_SetObjectPrincipalsFinder = libsmjs.JS_SetObjectPrincipalsFinder
-JS_SetObjectPrincipalsFinder.restype = JSObjectPrincipalsFinder
-JS_SetObjectPrincipalsFinder.argtypes = [POINTER(JSContext),CFUNCTYPE(POINTER(JSPrincipals),POINTER(JSContext),POINTER(JSObject))]
-
-JS_NewFunction = libsmjs.JS_NewFunction
-JS_NewFunction.restype = POINTER(JSFunction)
-JS_NewFunction.argtypes = [POINTER(JSContext),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_uint,POINTER(jsval),POINTER(jsval)),c_uint,c_uint,POINTER(JSObject),c_char_p]
-
-JS_GetFunctionObject = libsmjs.JS_GetFunctionObject
-JS_GetFunctionObject.restype = POINTER(JSObject)
-JS_GetFunctionObject.argtypes = [POINTER(JSFunction)]
-
-JS_GetFunctionName = libsmjs.JS_GetFunctionName
-JS_GetFunctionName.restype = c_char_p
-JS_GetFunctionName.argtypes = [POINTER(JSFunction)]
-
-JS_GetFunctionId = libsmjs.JS_GetFunctionId
-JS_GetFunctionId.restype = POINTER(JSString)
-JS_GetFunctionId.argtypes = [POINTER(JSFunction)]
-
-JS_GetFunctionFlags = libsmjs.JS_GetFunctionFlags
-JS_GetFunctionFlags.restype = uintN
-JS_GetFunctionFlags.argtypes = [POINTER(JSFunction)]
-
-JS_ObjectIsFunction = libsmjs.JS_ObjectIsFunction
-JS_ObjectIsFunction.restype = JSBool
-JS_ObjectIsFunction.argtypes = [POINTER(JSContext),POINTER(JSObject)]
-
-JS_DefineFunctions = libsmjs.JS_DefineFunctions
-JS_DefineFunctions.restype = JSBool
-JS_DefineFunctions.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSFunctionSpec)]
-
-JS_DefineFunction = libsmjs.JS_DefineFunction
-JS_DefineFunction.restype = POINTER(JSFunction)
-JS_DefineFunction.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSObject),c_uint,POINTER(jsval),POINTER(jsval)),c_uint,c_uint]
-
-JS_CloneFunctionObject = libsmjs.JS_CloneFunctionObject
-JS_CloneFunctionObject.restype = POINTER(JSObject)
-JS_CloneFunctionObject.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSObject)]
-
-JS_BufferIsCompilableUnit = libsmjs.JS_BufferIsCompilableUnit
-JS_BufferIsCompilableUnit.restype = JSBool
-JS_BufferIsCompilableUnit.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_uint]
-
-JS_CompileScript = libsmjs.JS_CompileScript
-JS_CompileScript.restype = POINTER(JSScript)
-JS_CompileScript.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_uint,c_char_p,c_uint]
-
-JS_CompileScriptForPrincipals = libsmjs.JS_CompileScriptForPrincipals
-JS_CompileScriptForPrincipals.restype = POINTER(JSScript)
-JS_CompileScriptForPrincipals.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSPrincipals),c_char_p,c_uint,c_char_p,c_uint]
-
-JS_CompileUCScript = libsmjs.JS_CompileUCScript
-JS_CompileUCScript.restype = POINTER(JSScript)
-JS_CompileUCScript.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,c_char_p,c_uint]
-
-JS_CompileUCScriptForPrincipals = libsmjs.JS_CompileUCScriptForPrincipals
-JS_CompileUCScriptForPrincipals.restype = POINTER(JSScript)
-JS_CompileUCScriptForPrincipals.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSPrincipals),POINTER(jschar),c_uint,c_char_p,c_uint]
-
-JS_CompileFile = libsmjs.JS_CompileFile
-JS_CompileFile.restype = POINTER(JSScript)
-JS_CompileFile.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p]
-
-class _IO_marker(Structure):
- _fields_ = [
- ('_next', c_void_p),
- ('_sbuf', POINTER(_IO_FILE)),
- ('_pos', c_int),
- ]
-
-t__off_t = c_long
-
-_IO_lock_t = None
-
-t__quad_t = c_longlong
-
-t__off64_t = t__quad_t
-
-class _IO_FILE(Structure):
- _fields_ = [
- ('_flags', c_int),
- ('_IO_read_ptr', c_char_p),
- ('_IO_read_end', c_char_p),
- ('_IO_read_base', c_char_p),
- ('_IO_write_base', c_char_p),
- ('_IO_write_ptr', c_char_p),
- ('_IO_write_end', c_char_p),
- ('_IO_buf_base', c_char_p),
- ('_IO_buf_end', c_char_p),
- ('_IO_save_base', c_char_p),
- ('_IO_backup_base', c_char_p),
- ('_IO_save_end', c_char_p),
- ('_markers', POINTER(_IO_marker)),
- ('_chain', c_void_p),
- ('_fileno', c_int),
- ('_flags2', c_int),
- ('_old_offset', t__off_t),
- ('_cur_column', c_ushort),
- ('_vtable_offset', c_char),
- ('_shortbuf', c_char*1),
- ('_lock', POINTER(_IO_lock_t)),
- ('_offset', t__off64_t),
- ('__pad1', c_void_p),
- ('__pad2', c_void_p),
- ('_mode', c_int),
- ('_unused2', c_char*52),
- ]
-
-FILE = _IO_FILE
-
-JS_CompileFileHandle = libsmjs.JS_CompileFileHandle
-JS_CompileFileHandle.restype = POINTER(JSScript)
-JS_CompileFileHandle.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(FILE)]
-
-JS_CompileFileHandleForPrincipals = libsmjs.JS_CompileFileHandleForPrincipals
-JS_CompileFileHandleForPrincipals.restype = POINTER(JSScript)
-JS_CompileFileHandleForPrincipals.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,POINTER(FILE),POINTER(JSPrincipals)]
-
-JS_NewScriptObject = libsmjs.JS_NewScriptObject
-JS_NewScriptObject.restype = POINTER(JSObject)
-JS_NewScriptObject.argtypes = [POINTER(JSContext),POINTER(JSScript)]
-
-JS_GetScriptObject = libsmjs.JS_GetScriptObject
-JS_GetScriptObject.restype = POINTER(JSObject)
-JS_GetScriptObject.argtypes = [POINTER(JSScript)]
-
-JS_DestroyScript = libsmjs.JS_DestroyScript
-JS_DestroyScript.restype = None
-JS_DestroyScript.argtypes = [POINTER(JSContext),POINTER(JSScript)]
-
-JS_CompileFunction = libsmjs.JS_CompileFunction
-JS_CompileFunction.restype = POINTER(JSFunction)
-JS_CompileFunction.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_uint,POINTER(c_char_p),c_char_p,c_uint,c_char_p,c_uint]
-
-JS_CompileFunctionForPrincipals = libsmjs.JS_CompileFunctionForPrincipals
-JS_CompileFunctionForPrincipals.restype = POINTER(JSFunction)
-JS_CompileFunctionForPrincipals.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSPrincipals),c_char_p,c_uint,POINTER(c_char_p),c_char_p,c_uint,c_char_p,c_uint]
-
-JS_CompileUCFunction = libsmjs.JS_CompileUCFunction
-JS_CompileUCFunction.restype = POINTER(JSFunction)
-JS_CompileUCFunction.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_uint,POINTER(c_char_p),POINTER(jschar),c_uint,c_char_p,c_uint]
-
-JS_CompileUCFunctionForPrincipals = libsmjs.JS_CompileUCFunctionForPrincipals
-JS_CompileUCFunctionForPrincipals.restype = POINTER(JSFunction)
-JS_CompileUCFunctionForPrincipals.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSPrincipals),c_char_p,c_uint,POINTER(c_char_p),POINTER(jschar),c_uint,c_char_p,c_uint]
-
-JS_DecompileScript = libsmjs.JS_DecompileScript
-JS_DecompileScript.restype = POINTER(JSString)
-JS_DecompileScript.argtypes = [POINTER(JSContext),POINTER(JSScript),c_char_p,c_uint]
-
-JS_DecompileFunction = libsmjs.JS_DecompileFunction
-JS_DecompileFunction.restype = POINTER(JSString)
-JS_DecompileFunction.argtypes = [POINTER(JSContext),POINTER(JSFunction),c_uint]
-
-JS_DecompileFunctionBody = libsmjs.JS_DecompileFunctionBody
-JS_DecompileFunctionBody.restype = POINTER(JSString)
-JS_DecompileFunctionBody.argtypes = [POINTER(JSContext),POINTER(JSFunction),c_uint]
-
-JS_ExecuteScript = libsmjs.JS_ExecuteScript
-JS_ExecuteScript.restype = JSBool
-JS_ExecuteScript.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSScript),POINTER(jsval)]
-
-# enumeration JSExecPart
-JSEXEC_PROLOG = 0
-JSEXEC_MAIN = 1
-
-JSExecPart = c_int
-
-JS_ExecuteScriptPart = libsmjs.JS_ExecuteScriptPart
-JS_ExecuteScriptPart.restype = JSBool
-JS_ExecuteScriptPart.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSScript),c_int,POINTER(jsval)]
-
-JS_EvaluateScript = libsmjs.JS_EvaluateScript
-JS_EvaluateScript.restype = JSBool
-JS_EvaluateScript.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_uint,c_char_p,c_uint,POINTER(jsval)]
-
-JS_EvaluateScriptForPrincipals = libsmjs.JS_EvaluateScriptForPrincipals
-JS_EvaluateScriptForPrincipals.restype = JSBool
-JS_EvaluateScriptForPrincipals.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSPrincipals),c_char_p,c_uint,c_char_p,c_uint,POINTER(jsval)]
-
-JS_EvaluateUCScript = libsmjs.JS_EvaluateUCScript
-JS_EvaluateUCScript.restype = JSBool
-JS_EvaluateUCScript.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(jschar),c_uint,c_char_p,c_uint,POINTER(jsval)]
-
-JS_EvaluateUCScriptForPrincipals = libsmjs.JS_EvaluateUCScriptForPrincipals
-JS_EvaluateUCScriptForPrincipals.restype = JSBool
-JS_EvaluateUCScriptForPrincipals.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSPrincipals),POINTER(jschar),c_uint,c_char_p,c_uint,POINTER(jsval)]
-
-JS_CallFunction = libsmjs.JS_CallFunction
-JS_CallFunction.restype = JSBool
-JS_CallFunction.argtypes = [POINTER(JSContext),POINTER(JSObject),POINTER(JSFunction),c_uint,POINTER(jsval),POINTER(jsval)]
-
-JS_CallFunctionName = libsmjs.JS_CallFunctionName
-JS_CallFunctionName.restype = JSBool
-JS_CallFunctionName.argtypes = [POINTER(JSContext),POINTER(JSObject),c_char_p,c_uint,POINTER(jsval),POINTER(jsval)]
-
-JS_CallFunctionValue = libsmjs.JS_CallFunctionValue
-JS_CallFunctionValue.restype = JSBool
-JS_CallFunctionValue.argtypes = [POINTER(JSContext),POINTER(JSObject),c_long,c_uint,POINTER(jsval),POINTER(jsval)]
-
-JS_SetBranchCallback = libsmjs.JS_SetBranchCallback
-JS_SetBranchCallback.restype = JSBranchCallback
-JS_SetBranchCallback.argtypes = [POINTER(JSContext),CFUNCTYPE(JSBool,POINTER(JSContext),POINTER(JSScript))]
-
-JS_IsRunning = libsmjs.JS_IsRunning
-JS_IsRunning.restype = JSBool
-JS_IsRunning.argtypes = [POINTER(JSContext)]
-
-JS_IsConstructing = libsmjs.JS_IsConstructing
-JS_IsConstructing.restype = JSBool
-JS_IsConstructing.argtypes = [POINTER(JSContext)]
-
-JS_IsAssigning = libsmjs.JS_IsAssigning
-JS_IsAssigning.restype = JSBool
-JS_IsAssigning.argtypes = [POINTER(JSContext)]
-
-JS_SetCallReturnValue2 = libsmjs.JS_SetCallReturnValue2
-JS_SetCallReturnValue2.restype = None
-JS_SetCallReturnValue2.argtypes = [POINTER(JSContext),c_long]
-
-JS_NewString = libsmjs.JS_NewString
-JS_NewString.restype = POINTER(JSString)
-JS_NewString.argtypes = [POINTER(JSContext),c_char_p,c_uint]
-
-JS_NewStringCopyN = libsmjs.JS_NewStringCopyN
-JS_NewStringCopyN.restype = POINTER(JSString)
-JS_NewStringCopyN.argtypes = [POINTER(JSContext),c_char_p,c_uint]
-
-JS_NewStringCopyZ = libsmjs.JS_NewStringCopyZ
-JS_NewStringCopyZ.restype = POINTER(JSString)
-JS_NewStringCopyZ.argtypes = [POINTER(JSContext),c_char_p]
-
-JS_InternString = libsmjs.JS_InternString
-JS_InternString.restype = POINTER(JSString)
-JS_InternString.argtypes = [POINTER(JSContext),c_char_p]
-
-JS_NewUCString = libsmjs.JS_NewUCString
-JS_NewUCString.restype = POINTER(JSString)
-JS_NewUCString.argtypes = [POINTER(JSContext),POINTER(jschar),c_uint]
-
-JS_NewUCStringCopyN = libsmjs.JS_NewUCStringCopyN
-JS_NewUCStringCopyN.restype = POINTER(JSString)
-JS_NewUCStringCopyN.argtypes = [POINTER(JSContext),POINTER(jschar),c_uint]
-
-JS_NewUCStringCopyZ = libsmjs.JS_NewUCStringCopyZ
-JS_NewUCStringCopyZ.restype = POINTER(JSString)
-JS_NewUCStringCopyZ.argtypes = [POINTER(JSContext),POINTER(jschar)]
-
-JS_InternUCStringN = libsmjs.JS_InternUCStringN
-JS_InternUCStringN.restype = POINTER(JSString)
-JS_InternUCStringN.argtypes = [POINTER(JSContext),POINTER(jschar),c_uint]
-
-JS_InternUCString = libsmjs.JS_InternUCString
-JS_InternUCString.restype = POINTER(JSString)
-JS_InternUCString.argtypes = [POINTER(JSContext),POINTER(jschar)]
-
-JS_GetStringBytes = libsmjs.JS_GetStringBytes
-JS_GetStringBytes.restype = c_char_p
-JS_GetStringBytes.argtypes = [POINTER(JSString)]
-
-JS_GetStringChars = libsmjs.JS_GetStringChars
-JS_GetStringChars.restype = POINTER(jschar)
-JS_GetStringChars.argtypes = [POINTER(JSString)]
-
-JS_GetStringLength = libsmjs.JS_GetStringLength
-JS_GetStringLength.restype = size_t
-JS_GetStringLength.argtypes = [POINTER(JSString)]
-
-JS_CompareStrings = libsmjs.JS_CompareStrings
-JS_CompareStrings.restype = intN
-JS_CompareStrings.argtypes = [POINTER(JSString),POINTER(JSString)]
-
-JS_NewGrowableString = libsmjs.JS_NewGrowableString
-JS_NewGrowableString.restype = POINTER(JSString)
-JS_NewGrowableString.argtypes = [POINTER(JSContext),POINTER(jschar),c_uint]
-
-JS_NewDependentString = libsmjs.JS_NewDependentString
-JS_NewDependentString.restype = POINTER(JSString)
-JS_NewDependentString.argtypes = [POINTER(JSContext),POINTER(JSString),c_uint,c_uint]
-
-JS_ConcatStrings = libsmjs.JS_ConcatStrings
-JS_ConcatStrings.restype = POINTER(JSString)
-JS_ConcatStrings.argtypes = [POINTER(JSContext),POINTER(JSString),POINTER(JSString)]
-
-JS_UndependString = libsmjs.JS_UndependString
-JS_UndependString.restype = POINTER(jschar)
-JS_UndependString.argtypes = [POINTER(JSContext),POINTER(JSString)]
-
-JS_MakeStringImmutable = libsmjs.JS_MakeStringImmutable
-JS_MakeStringImmutable.restype = JSBool
-JS_MakeStringImmutable.argtypes = [POINTER(JSContext),POINTER(JSString)]
-
-JS_SetLocaleCallbacks = libsmjs.JS_SetLocaleCallbacks
-JS_SetLocaleCallbacks.restype = None
-JS_SetLocaleCallbacks.argtypes = [POINTER(JSContext),POINTER(JSLocaleCallbacks)]
-
-JS_GetLocaleCallbacks = libsmjs.JS_GetLocaleCallbacks
-JS_GetLocaleCallbacks.restype = POINTER(JSLocaleCallbacks)
-JS_GetLocaleCallbacks.argtypes = [POINTER(JSContext)]
-
-JS_ReportError = libsmjs.JS_ReportError
-JS_ReportError.restype = None
-JS_ReportError.argtypes = [POINTER(JSContext),c_char_p]
-
-JS_ReportErrorNumber = libsmjs.JS_ReportErrorNumber
-JS_ReportErrorNumber.restype = None
-JS_ReportErrorNumber.argtypes = [POINTER(JSContext),CFUNCTYPE(POINTER(JSErrorFormatString),c_void_p,c_char_p,c_uint),c_void_p,c_uint]
-
-JS_ReportErrorNumberUC = libsmjs.JS_ReportErrorNumberUC
-JS_ReportErrorNumberUC.restype = None
-JS_ReportErrorNumberUC.argtypes = [POINTER(JSContext),CFUNCTYPE(POINTER(JSErrorFormatString),c_void_p,c_char_p,c_uint),c_void_p,c_uint]
-
-JS_ReportWarning = libsmjs.JS_ReportWarning
-JS_ReportWarning.restype = JSBool
-JS_ReportWarning.argtypes = [POINTER(JSContext),c_char_p]
-
-JS_ReportErrorFlagsAndNumber = libsmjs.JS_ReportErrorFlagsAndNumber
-JS_ReportErrorFlagsAndNumber.restype = JSBool
-JS_ReportErrorFlagsAndNumber.argtypes = [POINTER(JSContext),c_uint,CFUNCTYPE(POINTER(JSErrorFormatString),c_void_p,c_char_p,c_uint),c_void_p,c_uint]
-
-JS_ReportErrorFlagsAndNumberUC = libsmjs.JS_ReportErrorFlagsAndNumberUC
-JS_ReportErrorFlagsAndNumberUC.restype = JSBool
-JS_ReportErrorFlagsAndNumberUC.argtypes = [POINTER(JSContext),c_uint,CFUNCTYPE(POINTER(JSErrorFormatString),c_void_p,c_char_p,c_uint),c_void_p,c_uint]
-
-JS_ReportOutOfMemory = libsmjs.JS_ReportOutOfMemory
-JS_ReportOutOfMemory.restype = None
-JS_ReportOutOfMemory.argtypes = [POINTER(JSContext)]
-
-JS_SetErrorReporter = libsmjs.JS_SetErrorReporter
-JS_SetErrorReporter.restype = JSErrorReporter
-JS_SetErrorReporter.argtypes = [POINTER(JSContext),CFUNCTYPE(None,POINTER(JSContext),c_char_p,POINTER(JSErrorReport))]
-
-JS_NewRegExpObject = libsmjs.JS_NewRegExpObject
-JS_NewRegExpObject.restype = POINTER(JSObject)
-JS_NewRegExpObject.argtypes = [POINTER(JSContext),c_char_p,c_uint,c_uint]
-
-JS_NewUCRegExpObject = libsmjs.JS_NewUCRegExpObject
-JS_NewUCRegExpObject.restype = POINTER(JSObject)
-JS_NewUCRegExpObject.argtypes = [POINTER(JSContext),POINTER(jschar),c_uint,c_uint]
-
-JS_SetRegExpInput = libsmjs.JS_SetRegExpInput
-JS_SetRegExpInput.restype = None
-JS_SetRegExpInput.argtypes = [POINTER(JSContext),POINTER(JSString),c_int]
-
-JS_ClearRegExpStatics = libsmjs.JS_ClearRegExpStatics
-JS_ClearRegExpStatics.restype = None
-JS_ClearRegExpStatics.argtypes = [POINTER(JSContext)]
-
-JS_ClearRegExpRoots = libsmjs.JS_ClearRegExpRoots
-JS_ClearRegExpRoots.restype = None
-JS_ClearRegExpRoots.argtypes = [POINTER(JSContext)]
-
-JS_IsExceptionPending = libsmjs.JS_IsExceptionPending
-JS_IsExceptionPending.restype = JSBool
-JS_IsExceptionPending.argtypes = [POINTER(JSContext)]
-
-JS_GetPendingException = libsmjs.JS_GetPendingException
-JS_GetPendingException.restype = JSBool
-JS_GetPendingException.argtypes = [POINTER(JSContext),POINTER(jsval)]
-
-JS_SetPendingException = libsmjs.JS_SetPendingException
-JS_SetPendingException.restype = None
-JS_SetPendingException.argtypes = [POINTER(JSContext),c_long]
-
-JS_ClearPendingException = libsmjs.JS_ClearPendingException
-JS_ClearPendingException.restype = None
-JS_ClearPendingException.argtypes = [POINTER(JSContext)]
-
-JS_SaveExceptionState = libsmjs.JS_SaveExceptionState
-JS_SaveExceptionState.restype = POINTER(JSExceptionState)
-JS_SaveExceptionState.argtypes = [POINTER(JSContext)]
-
-JS_RestoreExceptionState = libsmjs.JS_RestoreExceptionState
-JS_RestoreExceptionState.restype = None
-JS_RestoreExceptionState.argtypes = [POINTER(JSContext),POINTER(JSExceptionState)]
-
-JS_DropExceptionState = libsmjs.JS_DropExceptionState
-JS_DropExceptionState.restype = None
-JS_DropExceptionState.argtypes = [POINTER(JSContext),POINTER(JSExceptionState)]
-
-JS_ErrorFromException = libsmjs.JS_ErrorFromException
-JS_ErrorFromException.restype = POINTER(JSErrorReport)
-JS_ErrorFromException.argtypes = [POINTER(JSContext),c_long]
-
-JSACC_TYPEMASK = (JSACC_WRITE - 1)
-JSLL_MAXINT = JSLL_MaxInt()
-JSLL_MININT = JSLL_MinInt()
-JSLL_ZERO = JSLL_Zero()
-
-_tabs = 0
-
-def _log_call(func, *args, **kargs):
- global _tabs
- _tabs += 1
- try:
- print '\t'*_tabs + 'CALL {',func,args,kargs,'}'
- r = func(*args,**kargs)
- print '\t'*_tabs + "RETURNED",r
- finally:
- _tabs += 0
- return r
-
-def log_call(func):
- return lambda *args, **kargs: _log_call(func,*args,**kargs)
-
-class JSError(Exception):
- pass
-
-def dict_from_JShash(context, hash):
- #~ cdef JSIdArray *prop_arr
- #~ cdef int i
- #~ cdef jsval jskey
- #~ cdef jsval jsvalue
- #~ cdef JSObject *obj
-
-
- cx = context.cx
-
- prop_arr = JS_Enumerate(cx, hash).contents
-
- jskey = jsval()
- jsvalue = jsval()
-
- d = {}
-
- for i in range(prop_arr.length):
- vector = cast(addressof(prop_arr.vector),POINTER(c_long))
- JS_IdToValue(cx, (vector)[i], byref(jskey))
-
- if JSVAL_IS_STRING(jskey):
- key = JS_GetStringBytes(JSVAL_TO_STRING(jskey))
- JS_GetProperty(cx, hash, key, byref(jsvalue))
- elif JSVAL_IS_INT(jskey):
- key = JSVAL_TO_INT(jskey)
- JS_GetElement(cx, hash, key, byref(jsvalue))
- else:
- assert False, "can't happen"
-
- if JSVAL_IS_PRIMITIVE(jsvalue):
- d[key] = Py_from_JSprimitive(jsvalue)
- else:
- if JSVAL_IS_OBJECT(jsvalue):
- obj = JSVAL_TO_OBJECT(jsvalue)
- if JS_IsArrayObject(cx, obj):
- d[key] = list_from_JSarray(context, obj)
- else:
- d[key] = dict_from_JShash(context, obj)
-
- JS_DestroyIdArray(cx, prop_arr)
-
- return d
-
-def list_from_JSarray(context, array):
- #~ cdef int nr_elems, i
- #~ cdef jsval elem
- #~ cdef JSObject *jsobj
-
- nr_elems = c_uint()
- elem = jsval()
-
- cx = context.cx
- JS_GetArrayLength(cx, array, byref(nr_elems))
- nr_elems = nr_elems.value
-
- l = [None]*nr_elems
-
- for i in range(nr_elems):
- JS_GetElement(cx, array, i, byref(elem))
-
- if JSVAL_IS_PRIMITIVE(elem):
- l[i] = Py_from_JSprimitive(elem)
- elif JSVAL_IS_OBJECT(elem):
- jsobj = JSVAL_TO_OBJECT(elem)
- if JS_IsArrayObject(cx, jsobj):
- l[i] = list_from_JSarray(context, jsobj)
- else:
- l[i] = dict_from_JShash(context, jsobj)
-
- return l
-
-def Py_from_JSprimitive(v):
- # JS_NULL is null, JS_VOID is undefined
- if JSVAL_IS_NULL(v) or JSVAL_IS_VOID(v):
- return None
- elif JSVAL_IS_INT(v):
- return JSVAL_TO_INT(v)
- elif JSVAL_IS_DOUBLE(v):
- return JSVAL_TO_DOUBLE(v)[0]
- elif JSVAL_IS_STRING(v):
- return JS_GetStringBytes(JSVAL_TO_STRING(v))
- elif JSVAL_IS_BOOLEAN(v):
- return bool(JSVAL_TO_BOOLEAN(v))
- else:
- raise SystemError("unknown primitive type")
-
-def Py_from_JS(context, v):
- # Convert JavaScript value to equivalent Python value.
- #~ cdef JSObject *object
- #~ cdef ProxyObject proxy_obj
- #~ cdef Context context
-
- if JSVAL_IS_PRIMITIVE(v):
- return Py_from_JSprimitive(v)
- else:
- if JSVAL_IS_OBJECT(v):
- object = JSVAL_TO_OBJECT(v)
-
- if JS_IsArrayObject(context.cx, object):
- return list_from_JSarray(context, object)
- else:
- try:
- proxy_obj = context.get_object(object)
- except ValueError:
- return dict_from_JShash(context, object)
- else:
- return proxy_obj.obj
-
-def isinteger(x):
- return bool(compat_isinstance(x, (IntType, LongType)))
-
-def isfloat(x):
- return bool(compat_isinstance(x, FloatType))
-
-def isstringlike(x):
- return bool(compat_isinstance(x, StringTypes))
-
-def issequence(x):
- return bool(compat_isinstance(x, (ListType, TupleType)))
-
-def ismapping(x):
- return bool(compat_isinstance(x, DictType))
-
-def js_classname(pobj):
- # class or instance?
- try:
- klass = pobj.__class__
- except AttributeError:
- klass = pobj
-
- try:
- name = klass.js_name
- except AttributeError:
- name = klass.__name__
-
- if not isstringlike(name):
- raise AttributeError("%s js_name attribute is not string-like" % klass)
- return name
-
-def JS_from_Py(context, parent, py_obj):
- # Convert Python value to equivalent JavaScript value.
- #~ cdef JSObject *jsobj
- #~ cdef JSString *s
-
- #~ cdef jsval elem
- #~ cdef jsval rval
-
- #~ cdef int i
- #~ cdef int nr_elems
- #~ cdef jsval *elems
- #~ cdef JSObject *arr_obj
-
- #~ cdef Context context
- #~ cdef ProxyClass proxy_class
- #~ cdef ProxyObject proxy_obj
-
- rval = jsval()
- cx = context.cx
-
- if py_obj is None:
- return JSVAL_VOID
- elif isinteger(py_obj):
- return INT_TO_JSVAL(py_obj)
- elif isfloat(py_obj):
- d = JS_NewDouble(cx, py_obj)
- if d == None:
- raise SystemError("can't create new double")
- return DOUBLE_TO_JSVAL(d)
- elif isstringlike(py_obj):
- s = JS_NewStringCopyN(cx, py_obj, len(py_obj))
- if s == None:
- raise SystemError("can't create new string")
- return STRING_TO_JSVAL(s)
- elif ismapping(py_obj):
- jsobj = JS_NewObject(cx, None, None, None)
-
- if jsobj == None:
- raise SystemError("can't create new object")
- else:
- # assign properties
- for key, value in py_obj.iteritems():
- elem = JS_from_Py(context, parent, value)
- ok = JS_DefineProperty(cx, jsobj, key, elem, None, None, JSPROP_ENUMERATE)
- if not ok:
- raise SystemError("can't define property")
-
- return OBJECT_TO_JSVAL(jsobj)
-
- elif issequence(py_obj):
- arr_obj = JS_NewArrayObject(cx, 0, None)
-
- if arr_obj == None:
- raise SystemError("can't create new array object")
- else:
- for i in range(len(py_obj)):
- elem = JS_from_Py(context, parent, py_obj[i])
- ok = JS_DefineElement(cx, arr_obj, i, elem, None, None, JSPROP_ENUMERATE)
- if not ok:
- raise SystemError("can't define element")
-
- return OBJECT_TO_JSVAL(arr_obj)
- elif compat_isinstance(py_obj, MethodType):
- # XXX leak? -- calls JS_DefineFunction every time a method
- # is called
- return context.new_method(py_obj)
- elif compat_isinstance(py_obj, (FunctionType, LambdaType)):
- # XXX implement me?
- return JSVAL_VOID
- else:
- # If we get here, py_obj is probably a Python class or a class instance.
- # XXXX could problems be caused if some weird object such a module or
- # regexp or code object were, eg., returned by a Python function?
-
- # is object already bound to a JS proxy?...
- try:
- proxy_obj = context.get_object_from_py(py_obj)
- except ValueError:
- # ...no, so create and register a new JS proxy
- proxy_class = context.get_class(js_classname(py_obj))
- # XXXX I have *no idea* if using globj as the proto here is
- # correct! If I don't put globj in here, JS does a get_property
- # on an object that hasn't been registered with the Context --
- # dunno why.
- jsobj = proxy_class.new_object(parent=parent,py_obj = py_obj) # JS_NewObject(cx, proxy_class.jsc, context.globj, parent)
- if jsobj == None:
- raise SystemError("couldn't look up or create new object")
- else:
- # ...yes, use existing proxy
- jsobj = proxy_obj.jsobj
- return OBJECT_TO_JSVAL(jsobj)
-
-class Runtime:
-
- def __init__(self, memsize = (8*1024*1024), max_context = 32):
-
- self.rt = JS_Init(memsize)
- self._cxs = []
- self._max_context = max_context
-
- def __dealloc__(self):
- JS_Finish(self.rt)
-
- def new_context(self, globj = None, stacksize = 8192):
- context = Context(globj, self, stacksize)
- self._cxs.append(context)
- if len(self._cxs) > self._max_context:
- old_cx = self._cxs.pop(0)
- old_cx.alive = False
- JS_DestroyContext(old_cx.cx)
- context.initialize()
- return context
-
-import sys, inspect
-
-class ProxyObject:
- def __init__(self, obj, jsobj = None):
- self.obj = obj
- self.jsobj = jsobj
-
-def compat_isinstance(obj, tuple_or_obj):
- if type(tuple_or_obj) == TupleType:
- for otherobj in tuple_or_obj:
- if isinstance(obj, otherobj):
- return True
- return False
- return isinstance(obj, tuple_or_obj)
-
-from types import *
-
-class ProxyClass:
- def __init__(self, context, classobject, bind_constructor, is_global, flags):
- self.context = context
- name = js_classname(classobject)
- self.classobject = classobject
- self.jsclass = JSClass()
- self.jsclass.name = name
- self.jsclass.flags = flags
- self.jsclass.addProperty = JS_PropertyStub
- self.jsclass.delProperty = JS_PropertyStub
- self.jsclass.getProperty = self.context._get_property
- self.jsclass.setProperty = self.context._set_property
- self.jsclass.enumerate = JS_EnumerateStub
- if is_global:
- self._resolve_global = JSResolveOp(self.resolve_global)
- self.jsclass.resolve = self._resolve_global
- else:
- self.jsclass.resolve = JS_ResolveStub
- self.jsclass.convert = JS_ConvertStub
- self.jsclass.finalize = JS_FinalizeStub
-
- if bind_constructor:
- self._constructor_cb = JSNative(self.constructor_cb)
- res = JS_InitClass(context.cx, context._global, None, self.jsclass, self._constructor_cb, 0, None, None, None, None)
- assert res, "couldn't initialise JavaScript proxy class"
-
- def resolve_global(self, cx, obj, id):
- #~ cdef Context context
- #~ cdef ProxyObject proxy_obj
- #~ cdef object thing
- #~ cdef object key
-
- try:
- proxy_obj = self.context.get_object(obj)
- thing = proxy_obj.obj
- key = Py_from_JS(self.context, id)
- if type(key) == str and hasattr(thing, key):
- attr = getattr(thing, key)
- if compat_isinstance(attr, MethodType):
- self.context.bind_callable(key, attr)
- else:
- self.context.bind_attribute(key, thing, key)
- return JS_TRUE
- except:
- return self.context.report()
- return JS_FALSE
-
- def constructor_cb(self, cx, obj, argc, argv, rval):
- #~ cdef ProxyClass proxy_class
- #~ cdef Context context
- #~ cdef char *fname
- #~ cdef JSFunction *func
- #~ cdef int arg
- #~ cdef ProxyObject object
- func = JS_ValueToFunction(cx, argv[-2])
- if not func:
- msg = "couldn't get JS constructor"
- JS_ReportError(cx, msg)
- return JS_FALSE
- fname = JS_GetFunctionName(func)
- try:
- args = []
- for arg in range(argc):
- args.append(Py_from_JS(cx, argv[arg]))
- if hasattr(self.classobject, "js_constructor"):
- py_rval = self.classobject.js_constructor[0](self.context, *args)
- else:
- py_rval = self.classobject(*args)
- self.context.register_object(py_rval, obj)
- except:
- self.context.report()
-
- return JS_TRUE
-
- def new_object(self, parent = None, py_obj = None):
- proto = self.context._global
- jsobj = JS_NewObject(self.context.cx, byref(self.jsclass), proto, parent)
- if py_obj:
- self.context.register_object(py_obj, jsobj)
- return jsobj
-
-stderr = sys.stderr
-
-class DestroyedContext(Exception):
- def __str__(self):
- return "Context Memory has been released previously by Runtime Class sanity checks."
-
-class Context:
- cx = None
-
- class global_class:
- js_name = 'global'
-
- _global = None
-
- def __init__(self, globj, runtime, stacksize):
- self.cx = JS_NewContext(runtime.rt, stacksize)
- self.alive = True
- self.classes = []
- self.objects = []
- self.funcs = []
- #self.runtime = runtime
- self._get_property = JSPropertyOp(self.get_property)
- self._set_property = JSPropertyOp(self.set_property)
- self._bound_method_cb = JSNative(self.bound_method_cb)
- if not globj:
- globj = self.global_class()
- global_class = self.bind_class(globj.__class__, bind_constructor = False, is_global = True)
- self._global = global_class.new_object(py_obj = globj)
- assert self._global
-
- def get_object_from_py(self, py_obj):
- for proxy_obj in self.objects:
- if proxy_obj.obj == py_obj:
- return proxy_obj
- raise ValueError, py_obj
-
- def get_object(self, jsobj):
- for proxy_obj in self.objects:
- if addressof(proxy_obj.jsobj.contents) == addressof(jsobj.contents):
- return proxy_obj
- raise ValueError, jsobj.contents
-
- def get_class(self, name):
- #cdef ProxyClass cl
- for cl in self.classes:
- if cl.jsclass.name == name:
- return cl
- raise ValueError("no class named '%s' is bound" % name)
-
- def get_global(self, name):
- """Only works with undotted names. Use eval_script for anything
- else."""
- # XXXX probably best to get rid of this -- eval_script does the job
- #cdef jsval jsv
- if not isstringlike(name):
- raise TypeError("name must be string-like")
- jsv = jsval()
- if not JS_GetProperty(self.cx, self._global, name, byref(jsv)):
- raise SystemError("can't get JavaScript property")
- val = Py_from_JS(self, jsv)
- if val is None:
- raise ValueError("no global named '%s'" % name)
- ## # XXXX why does this hang??
- ## raise AttributeError("%s instance has no attribute '%s'" %
- ## (self.__class__.__name__, name))
- else:
- return val
-
- def register_object(self, obj, jsobj):
- self.objects.append(ProxyObject(obj, jsobj))
-
- def report(self):
- import traceback
- self.report_error(traceback.format_exc())
-
- def report_error(self, msg, *args):
- JS_ReportError(self.cx, msg, *args)
-
- def error_reporter(self, cx, text, er):
- print >> stderr, text
-
- #def __del__(self):
- #JS_DestroyContext(self.cx)
-
- def new_method(self, py_method):
- #~ cdef JSFunction *method
- #~ cdef JSObject *method_obj
-
- # Method (hence its func_name attribute) will go away only when the
- # context is GC'd by Python, because the Python function object is
- # stored in Context extension type instance. XXX erm, no it isn't:
- # the class instance is kept in the ProxyClass, but the instance's
- # function is not. Hmm... XXX also, JS objects exist in runtime,
- # not in context!
- method = JS_NewFunction(self.cx, self._bound_method_cb, 0, 0, None, py_method.func_name)
- method_obj = JS_GetFunctionObject(method)
- return OBJECT_TO_JSVAL(method_obj)
-
- def get_property(self, cx, obj, id, vp):
- #~ cdef Context context
- #~ cdef ProxyObject proxy_obj
- #~ cdef object thing
- #~ cdef object key
-
- try:
- key = Py_from_JS(self, id)
- proxy_obj = self.get_object(obj)
- thing = proxy_obj.obj
- if type(key) == IntType:
- try:
- attr = thing[key]
- except:
- pass
- else:
- vp[0] = JS_from_Py(self, obj, attr)
- elif type(key) == StringType:
- if not key.startswith("_"):
- try:
- attr = getattr(thing, key)
- except:
- pass
- else:
- vp[0] = JS_from_Py(self, obj, attr)
- else:
- #in original version: assert False
- return JS_FALSE
- return JS_TRUE
- except:
- self.report()
- return JS_FALSE
-
- def set_property(self, cx, obj, id, vp):
- #~ cdef Context context
- #~ cdef ProxyObject proxy_obj
- #~ cdef object thing
- #~ cdef object key
- #~ cdef object value
- #~ cdef object attr
-
- try:
- proxy_obj = self.get_object(obj)
-
- thing = proxy_obj.obj
- key = Py_from_JS(self, id)
- value = Py_from_JS(self, vp[0])
- if type(key) == IntType:
- try:
- thing[key] = value
- except:
- pass
- elif type(key) == StringType:
- if hasattr(thing, key) and not key.startswith("_"):
- attr = getattr(thing, key)
- if not callable(attr):
- try:
- setattr(thing, key, value)
- except:
- pass
- else:
- assert False
- return JS_TRUE
- except:
- return self.report()
-
- return JS_FALSE
-
- def bound_method_cb(self, cx, obj, argc, argv, rval):
- #~ cdef Context context
- #~ cdef JSFunction *func
- #~ cdef int arg
- #~ cdef JSClass *jsclass
- #~ cdef ProxyObject proxy_obj
-
- func = JS_ValueToFunction(cx, argv[-2])
- method_name = JS_GetFunctionName(func)
- jsclass = JS_GetClass(self.cx, obj)
-
- try:
- proxy_obj = self.get_object(obj)
-
- py_args = []
- for arg in range(argc):
- py_args.append(Py_from_JS(self, argv[arg]))
- meth = getattr(proxy_obj.obj, method_name)
- py_rval = meth(*py_args)
- rval[0] = JS_from_Py(self, obj, py_rval)
- except:
- return self.report()
- return JS_TRUE
-
- def get_callback_fn(self, name):
- for cbname, fn in self.funcs:
- if cbname == name:
- return fn
- raise ValueError("no callback function named '%s' is bound" % name)
-
- def function_cb(self, cx, obj, argc, argv, rval):
- #~ cdef JSFunction *jsfunc
- #~ cdef int i
- #~ cdef char *name
-
- # XXX is this argv[-2] documented anywhere??
- jsfunc = JS_ValueToFunction(cx, argv[-2])
- if not jsfunc:
- return JS_FALSE
- name = JS_GetFunctionName(jsfunc)
- if not name:
- return JS_FALSE
-
- try:
- callback = self.get_callback_fn(name)
- args = []
- for i in range(argc):
- args.append(Py_from_JS(self, argv[i]))
- pyrval = callback(*args)
-
- # XXX shouldn't NULL be the JSObject if it's a Python class instance?
- rval[0] = JS_from_Py(self, None, pyrval)
- except:
- return self.report()
-
- return JS_TRUE
-
- def bind_callable(self, name, function):
- if not callable(function):
- raise ValueError("not a callable object")
- self._function_cb = JSNative(self.function_cb)
- self.funcs.append((name, function))
- JS_DefineFunction(self.cx, self._global, name, self._function_cb, 0, 0)
-
- def bind_attribute(self, name, obj, attr_name):
- #cdef jsval initial_value
- if not isstringlike(name):
- raise TypeError("name must be string-like")
- if not isstringlike(attr_name):
- raise TypeError("name must be string-like")
- initial_value = JS_from_Py(self, None, getattr(obj, name))
- JS_DefineProperty(self.cx, self._global, name, initial_value, cast(self._get_property,c_void_p), cast(self._set_property,c_void_p), 0)
-
- def bind_class(self, classobject, bind_constructor = True, is_global = False, flags = 0):
- if not inspect.isclass(classobject): raise TypeError("klass must be a class")
- if not isinteger(flags): raise TypeError("flags must be an integer")
-
- proxy_class = ProxyClass(self, classobject, bind_constructor, is_global, flags)
- self.classes.append(proxy_class)
- return proxy_class
-
- def bind_object(self, name, obj):
- #~ cdef JSObject *jsobj
- #~ cdef ProxyClass proxy_class
-
- if not isstringlike(name):
- raise TypeError("name must be string-like")
-
- proxy_class = self.get_class(js_classname(obj))
- jsobj = JS_DefineObject(self.cx, self._global, name, proxy_class.jsclass, None, JSPROP_READONLY)
- if jsobj:
- self.register_object(obj, jsobj)
- else:
- raise ValueError("failed to bind Python object %s" % obj)
-
- def initialize(self):
- JS_InitStandardClasses(self.cx, self._global)
- self._error_reporter = JSErrorReporter(self.error_reporter)
- JS_SetErrorReporter(self.cx, self._error_reporter)
-
- def eval_script(self, script):
- if not isstringlike(script):
- raise TypeError("name must be string-like")
- if not self.alive:
- raise DestroyedContext
- rval = jsval()
- if not JS_EvaluateScript(self.cx, self._global, script, len(script), 'Python', 0, byref(rval)):
- raise JSError, "Failed to execute script."
-
- retval = Py_from_JS(self, rval)
- JS_MaybeGC(self.cx)
- return retval
-
-if __name__ == '__main__':
- rt = Runtime()
- cx = rt.new_context()
-
- class foo:
- def test(self):
- return 1.0
-
- cx.bind_class(foo, bind_constructor=True)
- f = cx.eval_script("""var f = new foo();
- f.test(); // script return value
- """)
- print f
diff --git a/scrapy/trunk/scrapy/xpath/__init__.py b/scrapy/trunk/scrapy/xpath/__init__.py
deleted file mode 100644
index 44a60c3eb..000000000
--- a/scrapy/trunk/scrapy/xpath/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""
-The scrapy.xpath module provides useful classes for parsing HTML and XML
-documents using XPath. It requires libxml2 and its python bindings.
-
-This parent module exports the classes most commonly used when building
-spiders, for convenience.
-
-* XPath - a simple class to represent a XPath expression
-* XPathSelector - to extract data using XPaths (parses the entire response)
-"""
-
-from scrapy.xpath.types import XPath
-from scrapy.xpath.selector import XPathSelector, XmlXPathSelector, HtmlXPathSelector
diff --git a/scrapy/trunk/scrapy/xpath/document.py b/scrapy/trunk/scrapy/xpath/document.py
deleted file mode 100644
index f35ac8bc3..000000000
--- a/scrapy/trunk/scrapy/xpath/document.py
+++ /dev/null
@@ -1,22 +0,0 @@
-"""
-This module contains a simple class (Libxml2Document) to wrap libxml2 documents
-(xmlDoc) for proper garbage collection.
-"""
-
-from scrapy.xpath.constructors import xmlDoc_from_html
-
-class Libxml2Document(object):
-
- def __init__(self, response, constructor=xmlDoc_from_html):
- self.xmlDoc = constructor(response)
- self.xpathContext = self.xmlDoc.xpathNewContext()
-
- def __del__(self):
- if hasattr(self, 'xmlDoc'):
- self.xmlDoc.freeDoc()
- if hasattr(self, 'xpathContext'):
- self.xpathContext.xpathFreeContext()
-
- def __str__(self):
- return "<Libxml2Document %s>" % self.xmlDoc.name
-
diff --git a/scrapy/trunk/scrapy/xpath/types.py b/scrapy/trunk/scrapy/xpath/types.py
deleted file mode 100644
index 56d2efe96..000000000
--- a/scrapy/trunk/scrapy/xpath/types.py
+++ /dev/null
@@ -1,11 +0,0 @@
-class XPath(object):
- """A XPath expression"""
-
- def __init__(self, xpath_expr):
- self.expr = xpath_expr
-
- def __repr__(self):
- return "XPath(%s)" % repr(self.expr)
-
- def __str__(self):
- return self.expr
diff --git a/scrapy/trunk/scripts/rpm-install.sh b/scrapy/trunk/scripts/rpm-install.sh
deleted file mode 100644
index 710f18671..000000000
--- a/scrapy/trunk/scripts/rpm-install.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#! /bin/sh
-#
-# This file becomes the install section of the generated spec file.
-#
-
-python setup.py install --root=${RPM_BUILD_ROOT} --record="INSTALLED_FILES"
-
-cat << EOF >> INSTALLED_FILES
-/usr/bin/*.py*
-EOF
diff --git a/scrapy/trunk/scrapy/contrib/cluster/master/__init__.py b/scrapy/utils/__init__.py
similarity index 100%
rename from scrapy/trunk/scrapy/contrib/cluster/master/__init__.py
rename to scrapy/utils/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/c14n.py b/scrapy/utils/c14n.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/utils/c14n.py
rename to scrapy/utils/c14n.py
diff --git a/scrapy/trunk/scrapy/utils/datatypes.py b/scrapy/utils/datatypes.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/datatypes.py
rename to scrapy/utils/datatypes.py
diff --git a/scrapy/trunk/scrapy/utils/db.py b/scrapy/utils/db.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/db.py
rename to scrapy/utils/db.py
diff --git a/scrapy/trunk/scrapy/utils/defer.py b/scrapy/utils/defer.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/defer.py
rename to scrapy/utils/defer.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/display.py b/scrapy/utils/display.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/utils/display.py
rename to scrapy/utils/display.py
diff --git a/scrapy/trunk/scrapy/utils/http.py b/scrapy/utils/http.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/http.py
rename to scrapy/utils/http.py
diff --git a/scrapy/trunk/scrapy/utils/iterators.py b/scrapy/utils/iterators.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/iterators.py
rename to scrapy/utils/iterators.py
diff --git a/scrapy/trunk/scrapy/utils/markup.py b/scrapy/utils/markup.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/markup.py
rename to scrapy/utils/markup.py
diff --git a/scrapy/trunk/scrapy/utils/misc.py b/scrapy/utils/misc.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/misc.py
rename to scrapy/utils/misc.py
diff --git a/scrapy/trunk/scrapy/utils/python.py b/scrapy/utils/python.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/python.py
rename to scrapy/utils/python.py
diff --git a/scrapy/trunk/scrapy/utils/request.py b/scrapy/utils/request.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/request.py
rename to scrapy/utils/request.py
diff --git a/scrapy/trunk/scrapy/utils/response.py b/scrapy/utils/response.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/response.py
rename to scrapy/utils/response.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/utils/serialization.py b/scrapy/utils/serialization.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/utils/serialization.py
rename to scrapy/utils/serialization.py
diff --git a/scrapy/trunk/scrapy/utils/test.py b/scrapy/utils/test.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/test.py
rename to scrapy/utils/test.py
diff --git a/scrapy/trunk/scrapy/utils/url.py b/scrapy/utils/url.py
similarity index 100%
rename from scrapy/trunk/scrapy/utils/url.py
rename to scrapy/utils/url.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/BeautifulSoup.py b/scrapy/xlib/BeautifulSoup.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/BeautifulSoup.py
rename to scrapy/xlib/BeautifulSoup.py
diff --git a/scrapy/trunk/scrapy/xlib/ClientForm.py b/scrapy/xlib/ClientForm.py
similarity index 100%
rename from scrapy/trunk/scrapy/xlib/ClientForm.py
rename to scrapy/xlib/ClientForm.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/__init__.py b/scrapy/xlib/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/__init__.py
rename to scrapy/xlib/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/lrucache.py b/scrapy/xlib/lrucache.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/lrucache.py
rename to scrapy/xlib/lrucache.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/lsprofcalltree.py b/scrapy/xlib/lsprofcalltree.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/lsprofcalltree.py
rename to scrapy/xlib/lsprofcalltree.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/__init__.py b/scrapy/xlib/pydispatch/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/__init__.py
rename to scrapy/xlib/pydispatch/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/dispatcher.py b/scrapy/xlib/pydispatch/dispatcher.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/dispatcher.py
rename to scrapy/xlib/pydispatch/dispatcher.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/errors.py b/scrapy/xlib/pydispatch/errors.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/errors.py
rename to scrapy/xlib/pydispatch/errors.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/license.txt b/scrapy/xlib/pydispatch/license.txt
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/license.txt
rename to scrapy/xlib/pydispatch/license.txt
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/robust.py b/scrapy/xlib/pydispatch/robust.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/robust.py
rename to scrapy/xlib/pydispatch/robust.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/robustapply.py b/scrapy/xlib/pydispatch/robustapply.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/robustapply.py
rename to scrapy/xlib/pydispatch/robustapply.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/saferef.py b/scrapy/xlib/pydispatch/saferef.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/pydispatch/saferef.py
rename to scrapy/xlib/pydispatch/saferef.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/INSTALL.scrapy b/scrapy/xlib/spidermonkey/INSTALL.scrapy
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/INSTALL.scrapy
rename to scrapy/xlib/spidermonkey/INSTALL.scrapy
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/__init__.py b/scrapy/xlib/spidermonkey/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/__init__.py
rename to scrapy/xlib/spidermonkey/__init__.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/sm_settings.py b/scrapy/xlib/spidermonkey/sm_settings.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/sm_settings.py
rename to scrapy/xlib/spidermonkey/sm_settings.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/spidermonkey.py b/scrapy/xlib/spidermonkey/spidermonkey.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xlib/spidermonkey/spidermonkey.py
rename to scrapy/xlib/spidermonkey/spidermonkey.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xpath/__init__.py b/scrapy/xpath/__init__.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xpath/__init__.py
rename to scrapy/xpath/__init__.py
diff --git a/scrapy/trunk/scrapy/xpath/constructors.py b/scrapy/xpath/constructors.py
similarity index 100%
rename from scrapy/trunk/scrapy/xpath/constructors.py
rename to scrapy/xpath/constructors.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xpath/document.py b/scrapy/xpath/document.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xpath/document.py
rename to scrapy/xpath/document.py
diff --git a/scrapy/trunk/scrapy/xpath/extension.py b/scrapy/xpath/extension.py
similarity index 100%
rename from scrapy/trunk/scrapy/xpath/extension.py
rename to scrapy/xpath/extension.py
diff --git a/scrapy/trunk/scrapy/xpath/selector.py b/scrapy/xpath/selector.py
similarity index 100%
rename from scrapy/trunk/scrapy/xpath/selector.py
rename to scrapy/xpath/selector.py
diff --git a/scrapy/branches/cluster-refactor/scrapy/xpath/types.py b/scrapy/xpath/types.py
similarity index 100%
rename from scrapy/branches/cluster-refactor/scrapy/xpath/types.py
rename to scrapy/xpath/types.py
diff --git a/scrapy/branches/cluster-refactor/scripts/rpm-install.sh b/scripts/rpm-install.sh
similarity index 100%
rename from scrapy/branches/cluster-refactor/scripts/rpm-install.sh
rename to scripts/rpm-install.sh
diff --git a/scrapy/trunk/setup.cfg b/setup.cfg
similarity index 100%
rename from scrapy/trunk/setup.cfg
rename to setup.cfg
diff --git a/scrapy/trunk/setup.py b/setup.py
similarity index 100%
rename from scrapy/trunk/setup.py
rename to setup.py
diff --git a/sites/scrapy.org/Makefile b/sites/scrapy.org/Makefile
deleted file mode 100644
index f074e308e..000000000
--- a/sites/scrapy.org/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-export PYTHONPATH =: .
-
-SETTINGS = export DJANGO_SETTINGS_MODULE=scrapyorg.settings
-
-.PHONY : all build docs tests
-
-all : build tests
-
-build : docs
-
-tests :
- $(SETTINGS); \
- django-admin.py test
diff --git a/sites/scrapy.org/README b/sites/scrapy.org/README
deleted file mode 100644
index 36216e8e6..000000000
--- a/sites/scrapy.org/README
+++ /dev/null
@@ -1,7 +0,0 @@
-Dependencies:
-
- * python docutils (python-docutils in debian)
- Needed for ReST markup
-
- * Sphinx python package (easy_install Sphinx)
- Needed for documentation
diff --git a/sites/scrapy.org/docs/old/basics.rst b/sites/scrapy.org/docs/old/basics.rst
deleted file mode 100644
index ccaa3dec7..000000000
--- a/sites/scrapy.org/docs/old/basics.rst
+++ /dev/null
@@ -1,47 +0,0 @@
-======
-Basics
-======
-
-Scrapy is built up on `Twisted <http://twistedmatrix.com>`_ , a python platform for the developing of network applications in an asynchronous (non-blocking) approach. This means that, while running in a single thread, a Scrapy application does not block while waiting data arrival from the network. Instead, it continues to process any task that requires CPU attention. Then, when data arrives, a callback function is called with this data as parameter. This is why this kind of code is also called event-driven or callback-based. For more information about this issue see `Asynchronous Programming with Twisted <http://twistedmatrix.com/projects/core/documentation/howto/async.html>`_.
-
-When coding with Scrapy, the elemental scheme loop is:
-
-1. Feed the application with an initial set of urls.
-2. Create a [source:scrapy/trunk/scrapy/http/request.py Request] object for each given url.
-3. Attach callback functions to each Request, so you define what to do with data once arrives.
-4. Feed the [source:scrapy/trunk/scrapy/core/engine.py Execution Engine] with a list of Requests and data.
-
-Eventually, the callbacks can return data or more Request objects to the Execution Engine, so the crawling process will continue until no more request left.
-
-At this point, it may seem that Scrapy can't do anything that cannot be done easily with Twisted. But the magic of Scrapy resides on that it helps the developer to implement this basic scheme under a very simple and straightforward model and, most important, on all the fully integrated helpers that places at developer disposal in order to perform intensive network crawling and quickly deploy a fully functional application.
-
-These helpers includes
-
-* Parsers/interpreters for most common languages found in the web (xml/html/csv/javascript).
-* Network request and response pre and post process pluggable middleware to comply with specific network tasks, such as HTTP authentication, redirection, compression, network caching, network debug info logging, download retrying, cookie management, etc.
-* Scraping results post process pluggable middleware.
-* Pluggable extensions such as memory debugging, memory usage control and profiling, cpu profiling, controlling web/webservice and telnet consoles, distributed crawling cluster, scraping statistics and lot more.
-* Built-in event signaling.
-* Spiders quality test tools.
-* Lots of useful utilities for many kinds of data processing.
-
-In order to implement all these resources, Scrapy heavily exploits the concept of middleware. Middleware is plugin code organized in a pipeline model, that resides in the execution line between the spiders, the engine and the Web.
-
-So, if you don't want to start from the very begining a serious production crawling/scraping project, Scrapy is for you.
-
-Getting Scrapy and starting a new project
-=========================================
-
-Scrapy is under heavy development, so you will want to download it from his svn repository::
-
- svn co http://svn.scrapy.org/scrapy
-
-This command will create a folder with the name *scrapy* You can find **scrapy** module under *scrapy/trunk* so in order to import this module, assure you have its absolute path in your PYTHONPATH environment variable.
-
-In order to start a new project, Scrapy gives you a script tool that helps to generate a basic folder structure for the new project, an initial settings file, and a control script.
-
-Do::
-
- $ scrapy/trunk/scrapy/bin/scrapy-admin.py startproject myproject
-
-You will see that a new folder, *myproject*, in your actual path, was created. Let's continue in the scrapy tutorial.
diff --git a/sites/scrapy.org/docs/old/tutorial/index.rst b/sites/scrapy.org/docs/old/tutorial/index.rst
deleted file mode 100644
index 4b7714423..000000000
--- a/sites/scrapy.org/docs/old/tutorial/index.rst
+++ /dev/null
@@ -1,9 +0,0 @@
-========
-Tutorial
-========
-
-.. toctree::
-
- tutorial1
- tutorial2
- tutorial3
diff --git a/sites/scrapy.org/docs/old/tutorial/tutorial1.rst b/sites/scrapy.org/docs/old/tutorial/tutorial1.rst
deleted file mode 100644
index 93231fe60..000000000
--- a/sites/scrapy.org/docs/old/tutorial/tutorial1.rst
+++ /dev/null
@@ -1,74 +0,0 @@
-================
-Our first spider
-================
-
-Lets code our first spider. But before, lets check two important asociated settings in *conf/scrapy_settings.py* file::
-
- SPIDER_MODULES = ['myproject.spiders']
- ENABLED_SPIDERS_FILE = '%s/conf/enabled_spiders.list' % myproject.__path__[0]
-
-The first setting, SPIDER_MODULES, is a list that sets the modules that contains the spiders. The second one, ENABLED_SPIDERS_FILE, sets the location of a text file that contains the list of enabled spiders. When you created the project branch, the admin script set both for you. Hence, you will see that with these values, **Scrapy** will search spiders in the module *myproject.spiders* and will read the enabled spiders list from the path *path to myproject>/myproject/conf/enabled_spiders.list* where *<path to myproject>* is the path where the module *myproject* resides on. Of course, you can change this settings as taste. These are just defaults to help you.
-
-Now, finally, the code to our first spider::
-
- from scrapy.spider import BaseSpider
-
- class MySpider(BaseSpider):
-
- domain_name = "scrapy.org"
-
- start_urls = ["http://dev.scrapy.org/wiki/WikiStart", "http://dev.scrapy.org/wiki/Starting"]
-
- def parse(self, response):
- filename = response.url.split("/")[-1]
- open(filename, "w").write(response.body.to_unicode())
-
- return []
-
- CRAWLER = MySpider()
-
-The first line imports the class [source:scrapy/trunk/scrapy/spider/models.py BaseSpider]. For the purpose of creating a working spider, you must subclass !BaseSpider, and then define the three main, mandatory, attributes:
-
-* *domain_name* identifies the spider. It must be unique, that is, you can't set the same domain name for different spiders.
-* *start_urls* is a list of urls where the spider will begin to crawl from. So, the first pages downloaded will be those listed here. The subsequent urls will be generated successively from data contained in the start urls.
-* *parse* is the callback method of the spider. This means that each time a page is retrieved, the downloaded data will be passed to this method. In this simple example, the only action is to save the data. But anything can be done here: parse the data, organize it and store in a db or in the filesystem, process it, get new urls to continue the crawling process, etc.
-
-*parse()* method must always return a list. We will see why later.
-
-In the last line, we instantiate our spider class.
-
-So, save this code in a file named myfirst.py inside *myproject/spiders* folder, and create the file *conf/enabled_spiders.list* with the content::
-
- scrapy.org
-
-to enable our new spider.
-
-Now, go to myproject base folder and run::
-
- ./scrapy-ctl.py crawl
-
-The **crawl** subcommand runs all the enabled spiders. The output of this command will be something like::
-
- 2008/07/27 19:46 -0200 [-] Log opened.
- 2008/07/27 19:46 -0200 [scrapy-bot] INFO: Enabled extensions: TelnetConsole, WebConsole
- 2008/07/27 19:46 -0200 [scrapy-bot] INFO: Enabled downloader middlewares:
- 2008/07/27 19:46 -0200 [scrapy-bot] INFO: Enabled spider middlewares:
- 2008/07/27 19:46 -0200 [scrapy-bot] INFO: Enabled item pipelines:
- 2008/07/27 19:46 -0200 [scrapy-bot/scrapy.org] INFO: Domain opened
- 2008/07/27 19:46 -0200 [scrapy-bot/scrapy.org] DEBUG: Crawled live <http://dev.scrapy.org/wiki/WikiStart> from <None>
- 2008/07/27 19:46 -0200 [scrapy-bot/scrapy.org] DEBUG: Crawled live <http://dev.scrapy.org/wiki/Starting> from <None>
- 2008/07/27 19:46 -0200 [scrapy-bot/scrapy.org] INFO: Domain closed (finished)
- 2008/07/27 19:46 -0200 [-] Main loop terminated.
-
-Pay attention to the lines labeled [scrapy-bot/scrapy.org], which corresponds to our spider identified by the domain "scrapy.org". You can see a log line for each url defined in *start_urls*. Because these urls are the starting ones, they have no referrers, and this condition is indicated at the end of the log line, where it says *from <None>*.
-
-But more interesting, as our *parse* method instructs, two files have been created: WikiStart and Starting, with the content of both urls.
-
-If you remember the elemental loop scheme of Scrapy described before:
-
-1. Feed the application with an initial set of urls.
-2. Create a Request object for each given url.
-3. Attach callback functions to each Request, so you define what to do with data once arrives.
-4. Feed the Execution Engine with a list of Requests and data.
-
-You will see that the sample spider we made here (and all spiders) actually performes step 1 and 3. But behind the scenes, step 2 and 4 are also carried out. Most spiders will explicitly create Requests. And they don't need to call the engine by themselves. In fact, they will never do that.
diff --git a/sites/scrapy.org/docs/old/tutorial/tutorial2.rst b/sites/scrapy.org/docs/old/tutorial/tutorial2.rst
deleted file mode 100644
index 970d8ae74..000000000
--- a/sites/scrapy.org/docs/old/tutorial/tutorial2.rst
+++ /dev/null
@@ -1,173 +0,0 @@
-=========
-Selectors
-=========
-
-In the last section we have learned how to make an spider, that is, the piece of code that actually does something with data directly retrieved from the web. But we want more than just save this data in a file. We want to extract and classify meaningful data for us. So, first we have to *parse* the data contained in the page. We could use for example regular expressions. And indeed, Scrapy has support for them.
-
-But web pages has a particular language structure, a markup language, that can be easily accessed by more suitable means. One way, and the one adopted by Scrapy, is xpath. Lets suppose we have the following html code::
-
- <html>
- <head><title>Commodities</title></head>
- <body>
- <table>
-
- <tr>
- <td>Gold</td>
- <td class=price>939.12US$/oz</td>
- </tr>
- <tr>
- <td>Oil</td>
- <td class=price>123.44US$/bbl</td>
- </tr>
-
- </table>
- </body>
- </html>
-
-We can access to the title content by the xpath "/html/head/title", which, according to xpath specifications, it is evaluated as "<title>Commodities</title>". "/html/head/title/text()" is evaluated as "Commodities".
-
-If you want to access all the root td elements, the xpath expression is "//td", and the result is multivaluated: "<td>Gold</td>", "<td price=class>939.12US$/oz</td>", "<td>Oil</td>", "<td price=class>123.44US$/bbl</td>".
-
-If want to access all the first <td> tags inside its parent tag (in this case, <tr>), the xpath is "//td![1]", and the result is multivalued "<td>Gold</td>", "<td>Oil</td>".
-
-Also, you can access tags by attributes. For example, "//td[@class='price']" will match "<td class="price">939.12US$/oz</td>" and "<td class="price">123.44US$/bbl</td>".
-
-The value of the xpath "//body" will be the entire content of the body tag, and so on. For an xpath specifications tutorial see http://www.w3schools.com/xpath/default.asp. I strongly recommend to read that tutorial before continue here. Usually we will not being using such simple xpath expressions.
-
-In order to manage with xpaths, Scrapy defines a class, [source:scrapy/trunk/scrapy/xpath/selector.py XPathSelector]. To access the different elements of a html code, you instantiate the class XPathSelector with a response object. XPathSelector comes in two flavors: XmlXPathSelector and HtmlXPathSelector. At this point I will introduce you a very useful tool: the scrapy console, *shell* so i can ilustrate the use of selectors. I strongly recommend to install IPython package to experience scrapy shell in the most convenient way. Save the above html code in a file, i.e. *sample.html* and run::
-
- $ ./scrapy-ctl.py shell file://sample.html
- Scrapy 0.1.0 - Interactive scraping console
-
- Enabling Scrapy extensions... done
- Downloading URL... done
- ------------------------------------------------------------------------------
- Available local variables:
- xxs: <class 'scrapy.xpath.selector.XmlXPathSelector'>
- url: http://www.bloomberg.com/markets/commodities/cfutures.html
- spider: <class 'scrapy.spider.models.BaseSpider'>
- hxs: <class 'scrapy.xpath.selector.HtmlXPathSelector'>
- item: <class 'scrapy.item.models.ScrapedItem'>
- response: <class 'scrapy.http.response.Response'>
- Available commands:
- get <url>: Fetches an url and updates all variables.
- scrapehelp: Prints this help.
- ------------------------------------------------------------------------------
- Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
- Type "copyright", "credits" or "license" for more information.
-
- IPython 0.8.1 -- An enhanced Interactive Python.
- ? -> Introduction to IPython's features.
- %magic -> Information about IPython's 'magic' % functions.
- help -> Python's own help system.
- object? -> Details about 'object'. ?object also works, ?? prints more.
-
- In [1]:
-
-Ipython is an extended python console, and *shell* command adds some useful local variables and methods, sets python path and imports some scrapy libraries. One of the loaded variables is *response* and contains all the data associated with the result of the request action for the given url. If you enter *response.body.to_unicode()* the downloaded data will be printed on screen.
-
-*xxs* and *hxs* are selectors already instantiated with this response as initialization parameter. *xxs* is a selector with xml 'flavor', and hxs is a selector with html 'flavor'. In the present case, we will use *hxs* You can see selectors as objects that represents nodes in the document structure. So, these instantiated selectors are associated to the root node, or entire document.
-
-Selectors has three methods: *x* *re* and *extract*
-
- - *x* returns a list of selectors, each of them representing the nodes getted in the xpath expression given as parameter.
- - *re* returns a list of results of a regular expression given as parameter.
- - *extract* actually extracts the data contained in the node. Does not receive parameters.
-
-A list of selectors, a XPathSelectorList object, has the same methods, but they are evaluated on each XPathSelector of the list.
-
-Examples:::
-
- In [2]: hxs.x("/html")
- Out[1]: [<HtmlXPathSelector (html) xpath=/html>]
-
- In [2]: hxs.x("//td[@class='price']")
- Out[2]:
- [<HtmlXPathSelector (td) xpath=//td[@class='price']>,
- <HtmlXPathSelector (td) xpath=//td[@class='price']>]
-
- In [3]: _.extract()
- Out[3]:
- [u'<td class="price">939.12US$/oz</td>',
- u'<td class="price">123.44US$/bbl</td>']
-
- In [4]:hxs.re("\d+.\d+US\$")
- Out[4]: [u'939.12US$', u'123.44US$']
-
- In [5] hxs.x("//td[2]").re("\d+")
- Out[5]: [u'939', u'12', u'123', u'44']
-
-This is a trivial example. But pages retrieved from the web won't be so simple. Lets suppose we are interested in financial data, and want to extract gold, oil and soy prices from Bloomberg Commodities Page http://www.bloomberg.com/markets/commodities/cfutures.html
-
-Lets try:::
-
- $ ./scrapy-ctl.py shell http://www.bloomberg.com/markets/commodities/cfutures.html
-
-And inside the scrapy console:::
-
- In [1]: response.body.to_unicode()
- ...
-
-We will get a big text, and data is not easily targeted there. We need three prices, and can search by try and error, or by aproximation, but it is a tedious job. But someone has developed a very practical tool for doing this: [https://addons.mozilla.org/firefox/addon/1843 Firebug], an add-on for Mozilla Firefox. Install it, then open in your Firefox the Bloomberg url given above. Point the mouse over the Gold row, Price column, click right button and select Inspect Element. This new inspect option has been added by Firebug. A tab will open with the page source code, and highlighted, the code corresponding to the Gold Price:
-
-[[Image(firebug.png)]]
-
-(Observe that pointing the mouse over different elements in code tab, the matching rendered region in browser will be highlighted as well.)
-
-So, you could find the gold price by the xpath expression *span[@class='style5']"* If you type in scrapy console *hxs.x("//span[@class='style5']/text()").extract()* you will get a large list of nodes, because multiple instances of this xpath pattern were found, so you could select that corresponding to gold by the expression *hxs.x("//span[@class='style5']/text()").extract()![73]*
-
-Always there are several ways to target the same element. We could find the same gold price, for example, with the expression *hxs.x("//span[contains(text(),'GOLD')]/../following-sibling::td![1]/span/text()").extract()* And this is an interesting approach, because we could do:::
-
- In [2]: def get_commodity_price(text):
- ....: return hxs.x("//span[contains(text(),'%s')]/../following-sibling::td[1]/span/text()" % text).extract()[0]
- ....:
-
-and then,::
-
- In [3]: get_commodity_price('GOLD')
- Out[3]: u'916.500'
-
- In [4]: get_commodity_price('WTI CRUDE')
- Out[4]: u'121.590'
-
- In [5]: get_commodity_price('SOYBEAN FUTURE')
- Out[5]: u'1390.750'
-
-And so on.
-
-So, we can add the following spider to our project:::
-
- from scrapy.spider import BaseSpider
- from scrapy.xpath import HtmlXPathSelector
-
- class MySpider(BaseSpider):
-
- domain_name = "bloomberg.com"
-
- start_urls = ["http://www.bloomberg.com/markets/commodities/cfutures.html"]
-
- def parse(self, response):
-
- hxs = HtmlXPathSelector(response)
- def get_commodity_price(text):
- return hxs.x("//span[contains(text(),'%s')]/../following-sibling::td[1]/span/text()" % text).extract()[0]
-
- print "Gold Futures NY: %sUS$/oz" % get_commodity_price("GOLD")
- print "Oil WTI Futures: %sUS$/bbl" % get_commodity_price("WTI CRUDE")
- print "Soybean: %sUS$/bu" % get_commodity_price("SOYBEAN FUTURE")
-
- return []
-
- CRAWLER = MySpider()
-
-Save it as *spiders/bloomberg.py* for example, and enable it adding "bloomberg.com" to *conf/enabled_spiders.list* Actually the name given to the module that contains the spider does not matter. Scrapy will find the correct spider looking for its *domain_name* attribute.
-
-Do a crawl (*scrapy-ctl.py crawl* and both spiders will be ran. We will get printed in part of the log output something like this:::
-
- 2008/07/30 12:40 -0200 [HTTPPageGetter,client] Gold Futures NY: 905.400US$/oz
- 2008/07/30 12:40 -0200 [HTTPPageGetter,client] Oil WTI Futures: 121.210US$/bbl
- 2008/07/30 12:40 -0200 [HTTPPageGetter,client] Soybean: 1390.750US$/bu
-
-If you want to crawl only one domain among all availables, you just add the domain name to the command line arguments:::
-
- ./scrapy-ctl.py crawl bloomberg.com
diff --git a/sites/scrapy.org/docs/old/tutorial/tutorial3.rst b/sites/scrapy.org/docs/old/tutorial/tutorial3.rst
deleted file mode 100644
index 4ad73d18c..000000000
--- a/sites/scrapy.org/docs/old/tutorial/tutorial3.rst
+++ /dev/null
@@ -1,173 +0,0 @@
-==================
-Items and Adaptors
-==================
-
-At this point we have seen how to scrape data from a web page. But the only thing we did was to print it in the screen. Frequently we need to organize, process, or store the data we have retrieved. In order to perform these jobs, Scrapy model includes a data encapsulation class: [source:scrapy/trunk/scrapy/item/models.py ScrapedItem].
-
-A [source:scrapy/trunk/scrapy/item/models.py ScrapedItem] contains attributes with given values, just like any python object. And you use the method *attribute* in order to assign to the item an attribute with a given value and name. Of course, you could do something like::
-
- index.name = "Gold Future"
- index.value = get_commodity_price("GOLD")
-
-being *index* an instance of a given object class. But *attribute* method is intended to do more than just assign. Very often data from the web contains entities, tags, or comes inside a piece of text, and are always strings. But you may want to remove or not entities and tags depending on attribute name, or extract significative data from a bigger text (i.e. dimensions or prices inside a text), convert data to float, integers, and validate data assigned, or normalize some data features. You could do all this inside the spider code. But in this manner you will repeat lot of code, and even generate data inconsistencies from spider to spider simply because you forget to apply correct data processing according to policies you have pre-established (imagine when working with lots and lots of different spiders and source webpages)
-
-When you use the *attribute* method, the data passes through an adaptation pipeline before finally be assigned. The purpose of this adaptation pipeline is preciselly to apply all the data processing in a user-defined, simple and scalable way, and without having to implement it inside the spiders code each time you add a new one.
-
-Lets continue our bloomberg commodities example. Modify our bloomberg.py file as follows:::
-
- from scrapy.spider import BaseSpider
- from scrapy.xpath import HtmlXPathSelector
-
- from scrapy.item import ScrapedItem as FinancyIndex
-
- class BloombergSpider(BaseSpider):
-
- domain_name = "bloomberg.com"
-
- start_urls = ["http://www.bloomberg.com/markets/commodities/cfutures.html",
- "http://www.bloomberg.com/markets/stocks/movers_index_spx.html"]
-
- def parse(self, response):
-
- hxs = HtmlXPathSelector(response)
-
- def get_commodity_price(text):
- value = hxs.x("//span[contains(text(),'%s')]/../following-sibling::td[1]/span/text()" % text).extract()[0]
- unit = hxs.x("//span[contains(text(),'%s')]/following-sibling::span" % text).re("\((.*)\)")[0]
- return value, unit
-
- def get_index_value():
- return hxs.x("//span[contains(text(),'VALUE')]/../following-sibling::td/text()").extract()[0]
-
- items = []
- if "cfutures" in response.url:
- for i in [("GOLD", "Gold Futures NY"), ("WTI CRUDE", "Oil WTI Futures"), ("SOYBEAN FUTURE", "Soybean")]:
- index = FinancyIndex()
- index.attribute("name", i[1])
- value, unit = get_commodity_price(i[0])
- index.attribute("value", value)
- index.attribute("unit", unit)
- items.append(index)
- elif "index_spx" in response.url:
- index = FinancyIndex()
- index.attribute("name", "S&P500")
- index.attribute("value", get_index_value())
- index.attribute("unit", "%")
- items.append(index)
- return items
-
- CRAWLER = BloombergSpider()
-
-Note two important differences with our previous version:
-
-* We have added a second url in our *start_urls* list. This means our spider will visit two webpages. In order to handle this, we have splitted our code in two parts, according to the response url, one that handles commodities page , and other which handles Standard&Poor's index page. We can add any ammount of urls we want to visit in the *start_urls* list. But this is an inefficient approach if we want to scrape lots of pages from a site (it is common to visit hundreds or even thousands of them). Further we will learn crawling techniques with Scrapy in order to generate and follow links in a site, beginning from few starting urls.
-* Instead of printing scraped data in the console, we assign it to [source:scrapy/trunk/scrapy/item/models.py ScrapedItem] objects. Each item contains three attributes: name, value and unit (also, we have added code to scrape units). Then, *parse* method returns a list of the scraped items. Remember we said in previous section that *parse* must always return a list.
-
-If we run the scrapy shell with our commodity url as parameter and run *spider.parse(response)* we will get a list of three items:::
-
- In [1]: spider.parse(response)
- Out[1]:
- [<scrapy.item.models.ScrapedItem object at 0x8ae602c>,
- <scrapy.item.models.ScrapedItem object at 0x8ae616c>,
- <scrapy.item.models.ScrapedItem object at 0x8ae606c>]
-
-So parse is doing what we expect: it returns three items, one for each index. If we want to see a more detailed output, *scrapy-ctl* proportionates another useful tool: the *parse* subcommand. Try:::
-
- $ ./scrapy-ctl.py parse http://www.bloomberg.com/markets/commodities/cfutures.html
- 2008/09/02 17:40 -0200 [-] Log opened.
- 2008/09/02 17:40 -0200 [scrapy-bot] INFO: Enabled extensions: TelnetConsole, WebConsole
- 2008/09/02 17:40 -0200 [scrapy-bot] INFO: Enabled downloader middlewares:
- 2008/09/02 17:40 -0200 [scrapy-bot] INFO: Enabled spider middlewares:
- 2008/09/02 17:40 -0200 [scrapy-bot] INFO: Enabled item pipelines:
- 2008/09/02 17:40 -0200 [scrapy-bot/bloomberg.com] INFO: Domain opened
- 2008/09/02 17:40 -0200 [scrapy-bot/bloomberg.com] DEBUG: Crawled live <http://www.bloomberg.com/markets/commodities/cfutures.html> from <None>
- 2008/09/02 17:40 -0200 [scrapy-bot/bloomberg.com] INFO: Domain closed (finished)
- 2008/09/02 17:40 -0200 [-] Main loop terminated.
- # Scraped Items ------------------------------------------------------------
- ScrapedItem({'name': 'Gold Futures NY', 'unit': u'USD/t oz.', 'value': u'812.700'})
- ScrapedItem({'name': 'Oil WTI Futures', 'unit': u'USD/bbl.', 'value': u'110.430'})
- ScrapedItem({'name': 'Soybean', 'unit': u'USd/bu.', 'value': u'1298.500'})
-
- # Links --------------------------------------------------------------------
-
- $
-
-We get a nice printing of our items, displaying all their attributes. Observe that attribute values are raw data, extracted as is from the page. All are strings, and we could be interested in operate with decimal values; units expressions are not homogeneous (see dollar symbols are USD and USd), and we did not give unicode strings as items name. So, lets construct an adaptor pipeline and create our own item class for this purpose:::
-
- from decimal import Decimal
- import re
-
- from scrapy.item.models import ScrapedItem
- from scrapy.item.adaptors import AdaptorPipe
-
- def extract(value):
- if hasattr(value, 'extract'):
- value = value.extract()
- if isinstance(value, list):
- value = value[0]
- return value
-
- def to_decimal(value):
- return Decimal(value)
-
- def to_unicode(value):
- return unicode(value)
-
- _dollars_re = re.compile("[Uu][Ss][Dd]")
- def normalize_units(value):
- return _dollars_re.sub("U$S", value)
-
- def clean(value):
- return value.strip()
-
- def clean_number(value):
- if value.find(".") > value.find(","):
- value = value.replace(",", "")
- elif value.find(",") > value.find("."):
- value = value.replace(".", "")
- value = value.replace(",", ".")
- return value
-
- pipedict = {
- 'name': [extract, to_unicode, clean],
- 'unit': [extract, to_unicode, clean, normalize_units],
- 'value': [extract, to_unicode, clean, clean_number, to_decimal]
- }
-
- class FinancyIndex(ScrapedItem):
-
- adaptors_pipe = AdaptorPipe(pipedict)
-
-
-Save this as *item.py* and in the bloomberg spider code, replace the line::
-
- from scrapy.item import ScrapedItem as FinancyIndex
-
-by::
-
- from financy.item import FinancyIndex
-
-Also, you can remove the *extract()* and *0]* in our helper functions *get_commodity_price* and *get_index_value*::
-
- def get_commodity_price(text):
- value = hxs.x("//span[contains(text(),'%s')]/../following-sibling::td[1]/span/text()" % text)
- unit = hxs.x("//span[contains(text(),'%s')]/following-sibling::span" % text).re("\((.*)\)")
- return value, unit
-
- def get_index_value():
- return hxs.x("//span[contains(text(),'VALUE')]/../following-sibling::td/text()")v
-
-The extract adaptor will do that for us.
-
-Run *parse* command again:::
-
- # Scraped Items ------------------------------------------------------------
- FinancyIndex({'name': u'Gold Futures NY', 'unit': u'U$S/t oz.', 'value': Decimal("809.600")})
- FinancyIndex({'name': u'Oil WTI Futures', 'unit': u'U$S/bbl.', 'value': Decimal("110.240")})
- FinancyIndex({'name': u'Soybean', 'unit': u'U$S/bu.', 'value': Decimal("1298.500")})
-
-Very nice, uh? And this adaptor pipeline will be applied for all spiders you add to your project --which is the purpose of the adaptor pipeline--, provided you use the item *attribute* method to assign them.
-
-Adaptors run in the specified order. And you must take care that each adaptor receives from the previous one, what expects to receive. In order to enable an adaptors pipeline, you have to instantiate an [source:scrapy/trunk/scrapy/item/adaptors.py AdaptorPipe] class in your item class (in this example, *financy.item.FinancyIndex*) with a dictionary which maps *attribute name* to a pipeline of adaptation functions, and assign it to the class attribute *adaptors_pipe*.
-
-You can at anytime edit the pipeline by accessing to *pipe* attribute of the !AdaptorPipe instance. For example, you may want to remove or add an adaptor from a spider code for a certain group of attributes. But you must take on account that, because the pipeline is a class attribute, any change will has effect on all.
diff --git a/sites/scrapy.org/scrapyorg/__init__.py b/sites/scrapy.org/scrapyorg/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/article/__init__.py b/sites/scrapy.org/scrapyorg/article/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/article/urls.py b/sites/scrapy.org/scrapyorg/article/urls.py
deleted file mode 100644
index 8c54379ae..000000000
--- a/sites/scrapy.org/scrapyorg/article/urls.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from django.conf.urls.defaults import *
-
-from scrapyorg.article.views import *
-
-
-urlpatterns = patterns('',
- (r"^$", render_template, { "path": "home" }),
- (r"(?P<path>.*)/", render_template),
-)
diff --git a/sites/scrapy.org/scrapyorg/article/views.py b/sites/scrapy.org/scrapyorg/article/views.py
deleted file mode 100644
index 3a8a301f1..000000000
--- a/sites/scrapy.org/scrapyorg/article/views.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from os.path import join
-
-from django.template import TemplateDoesNotExist
-from django.template.context import RequestContext
-from django.shortcuts import render_to_response
-from django.http import Http404
-
-
-ARTICLES_TEMPLATES_DIR = "articles"
-
-
-def render_template(request, path):
- if not path.endswith(".html"):
- path = path + ".html"
- path = join(ARTICLES_TEMPLATES_DIR, path)
-
- try:
- c = RequestContext(request)
- return render_to_response(path, context_instance=c)
- except TemplateDoesNotExist, e:
- raise Http404("Article does not exists")
diff --git a/sites/scrapy.org/scrapyorg/blog/__init__.py b/sites/scrapy.org/scrapyorg/blog/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/blog/admin.py b/sites/scrapy.org/scrapyorg/blog/admin.py
deleted file mode 100644
index 0b1568c9d..000000000
--- a/sites/scrapy.org/scrapyorg/blog/admin.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from django.contrib import admin
-from scrapyorg.blog.models import *
-
-
-class CategoryAdmin(admin.ModelAdmin):
- prepopulated_fields = {'slug': ('title',)}
-
-admin.site.register(Category, CategoryAdmin)
-
-
-class PostAdmin(admin.ModelAdmin):
- list_display = ('title', 'publish', 'status')
- list_filter = ('publish', 'categories', 'status')
- search_fields = ('title', 'body')
- prepopulated_fields = {'slug': ('title',)}
-
-admin.site.register(Post, PostAdmin)
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/feeds.py b/sites/scrapy.org/scrapyorg/blog/feeds.py
deleted file mode 100644
index 2cd11cb28..000000000
--- a/sites/scrapy.org/scrapyorg/blog/feeds.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from django.contrib.syndication.feeds import FeedDoesNotExist
-from django.core.exceptions import ObjectDoesNotExist
-from django.contrib.sites.models import Site
-from django.contrib.syndication.feeds import Feed
-from django.core.urlresolvers import reverse
-from scrapyorg.blog.models import Post, Category
-
-
-class BlogPostsFeed(Feed):
- _site = Site.objects.get_current()
- title = '%s feed' % _site.name
- description = '%s posts feed.' % _site.name
-
- def link(self):
- return reverse('blog_index')
-
- def items(self):
- return Post.objects.published()[:10]
-
- def item_pubdate(self, obj):
- return obj.publish
-
-
-class BlogPostsByCategory(Feed):
- _site = Site.objects.get_current()
- title = '%s posts category feed' % _site.name
-
- def get_object(self, bits):
- if len(bits) != 1:
- raise ObjectDoesNotExist
- return Category.objects.get(slug__exact=bits[0])
-
- def link(self, obj):
- if not obj:
- raise FeedDoesNotExist
- return obj.get_absolute_url()
-
- def description(self, obj):
- return "Posts recently categorized as %s" % obj.title
-
- def items(self, obj):
- return obj.post_set.published()[:10]
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/managers.py b/sites/scrapy.org/scrapyorg/blog/managers.py
deleted file mode 100644
index d5bcdb005..000000000
--- a/sites/scrapy.org/scrapyorg/blog/managers.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from django.db.models import Manager
-import datetime
-
-
-class PublicManager(Manager):
- """Returns published posts that are not in the future."""
-
- def published(self):
- return self.get_query_set().filter(status__gte=2, publish__lte=datetime.datetime.now())
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/models.py b/sites/scrapy.org/scrapyorg/blog/models.py
deleted file mode 100644
index 176f5d63c..000000000
--- a/sites/scrapy.org/scrapyorg/blog/models.py
+++ /dev/null
@@ -1,80 +0,0 @@
-from django.db import models
-from django.utils.translation import ugettext_lazy as _
-from django.db.models import permalink
-from django.contrib.auth.models import User
-#from tagging.fields import TagField
-from scrapyorg.blog.managers import PublicManager
-
-#import tagging
-
-
-class Category(models.Model):
- """Category model."""
- title = models.CharField(_('title'), max_length=100)
- slug = models.SlugField(_('slug'), unique=True)
-
- class Meta:
- verbose_name = _('category')
- verbose_name_plural = _('categories')
- db_table = 'blog_categories'
- ordering = ('title',)
-
- class Admin:
- pass
-
- def __unicode__(self):
- return u'%s' % self.title
-
- @permalink
- def get_absolute_url(self):
- return ('blog_category_detail', None, {'slug': self.slug})
-
-
-class Post(models.Model):
- """Post model."""
- STATUS_CHOICES = (
- (1, _('Draft')),
- (2, _('Public')),
- )
- title = models.CharField(_('title'), max_length=200)
- slug = models.SlugField(_('slug'), unique_for_date='publish')
- author = models.ForeignKey(User, blank=True, null=True)
- body = models.TextField(_('body'))
- tease = models.TextField(_('tease'), blank=True)
- status = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=2)
- publish = models.DateTimeField(_('publish'))
- created = models.DateTimeField(_('created'), auto_now_add=True)
- modified = models.DateTimeField(_('modified'), auto_now=True)
- categories = models.ManyToManyField(Category, blank=True)
-# tags = TagField()
- objects = PublicManager()
-
- class Meta:
- verbose_name = _('post')
- verbose_name_plural = _('posts')
- db_table = 'blog_posts'
- ordering = ('-publish',)
- get_latest_by = 'publish'
-
- class Admin:
- list_display = ('title', 'publish', 'status')
- list_filter = ('publish', 'categories', 'status')
- search_fields = ('title', 'body')
-
- def __unicode__(self):
- return u'%s' % self.title
-
- @permalink
- def get_absolute_url(self):
- return ('blog_detail', None, {
- 'year': self.publish.year,
- 'month': self.publish.strftime('%b').lower(),
- 'day': self.publish.day,
- 'slug': self.slug
- })
-
- def get_previous_post(self):
- return self.get_previous_by_publish(status__gte=2)
-
- def get_next_post(self):
- return self.get_next_by_publish(status__gte=2)
diff --git a/sites/scrapy.org/scrapyorg/blog/sitemap.py b/sites/scrapy.org/scrapyorg/blog/sitemap.py
deleted file mode 100644
index 7b1ed9d25..000000000
--- a/sites/scrapy.org/scrapyorg/blog/sitemap.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from django.contrib.sitemaps import Sitemap
-from scrapyorg.blog.models import Post
-
-
-class BlogSitemap(Sitemap):
- changefreq = "never"
- priority = 0.5
-
- def items(self):
- return Post.objects.published()
-
- def lastmod(self, obj):
- return obj.publish
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/base.html b/sites/scrapy.org/scrapyorg/blog/templates/base.html
deleted file mode 100644
index 880d8a996..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/base.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
-
-<html lang="en">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>{% block title %}{% endblock %}</title>
-</head>
-<body id="{% block body_id %}{% endblock %}">
- <div id="body">
- {% block body %}
- <div>
- {% block content_title %}{% endblock %}
- </div>
- <div class="content">
- {% block content %}{% endblock %}
- </div>
- {% endblock %}
- </div>
-</body>
-</html>
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/base_blog.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/base_blog.html
deleted file mode 100644
index 48a039f7d..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/base_blog.html
+++ /dev/null
@@ -1,5 +0,0 @@
-{% extends "base.html" %}
-oaihdasasihjsd
-
-
-{% block body_class %}blog{% endblock %}
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/category_detail.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/category_detail.html
deleted file mode 100644
index 23a257976..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/category_detail.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Posts for {{ category.title }}{% endblock %}
-{% block body_class %}{{ block.super }} category_detail{% endblock %}
-{% block body_id %}category_{{ category.id }}{% endblock %}
-
-
-{% block content_title %}
- <h2>Posts for {{ category.title }}</h2>
-{% endblock %}
-
-
-{% block content %}
- {% load markup %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/category_list.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/category_list.html
deleted file mode 100644
index 6ec01e46b..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/category_list.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post categories{% endblock %}
-{% block body_class %}{{ block.super }} category_list{% endblock %}
-
-
-{% block content_title %}
- <h2>Post categories</h2>
-{% endblock %}
-
-
-{% block content %}
- {% load markup %}
- <ul class="link_list">
- {% for category in object_list %}
- <li><a href="{{ category.get_absolute_url }}">{{ category }}</a></li>
- {% endfor %}
- </ul>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_day.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_day.html
deleted file mode 100644
index b9d9ab97f..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_day.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive for {{ day|date:"d F Y" }}{% endblock %}
-{% block body_class %}{{ block.super }} post_archive_day{% endblock %}
-
-
-{% block content_title %}
- <h2>Post archive for {{ day|date:"d F Y" }}</h2>
-{% endblock %}
-
-
-{% block content %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_month.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_month.html
deleted file mode 100644
index 947a1cc7d..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_month.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive for {{ month|date:"F Y" }}{% endblock %}
-{% block body_class %}{{ block.super }} post_archive_month{% endblock %}
-
-
-{% block content_title %}
- <h2>Post archive for {{ month|date:"F Y" }}</h2>
-{% endblock %}
-
-
-{% block content %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_year.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_year.html
deleted file mode 100644
index f0255220b..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_archive_year.html
+++ /dev/null
@@ -1,21 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive for {{ year }}{% endblock %}
-{% block body_class %}{{ block.super }} post_archive_year{% endblock %}
-
-
-{% block content_title %}
- <h2>Post archive for {{ year }}</h2>
-{% endblock %}
-
-
-{% block content %}
- {% load markup %}
-
- <ul class="link_list">
- {% for month in date_list %}
- <li><a href="{% url blog_index %}{{ year }}/{{ month|date:"b" }}/">{{ month|date:"F" }}</a></li>
- {% endfor %}
- </ul>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_detail.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/post_detail.html
deleted file mode 100644
index a4247dcc4..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_detail.html
+++ /dev/null
@@ -1,67 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}{{ object.title }}{% endblock %}
-{% block body_class %}{{ block.super }} post_detail{% endblock %}
-{% block body_id %}post_{{ object.id }}{% endblock %}
-
-
-{% block content_title %}
- <h2>{{ object.title }}</h2>
- <p class="other_posts">
- {% if object.get_previous_by_publish %}
- <a class="previous" href="{{ object.get_previous_post.get_absolute_url }}">&laquo; {{ object.get_previous_post }}</a>
- {% endif %}
- {% if object.get_next_by_publish %}
- | <a class="next" href="{{ object.get_next_post.get_absolute_url }}">{{ object.get_next_post }} &raquo;</a>
- {% endif %}
- </p>
-{% endblock %}
-
-
-{% block content %}
- {% load blog markup comments tagging_tags %}
-
- <p class="date">{{ object.publish|date:"j F Y" }}</p>
-
- <div class="body">
- {{ object.body|markdown:"safe" }}
- </div>
-
- {% tags_for_object object as tag_list %}
- {% if tag_list %}
- <p class="inline_tag_list"><strong>Related tags:</strong>
- {% for tag in tag_list %}
- {{ tag }}{% if not forloop.last %}, {% endif %}
- {% endfor %}
- </p>
- {% endif %}
-
- {% get_comment_list for object as comment_list %}
- {% if comment_list %}
- <div id="comments">
- <a name="comments"></a>
- <h3 class="comments_title">Comments</h3>
- {% for comment in comment_list %}
- {% if comment.is_public %}
- <div class="comment">
- <h5 class="name">
- <a name="c{{ comment.id }}" href="{{ comment.get_absolute_url }}" title="Permalink to {{ comment.person_name }}'s comment" class="count">{{ forloop.counter }}</a>
- {% if comment.user_url %}<a href="{{ comment.user_url }}">{{ comment.user_name }}</a>{% else %}{{ comment.user_name }}{% endif %} says...
- </h5>
- {{ comment.comment|urlizetrunc:"60"|markdown:"safe" }}
- <p class="date">Posted at {{ comment.submit_date|date:"P" }} on {{ comment.submit_date|date:"F j, Y" }}</p>
- </div>
- {% endif %}
- {% endfor %}
- </div>
- {% endif %}
- {% if object.allow_comments %}
- {% render_comment_form for object %}
- {% else %}
- <div id="comment_form">
- <h3>Comments are closed.</h3>
- <p>Comments have been close for this post.</p>
- </div>
- {% endif %}
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_list.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/post_list.html
deleted file mode 100644
index 399b1f0e6..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_list.html
+++ /dev/null
@@ -1,35 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive{% endblock %}
-{% block body_class %}{{ block.super }} post_list{% endblock %}
-
-
-{% block content_title %}
- <h2>Post archive</h2>
-{% endblock %}
-
-
-{% block content %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-
- {% if is_paginated %}
- <p class="pagination">
- {% if has_next %}
- <a class="older" href="?page={{ next }}">Older</a>
- {% endif %}
- {% if has_next and has_previous %} | {% endif %}
- {% if has_previous %}
- <a class="newer" href="?page={{ previous }}">Newer</a>
- {% endif %}
- </p>
- {% endif %}
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_search.html b/sites/scrapy.org/scrapyorg/blog/templates/blog/post_search.html
deleted file mode 100644
index 2884333f8..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/blog/post_search.html
+++ /dev/null
@@ -1,37 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post search{% endblock %}
-{% block body_class %}{{ block.super }} post_search{% endblock %}
-
-
-{% block content_title %}
- <h2>Search</h2>
-{% endblock %}
-
-
-{% block content %}
- <form action="." method="get" id="post_search_form">
- <p>
- <input type="text" name="q" value="{{ search_term }}" id="search">
- <input type="submit" class="button" value="Search">
- </p>
- </form>
-
- {% if message %}
- <p class="message">{{ message }}</p>
- {% endif %}
-
- {% if object_list %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- <p class="comments">{% if comment_count %}{{ comment_count }} comment{{ comment_count|pluralize }}{% endif %}</p>
- </div>
- {% endfor %}
- </div>
- {% endif %}
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/feeds/posts_description.html b/sites/scrapy.org/scrapyorg/blog/templates/feeds/posts_description.html
deleted file mode 100644
index 99216e812..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/feeds/posts_description.html
+++ /dev/null
@@ -1 +0,0 @@
-{{ obj.tease }}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates/feeds/posts_title.html b/sites/scrapy.org/scrapyorg/blog/templates/feeds/posts_title.html
deleted file mode 100644
index 7899fce3e..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates/feeds/posts_title.html
+++ /dev/null
@@ -1 +0,0 @@
-{{ obj.title }}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates_backup/admin/blog/post/change_form.html b/sites/scrapy.org/scrapyorg/blog/templates_backup/admin/blog/post/change_form.html
deleted file mode 100644
index 08c034b77..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates_backup/admin/blog/post/change_form.html
+++ /dev/null
@@ -1,56 +0,0 @@
-{% extends "admin/change_form.html" %}
-
-{% block extrahead %}
- {% load adminmedia inlines %}
- {{ block.super }}
- <script type="text/javascript">
- function InlineInit() {
- var body_div = document.getElementById('id_body').parentNode;
- var content = ''
- content += '{% get_inline_types as inline_list %}'
- content += '<label>Body inlines:</label>'
-
- content += '<strong>Inline type:</strong> '
- content += '<select id="id_inline_content_type" onchange="document.getElementById(\'lookup_id_inline\').href = \'../../../\'+this.value+\'/\';" style="margin-right:20px;">'
- content += ' <option>----------</option>'
- content += ' {% for inline in inline_list %}'
- content += ' <option value="{{ inline.content_type.app_label }}/{{ inline.content_type.model }}">{{ inline.content_type.app_label|capfirst }}: {{ inline.content_type.model|capfirst }}</option>'
- content += ' {% endfor %}'
- content += '</select> '
-
- content += '<strong>Object:</strong> '
- content += '<input type="text" class="vIntegerField" id="id_inline" size="10" /> '
- content += '<a id="lookup_id_inline" href="#" class="related-lookup" onclick="if(document.getElementById(\'id_inline_content_type\').value != \'----------\') { return showRelatedObjectLookupPopup(this); }" style="margin-right:20px;"><img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Loopup" /></a> '
-
- content += '<strong>Class:</strong> '
- content += '<select id="id_inline_class">'
- content += ' <option value="small_left">Small left</option>'
- content += ' <option value="small_right">Small right</option>'
- content += ' <option value="medium_left">Medium left</option>'
- content += ' <option value="medium_right">Medium right</option>'
- content += ' <option value="large_left">Large left</option>'
- content += ' <option value="large_right">Large right</option>'
- content += ' <option value="full">Full</option>'
- content += '</select>'
-
- content += '<input type="button" value="Add" style="margin-left:10px;" onclick="return insertInline(document.getElementById(\'id_inline_content_type\').value, document.getElementById(\'id_inline\').value, document.getElementById(\'id_inline_class\').value)" />'
- content += '<p class="help">Insert inlines into your body by choosing an inline type, then an object, then a class.</p>'
-
- var div = document.createElement('div');
- div.setAttribute('style', 'margin-top:10px;');
- div.innerHTML = content;
-
- body_div.insertBefore(div);
- }
-
- function insertInline(type, id, classname) {
- if (type != '----------' && id != '') {
- inline = '<inline type="'+type.replace('/', '.')+'" id="'+id+'" class="'+classname+'" />';
- body = document.getElementById('id_body');
- body.value = body.value + inline + '\n';
- }
- }
-
- addEvent(window, 'load', InlineInit);
- </script>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templates_backup/inlines/default.html b/sites/scrapy.org/scrapyorg/blog/templates_backup/inlines/default.html
deleted file mode 100644
index 5510ba952..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templates_backup/inlines/default.html
+++ /dev/null
@@ -1,7 +0,0 @@
-{% if object %}
- {{ object }}
-{% else %}
- {% for object in object_list %}
- {{ object }}
- {% endfor %}
-{% endif %}
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/templatetags/__init__.py b/sites/scrapy.org/scrapyorg/blog/templatetags/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/blog/templatetags/blog.py b/sites/scrapy.org/scrapyorg/blog/templatetags/blog.py
deleted file mode 100644
index e80918cb3..000000000
--- a/sites/scrapy.org/scrapyorg/blog/templatetags/blog.py
+++ /dev/null
@@ -1,103 +0,0 @@
-from django import template
-from django.conf import settings
-from django.db import models
-
-import re
-
-Post = models.get_model('blog', 'post')
-Category = models.get_model('blog', 'category')
-
-register = template.Library()
-
-
-class LatestPosts(template.Node):
- def __init__(self, limit, var_name):
- self.limit = limit
- self.var_name = var_name
-
- def render(self, context):
- posts = Post.objects.published()[:int(self.limit)]
- if posts and (int(self.limit) == 1):
- context[self.var_name] = posts[0]
- else:
- context[self.var_name] = posts
- return ''
-
-def get_latest_posts(parser, token):
- """
- Gets any number of latest posts and stores them in a varable.
-
- Syntax::
-
- {% get_latest_posts [limit] as [var_name] %}
-
- Example usage::
-
- {% get_latest_posts 10 as latest_post_list %}
- """
- try:
- tag_name, arg = token.contents.split(None, 1)
- except ValueError:
- raise template.TemplateSyntaxError, "%s tag requires arguments" % token.contents.split()[0]
- m = re.search(r'(.*?) as (\w+)', arg)
- if not m:
- raise template.TemplateSyntaxError, "%s tag had invalid arguments" % tag_name
- format_string, var_name = m.groups()
- return LatestPosts(format_string, var_name)
-
-
-class BlogCategories(template.Node):
- def __init__(self, var_name):
- self.var_name = var_name
-
- def render(self, context):
- categories = Category.objects.all()
- context[self.var_name] = categories
- return ''
-
-def get_blog_categories(parser, token):
- """
- Gets all blog categories.
-
- Syntax::
-
- {% get_blog_categories as [var_name] %}
-
- Example usage::
-
- {% get_blog_categories as category_list %}
- """
- try:
- tag_name, arg = token.contents.split(None, 1)
- except ValueError:
- raise template.TemplateSyntaxError, "%s tag requires arguments" % token.contents.split()[0]
- m = re.search(r'as (\w+)', arg)
- if not m:
- raise template.TemplateSyntaxError, "%s tag had invalid arguments" % tag_name
- var_name = m.groups()[0]
- return BlogCategories(var_name)
-
-
-def get_links(value):
- """
- Extracts links from a ``Post`` body and returns a list.
-
- Template Syntax::
-
- {{ post.body|markdown:"safe"|get_links }}
-
- """
- try:
- try:
- from BeautifulSoup import BeautifulSoup
- except ImportError:
- from beautifulsoup import BeautifulSoup
- soup = BeautifulSoup(value)
- return soup.findAll('a')
- except ImportError:
- if settings.DEBUG:
- raise template.TemplateSyntaxError, "Error in 'get_links' filter: BeautifulSoup isn't installed."
- return value
diff --git a/sites/scrapy.org/scrapyorg/blog/tests.py b/sites/scrapy.org/scrapyorg/blog/tests.py
deleted file mode 100644
index 1dd87451d..000000000
--- a/sites/scrapy.org/scrapyorg/blog/tests.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""
->>> from django.test import Client
->>> from scrapyorg.blog.models import Post, Category
->>> import datetime
->>> from django.core.urlresolvers import reverse
->>> client = Client()
-
->>> category = Category(title='Django', slug='django')
->>> category.save()
->>> category2 = Category(title='Rails', slug='rails')
->>> category2.save()
-
->>> post = Post(title='DJ Ango', slug='dj-ango', body='Yo DJ! Turn that music up!', status=2, publish=datetime.datetime(2008,5,5,16,20))
->>> post.save()
-
->>> post2 = Post(title='Where my grails at?', slug='where', body='I Can haz Holy plez?', status=2, publish=datetime.datetime(2008,4,2,11,11))
->>> post2.save()
-
->>> post.categories.add(category)
->>> post2.categories.add(category2)
-
->>> response = client.get(reverse('blog_index'))
->>> response.context[-1]['object_list']
-[<Post: DJ Ango>, <Post: Where my grails at?>]
->>> response.status_code
-200
-
->>> response = client.get(reverse('blog_category_list'))
->>> response.context[-1]['object_list']
-[<Category: Django>, <Category: Rails>]
->>> response.status_code
-200
-
->>> response = client.get(category.get_absolute_url())
->>> response.context[-1]['object_list']
-[<Post: DJ Ango>]
->>> response.status_code
-200
-
->>> response = client.get(post.get_absolute_url())
->>> response.context[-1]['object']
-<Post: DJ Ango>
->>> response.status_code
-200
-
->>> response = client.get(reverse('blog_search'), {'q': 'DJ'})
->>> response.context[-1]['object_list']
-[<Post: DJ Ango>]
->>> response.status_code
-200
->>> response = client.get(reverse('blog_search'), {'q': 'Holy'})
->>> response.context[-1]['object_list']
-[<Post: Where my grails at?>]
->>> response.status_code
-200
->>> response = client.get(reverse('blog_search'), {'q': ''})
->>> response.context[-1]['message']
-'Search term was too vague. Please try again.'
-
->>> response = client.get(reverse('blog_detail', args=[2008, 'apr', 2, 'where']))
->>> response.context[-1]['object']
-<Post: Where my grails at?>
->>> response.status_code
-200
-"""
-
diff --git a/sites/scrapy.org/scrapyorg/blog/urls.py b/sites/scrapy.org/scrapyorg/blog/urls.py
deleted file mode 100644
index 53aa0f404..000000000
--- a/sites/scrapy.org/scrapyorg/blog/urls.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from django.conf.urls.defaults import *
-from scrapyorg.blog import views as blog_views
-
-
-urlpatterns = patterns('',
- url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$',
- view=blog_views.post_detail,
- name='blog_detail'),
-
- url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/$',
- view=blog_views.post_archive_day,
- name='blog_archive_day'),
-
- url(r'^(?P<year>\d{4})/(?P<month>\w{3})/$',
- view=blog_views.post_archive_month,
- name='blog_archive_month'),
-
- url(r'^(?P<year>\d{4})/$',
- view=blog_views.post_archive_year,
- name='blog_archive_year'),
-
- url(r'^categories/(?P<slug>[-\w]+)/$',
- view=blog_views.category_detail,
- name='blog_category_detail'),
-
- url (r'^categories/$',
- view=blog_views.category_list,
- name='blog_category_list'),
-
- url (r'^search/$',
- view=blog_views.search,
- name='blog_search'),
-
- url(r'^page/(?P<page>\w)/$',
- view=blog_views.post_list,
- name='blog_index_paginated'),
-
- url(r'^$',
- view=blog_views.post_list,
- name='blog_index'),
-)
\ No newline at end of file
diff --git a/sites/scrapy.org/scrapyorg/blog/views.py b/sites/scrapy.org/scrapyorg/blog/views.py
deleted file mode 100644
index ad65484b5..000000000
--- a/sites/scrapy.org/scrapyorg/blog/views.py
+++ /dev/null
@@ -1,160 +0,0 @@
-from django.shortcuts import render_to_response, get_object_or_404
-from django.template import RequestContext
-from django.http import Http404
-from django.views.generic import date_based, list_detail
-from django.db.models import Q
-from scrapyorg.blog.models import *
-
-import datetime
-import re
-
-
-def post_list(request, page=0, **kwargs):
- return list_detail.object_list(
- request,
- queryset = Post.objects.published(),
- paginate_by = 20,
- page = page,
- **kwargs
- )
-post_list.__doc__ = list_detail.object_list.__doc__
-
-
-def post_archive_year(request, year, **kwargs):
- return date_based.archive_year(
- request,
- year = year,
- date_field = 'publish',
- queryset = Post.objects.published(),
- make_object_list = True,
- **kwargs
- )
-post_archive_year.__doc__ = date_based.archive_year.__doc__
-
-
-def post_archive_month(request, year, month, **kwargs):
- return date_based.archive_month(
- request,
- year = year,
- month = month,
- date_field = 'publish',
- queryset = Post.objects.published(),
- **kwargs
- )
-post_archive_month.__doc__ = date_based.archive_month.__doc__
-
-
-def post_archive_day(request, year, month, day, **kwargs):
- return date_based.archive_day(
- request,
- year = year,
- month = month,
- day = day,
- date_field = 'publish',
- queryset = Post.objects.published(),
- **kwargs
- )
-post_archive_day.__doc__ = date_based.archive_day.__doc__
-
-
-def post_detail(request, slug, year, month, day, **kwargs):
- return date_based.object_detail(
- request,
- year = year,
- month = month,
- day = day,
- date_field = 'publish',
- slug = slug,
- queryset = Post.objects.published(),
- **kwargs
- )
-post_detail.__doc__ = date_based.object_detail.__doc__
-
-
-def category_list(request, template_name = 'blog/category_list.html', **kwargs):
- """
- Category list
-
- Template: ``blog/category_list.html``
- Context:
- object_list
- List of categories.
- """
- return list_detail.object_list(
- request,
- queryset = Category.objects.all(),
- template_name = template_name,
- **kwargs
- )
-
-def category_detail(request, slug, template_name = 'blog/category_detail.html', **kwargs):
- """
- Category detail
-
- Template: ``blog/category_detail.html``
- Context:
- object_list
- List of posts specific to the given category.
- category
- Given category.
- """
- category = get_object_or_404(Category, slug__iexact=slug)
-
- return list_detail.object_list(
- request,
- queryset = category.post_set.published(),
- extra_context = {'category': category},
- template_name = template_name,
- **kwargs
- )
-
-
-# Stop Words courtesy of http://www.dcs.gla.ac.uk/idom/ir_resources/linguistic_utils/stop_words
-STOP_WORDS = r"""\b(a|about|above|across|after|afterwards|again|against|all|almost|alone|along|already|also|
-although|always|am|among|amongst|amoungst|amount|an|and|another|any|anyhow|anyone|anything|anyway|anywhere|are|
-around|as|at|back|be|became|because|become|becomes|becoming|been|before|beforehand|behind|being|below|beside|
-besides|between|beyond|bill|both|bottom|but|by|call|can|cannot|cant|co|computer|con|could|couldnt|cry|de|describe|
-detail|do|done|down|due|during|each|eg|eight|either|eleven|else|elsewhere|empty|enough|etc|even|ever|every|everyone|
-everything|everywhere|except|few|fifteen|fify|fill|find|fire|first|five|for|former|formerly|forty|found|four|from|
-front|full|further|get|give|go|had|has|hasnt|have|he|hence|her|here|hereafter|hereby|herein|hereupon|hers|herself|
-him|himself|his|how|however|hundred|i|ie|if|in|inc|indeed|interest|into|is|it|its|itself|keep|last|latter|latterly|
-least|less|ltd|made|many|may|me|meanwhile|might|mill|mine|more|moreover|most|mostly|move|much|must|my|myself|name|
-namely|neither|never|nevertheless|next|nine|no|nobody|none|noone|nor|not|nothing|now|nowhere|of|off|often|on|once|
-one|only|onto|or|other|others|otherwise|our|ours|ourselves|out|over|own|part|per|perhaps|please|put|rather|re|same|
-see|seem|seemed|seeming|seems|serious|several|she|should|show|side|since|sincere|six|sixty|so|some|somehow|someone|
-something|sometime|sometimes|somewhere|still|such|system|take|ten|than|that|the|their|them|themselves|then|thence|
-there|thereafter|thereby|therefore|therein|thereupon|these|they|thick|thin|third|this|those|though|three|through|
-throughout|thru|thus|to|together|too|top|toward|towards|twelve|twenty|two|un|under|until|up|upon|us|very|via|was|
-we|well|were|what|whatever|when|whence|whenever|where|whereafter|whereas|whereby|wherein|whereupon|wherever|whether|
-which|while|whither|who|whoever|whole|whom|whose|why|will|with|within|without|would|yet|you|your|yours|yourself|
-yourselves)\b"""
-
-
-def search(request, template_name='blog/post_search.html'):
- """
- Search for blog posts.
-
- This template will allow you to setup a simple search form that will try to return results based on
- given search strings. The queries will be put through a stop words filter to remove words like
- 'the', 'a', or 'have' to help imporve the result set.
-
- Template: ``blog/post_search.html``
- Context:
- object_list
- List of blog posts that match given search term(s).
- search_term
- Given search term.
- """
- context = {}
- if request.GET:
- stop_word_list = re.compile(STOP_WORDS, re.IGNORECASE)
- search_term = '%s' % request.GET['q']
- cleaned_search_term = stop_word_list.sub('', search_term)
- cleaned_search_term = cleaned_search_term.strip()
- if len(cleaned_search_term) != 0:
- post_list = Post.objects.published().filter(Q(body__icontains=cleaned_search_term) | Q(tags__icontains=cleaned_search_term) | Q(categories__title__icontains=cleaned_search_term))
- context = {'object_list': post_list, 'search_term':search_term}
- else:
- message = 'Search term was too vague. Please try again.'
- context = {'message':message}
- return render_to_response(template_name, context, context_instance=RequestContext(request))
diff --git a/sites/scrapy.org/scrapyorg/docs/__init__.py b/sites/scrapy.org/scrapyorg/docs/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/docs/models.py b/sites/scrapy.org/scrapyorg/docs/models.py
deleted file mode 100644
index 71a836239..000000000
--- a/sites/scrapy.org/scrapyorg/docs/models.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.
diff --git a/sites/scrapy.org/scrapyorg/docs/urls.py b/sites/scrapy.org/scrapyorg/docs/urls.py
deleted file mode 100644
index 164287362..000000000
--- a/sites/scrapy.org/scrapyorg/docs/urls.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from django.conf import settings
-from django.conf.urls.defaults import *
-
-from scrapyorg.docs.views import document
-from scrapyorg.docs.views import images
-
-
-urlpatterns = patterns('',
- url(r'^$', document, {'url': ''}),
- url(r'^(?P<url>[\w./-]*)/$', document),
- url(r'^_images/(?P<path>.*)$', images),
-)
-
-if settings.DEBUG: # devel
- urlpatterns += patterns('',
- (r'^%s/(?P<path>.*)$' % settings.MEDIA_URL[1:],
- 'django.views.static.serve',
- {'document_root': settings.MEDIA_ROOT}),
- )
-
diff --git a/sites/scrapy.org/scrapyorg/docs/views.py b/sites/scrapy.org/scrapyorg/docs/views.py
deleted file mode 100644
index 56bb92814..000000000
--- a/sites/scrapy.org/scrapyorg/docs/views.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import cPickle as pickle
-import os
-
-import django.views.static
-from django.conf import settings
-from django.http import Http404
-from django.shortcuts import render_to_response
-from django.template import RequestContext
-
-
-def document(request, url):
- docroot = settings.DOC_PICKLE_ROOT
-
- if os.path.exists(os.path.join(docroot, url, 'index.fpickle')):
- docpath = os.path.join(docroot, url, 'index.fpickle')
- elif os.path.exists(os.path.join(docroot, url + '.fpickle')):
- docpath = os.path.join(docroot, url + '.fpickle')
- else:
- raise Http404("'%s' does not exist" % url)
-
- docfile = open(docpath, 'rb')
- doc = pickle.load(docfile)
-
- return render_to_response('docs/doc.html', {'doc': doc},
- context_instance=RequestContext(request))
-
-
-def images(request, path):
- return django.views.static.serve(
- request,
- document_root = os.path.join(settings.DOC_PICKLE_ROOT, '_images'),
- path = path,
- )
diff --git a/sites/scrapy.org/scrapyorg/download/__init__.py b/sites/scrapy.org/scrapyorg/download/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/download/admin.py b/sites/scrapy.org/scrapyorg/download/admin.py
deleted file mode 100644
index 4c5880561..000000000
--- a/sites/scrapy.org/scrapyorg/download/admin.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from django.contrib import admin
-
-from scrapyorg.download.models import DownloadLink
-
-
-class DownloadLinkAdmin(admin.ModelAdmin):
- list_display = ("text", "address", "public_link", "created")
- list_filter = ("public", "created")
- search_fields = ("address", "text")
-
-admin.site.register(DownloadLink, DownloadLinkAdmin)
diff --git a/sites/scrapy.org/scrapyorg/download/models.py b/sites/scrapy.org/scrapyorg/download/models.py
deleted file mode 100644
index 95e62d7a4..000000000
--- a/sites/scrapy.org/scrapyorg/download/models.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from datetime import datetime
-
-from django.db import models
-from django.utils.translation import ugettext_lazy as _
-
-
-class DownloadLink(models.Model):
- description = models.CharField(_("description"), max_length=512,
- blank=True, default='')
- address = models.CharField(_("address"), max_length=1024, blank=False)
- text = models.CharField(_("link text"), max_length=512, blank=False,
- default=_("download"))
- public = models.BooleanField(_("public"), blank=False, default=True)
-
- # automatic dates
- created = models.DateTimeField(_("created"), editable=False)
- updated = models.DateTimeField(_("updated"), editable=False)
-
- def toggle_public(self):
- self.public = not self.public
- self.save()
-
- def save(self):
- if not self.id:
- self.created = datetime.now()
- self.updated = datetime.now()
- super(DownloadLink, self).save()
-
- def __unicode__(self):
- return self.address
-
- # ugly, but django-admin isn't very versatile right now
- def public_link(self):
- img_url = "/media/img/admin/icon-%s.gif" % \
- (self.public and "yes" or "no")
- html = _('<img alt="%s" src="' + img_url + '"/> ' \
- '(<a href="%s/toggle/">Toggle</a>)')
- return html % (_(str(self.public)), self.id)
-
- public_link.short_description = u"public"
- public_link.allow_tags = True
-
-# class Admin:
-# list_display = ("text", "address", "public_link", "created")
-# list_filter = ("public", "created")
-# save_on_top = True
-
- class Meta:
- verbose_name = _("download link")
- verbose_name_plural = _("download links")
- ordering = ["-created",]
diff --git a/sites/scrapy.org/scrapyorg/download/templatetags/__init__.py b/sites/scrapy.org/scrapyorg/download/templatetags/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/download/templatetags/download_tags.py b/sites/scrapy.org/scrapyorg/download/templatetags/download_tags.py
deleted file mode 100644
index 14cd5a657..000000000
--- a/sites/scrapy.org/scrapyorg/download/templatetags/download_tags.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from django import template
-
-from scrapyorg.lib.templatetags import *
-
-from scrapyorg.download.models import DownloadLink
-
-
-register = template.Library()
-
-
[email protected](name="load_download_links")
-def do_load_links(parser, token):
- syntax_msg = 'Syntax: %s "COUNT" as "VAR_NAME"'
-
- try:
- splited = token.split_contents()
- if len(splited) == 4:
- tag, count, _as, var_name = splited
- elif len(splited) == 3:
- tag, _as, var_name = splited
- count = None
-
- if count and not is_string(count) or not is_string(var_name):
- raise_syntax(syntax_msg % tag)
- count = count and int(unquoute(count)) or count
- except:
- raise_syntax(syntax_msg % token.split_contents()[0])
- return LoadLinksNode(count, unquoute(var_name))
-
-
-class LoadLinksNode(template.Node):
- def __init__(self, count, var_name):
- self.count = count
- self.var_name = var_name
-
- def render(self, context):
- links = DownloadLink.objects.filter(public=True)[:self.count]
- context[self.var_name] = links
- return ''
diff --git a/sites/scrapy.org/scrapyorg/download/urls.py b/sites/scrapy.org/scrapyorg/download/urls.py
deleted file mode 100644
index 59deb47f4..000000000
--- a/sites/scrapy.org/scrapyorg/download/urls.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from django.conf.urls.defaults import *
-
-from scrapyorg.download.views import *
-
-
-urlpatterns = patterns('',
- (r"^(?P<link_id>\d+)/toggle/$", toggle_public),
-)
diff --git a/sites/scrapy.org/scrapyorg/download/views.py b/sites/scrapy.org/scrapyorg/download/views.py
deleted file mode 100644
index bc4b56215..000000000
--- a/sites/scrapy.org/scrapyorg/download/views.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from django.shortcuts import get_object_or_404
-from django.http import HttpResponseRedirect
-from django.contrib.admin.views.decorators import staff_member_required
-
-from scrapyorg.download.models import DownloadLink
-
-
-@staff_member_required
-def toggle_public(request, link_id):
- link = get_object_or_404(DownloadLink, pk=link_id)
- link.toggle_public()
- return HttpResponseRedirect("/admin/download/downloadlink/")
diff --git a/sites/scrapy.org/scrapyorg/lib/__init__.py b/sites/scrapy.org/scrapyorg/lib/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sites/scrapy.org/scrapyorg/lib/templatetags.py b/sites/scrapy.org/scrapyorg/lib/templatetags.py
deleted file mode 100644
index c664b913f..000000000
--- a/sites/scrapy.org/scrapyorg/lib/templatetags.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from django import template
-
-
-is_string = lambda val: val[0] in ("'", '"') and val[0] == val[-1]
-unquoute = lambda val: val[1:-1]
-
-def raise_syntax(msg):
- raise template.TemplateSyntaxError, msg
diff --git a/sites/scrapy.org/scrapyorg/local_settings.py.template b/sites/scrapy.org/scrapyorg/local_settings.py.template
deleted file mode 100644
index 5d2d85d7f..000000000
--- a/sites/scrapy.org/scrapyorg/local_settings.py.template
+++ /dev/null
@@ -1,12 +0,0 @@
-DEBUG = True
-
-DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = '' # Or path to database file if using sqlite3.
-DATABASE_USER = '' # Not used with sqlite3.
-DATABASE_PASSWORD = '' # Not used with sqlite3.
-DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
-DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
-
-EMAIL_HOST = ''
-EMAIL_HOST_USER = ''
-EMAIL_HOST_PASSWORD = ''
diff --git a/sites/scrapy.org/scrapyorg/manage.py b/sites/scrapy.org/scrapyorg/manage.py
deleted file mode 100755
index 5e78ea979..000000000
--- a/sites/scrapy.org/scrapyorg/manage.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-from django.core.management import execute_manager
-try:
- import settings # Assumed to be in the same directory.
-except ImportError:
- import sys
- sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
- sys.exit(1)
-
-if __name__ == "__main__":
- execute_manager(settings)
diff --git a/sites/scrapy.org/scrapyorg/settings.py b/sites/scrapy.org/scrapyorg/settings.py
deleted file mode 100644
index f38c24d05..000000000
--- a/sites/scrapy.org/scrapyorg/settings.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- coding: utf-8 -*-
-# Django settings for scrapy project.
-
-#from os.path import abspath, dirname, basename, join
-import os
-
-PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
-ADMINS = (
- # ('Your Name', '[email protected]'),
-)
-
-MANAGERS = ADMINS
-
-DEBUG=False
-
-DEFAULT_CHARSET = "utf-8"
-
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be avilable on all operating systems.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = 'America/Montevideo'
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-us'
-
-SITE_ID = 1
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-# USE_I18N = True
-
-# Absolute path to the directory that holds media.
-# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = os.path.join(PROJECT_ROOT, "static")
-
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash if there is a path component (optional in other cases).
-# Examples: "http://media.lawrence.com", "http://example.com/media/"
-MEDIA_URL = '/site-media'
-
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/media/'
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = 'fq04ss$#1h=m=39sh4vvph+76i5u716z1-x5$$9xn7sb6y4-di'
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.load_template_source',
- 'django.template.loaders.app_directories.load_template_source',
-# 'django.template.loaders.eggs.load_template_source',
-)
-
-MIDDLEWARE_CLASSES = (
- 'django.middleware.common.CommonMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.middleware.doc.XViewMiddleware',
-)
-
-ROOT_URLCONF = 'scrapyorg.urls'
-
-TEMPLATE_DIRS = (
- os.path.join(PROJECT_ROOT, "templates"),
-)
-
-INSTALLED_APPS = (
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.sites',
- 'django.contrib.admin',
- 'django.contrib.markup',
- 'scrapyorg.article',
- 'scrapyorg.download',
- 'scrapyorg.docs',
- 'scrapyorg.blog',
-)
-
-DOC_PICKLE_ROOT = os.path.join(PROJECT_ROOT, 'docs', 'pickle')
-
-# Override previous settings with values in local_settings.py settings file.
-try:
- from local_settings import *
-except ImportError:
- debug_msg ="Can't find local_settings.py, using default settings."
- try:
- from mod_python import apache
- apache.log_error("%s" % debug_msg, apache.APLOG_NOTICE)
- except ImportError:
- import sys
- sys.stderr.write("%s\n" % debug_msg)
diff --git a/sites/scrapy.org/scrapyorg/urls.py b/sites/scrapy.org/scrapyorg/urls.py
deleted file mode 100644
index 8bfe30671..000000000
--- a/sites/scrapy.org/scrapyorg/urls.py
+++ /dev/null
@@ -1,37 +0,0 @@
-from django.conf import settings
-from django.conf.urls.defaults import *
-from django.contrib import admin
-
-
-admin.autodiscover()
-
-
-urlpatterns = patterns('',
- # admin
- url(r"^admin/download/downloadlink/", include("scrapyorg.download.urls")),
- url(r'^admin/(.*)', admin.site.root),
-
- # pablo: disabled documentation until we improve its usability. for now,
- # documentation will be served at http://doc.scrapy.org using static html
- # files generated by Sphinx, and a small notice landing page will be shown
- # in scrapy.org/doc
- # docs
-# url(r"^docs/", include("scrapyorg.docs.urls")),
- url(r"docs/.*", 'django.views.generic.simple.redirect_to', {'url': '/doc/'}),
- # news
- url(r"^news/", include("scrapyorg.blog.urls")),
-)
-
-
-if settings.DEBUG: # devel
- urlpatterns += patterns('',
- (r'^%s/(?P<path>.*)$' % settings.MEDIA_URL[1:],
- 'django.views.static.serve',
- {'document_root': settings.MEDIA_ROOT}),
- )
-
-# last resort, it's an article
-urlpatterns += patterns('',
- url(r"", include("scrapyorg.article.urls")),
-)
-
diff --git a/sites/scrapy.org/static/images/box-borders-bottom.gif b/sites/scrapy.org/static/images/box-borders-bottom.gif
deleted file mode 100644
index 721647129..000000000
Binary files a/sites/scrapy.org/static/images/box-borders-bottom.gif and /dev/null differ
diff --git a/sites/scrapy.org/static/images/box-borders-bottom.png b/sites/scrapy.org/static/images/box-borders-bottom.png
deleted file mode 100644
index 4cb0dea01..000000000
Binary files a/sites/scrapy.org/static/images/box-borders-bottom.png and /dev/null differ
diff --git a/sites/scrapy.org/static/images/box-borders-top.png b/sites/scrapy.org/static/images/box-borders-top.png
deleted file mode 100644
index 117001d83..000000000
Binary files a/sites/scrapy.org/static/images/box-borders-top.png and /dev/null differ
diff --git a/sites/scrapy.org/static/images/footer-bg.jpg b/sites/scrapy.org/static/images/footer-bg.jpg
deleted file mode 100644
index 70682af36..000000000
Binary files a/sites/scrapy.org/static/images/footer-bg.jpg and /dev/null differ
diff --git a/sites/scrapy.org/static/images/icon-arrow.gif b/sites/scrapy.org/static/images/icon-arrow.gif
deleted file mode 100644
index 6326f0287..000000000
Binary files a/sites/scrapy.org/static/images/icon-arrow.gif and /dev/null differ
diff --git a/sites/scrapy.org/static/images/icon-author.gif b/sites/scrapy.org/static/images/icon-author.gif
deleted file mode 100644
index d72d4847f..000000000
Binary files a/sites/scrapy.org/static/images/icon-author.gif and /dev/null differ
diff --git a/sites/scrapy.org/static/images/logo.jpg b/sites/scrapy.org/static/images/logo.jpg
deleted file mode 100644
index c244578fa..000000000
Binary files a/sites/scrapy.org/static/images/logo.jpg and /dev/null differ
diff --git a/sites/scrapy.org/static/images/main-bg.jpg b/sites/scrapy.org/static/images/main-bg.jpg
deleted file mode 100644
index 523edba79..000000000
Binary files a/sites/scrapy.org/static/images/main-bg.jpg and /dev/null differ
diff --git a/sites/scrapy.org/static/style/pygments.css b/sites/scrapy.org/static/style/pygments.css
deleted file mode 100644
index 1f2d2b618..000000000
--- a/sites/scrapy.org/static/style/pygments.css
+++ /dev/null
@@ -1,61 +0,0 @@
-.hll { background-color: #ffffcc }
-.c { color: #408090; font-style: italic } /* Comment */
-.err { border: 1px solid #FF0000 } /* Error */
-.k { color: #007020; font-weight: bold } /* Keyword */
-.o { color: #666666 } /* Operator */
-.cm { color: #408090; font-style: italic } /* Comment.Multiline */
-.cp { color: #007020 } /* Comment.Preproc */
-.c1 { color: #408090; font-style: italic } /* Comment.Single */
-.cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
-.gd { color: #A00000 } /* Generic.Deleted */
-.ge { font-style: italic } /* Generic.Emph */
-.gr { color: #FF0000 } /* Generic.Error */
-.gh { color: #000080; font-weight: bold } /* Generic.Heading */
-.gi { color: #00A000 } /* Generic.Inserted */
-.go { color: #303030 } /* Generic.Output */
-.gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
-.gs { font-weight: bold } /* Generic.Strong */
-.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-.gt { color: #0040D0 } /* Generic.Traceback */
-.kc { color: #007020; font-weight: bold } /* Keyword.Constant */
-.kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
-.kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
-.kp { color: #007020 } /* Keyword.Pseudo */
-.kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
-.kt { color: #902000 } /* Keyword.Type */
-.m { color: #208050 } /* Literal.Number */
-.s { color: #4070a0 } /* Literal.String */
-.na { color: #4070a0 } /* Name.Attribute */
-.nb { color: #007020 } /* Name.Builtin */
-.nc { color: #0e84b5; font-weight: bold } /* Name.Class */
-.no { color: #60add5 } /* Name.Constant */
-.nd { color: #555555; font-weight: bold } /* Name.Decorator */
-.ni { color: #d55537; font-weight: bold } /* Name.Entity */
-.ne { color: #007020 } /* Name.Exception */
-.nf { color: #06287e } /* Name.Function */
-.nl { color: #002070; font-weight: bold } /* Name.Label */
-.nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
-.nt { color: #062873; font-weight: bold } /* Name.Tag */
-.nv { color: #bb60d5 } /* Name.Variable */
-.ow { color: #007020; font-weight: bold } /* Operator.Word */
-.w { color: #bbbbbb } /* Text.Whitespace */
-.mf { color: #208050 } /* Literal.Number.Float */
-.mh { color: #208050 } /* Literal.Number.Hex */
-.mi { color: #208050 } /* Literal.Number.Integer */
-.mo { color: #208050 } /* Literal.Number.Oct */
-.sb { color: #4070a0 } /* Literal.String.Backtick */
-.sc { color: #4070a0 } /* Literal.String.Char */
-.sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
-.s2 { color: #4070a0 } /* Literal.String.Double */
-.se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
-.sh { color: #4070a0 } /* Literal.String.Heredoc */
-.si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
-.sx { color: #c65d09 } /* Literal.String.Other */
-.sr { color: #235388 } /* Literal.String.Regex */
-.s1 { color: #4070a0 } /* Literal.String.Single */
-.ss { color: #517918 } /* Literal.String.Symbol */
-.bp { color: #007020 } /* Name.Builtin.Pseudo */
-.vc { color: #bb60d5 } /* Name.Variable.Class */
-.vg { color: #bb60d5 } /* Name.Variable.Global */
-.vi { color: #bb60d5 } /* Name.Variable.Instance */
-.il { color: #208050 } /* Literal.Number.Integer.Long */
\ No newline at end of file
diff --git a/sites/scrapy.org/static/style/style.css b/sites/scrapy.org/static/style/style.css
deleted file mode 100644
index e09ea3f6c..000000000
--- a/sites/scrapy.org/static/style/style.css
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Scrapy.org style sheet *******************************/
-
-/* main elements */
-html, body {
- margin:0;
- padding:0;
- height: 100%;
-}
-
-body {
- background: url('../images/main-bg.jpg') repeat-x left top;
- font-family: "Lucida Sans", Verdana, Helvetica, sans-serif;
- font-size:small;
- color:#333;
- background-color:#FFF;
-}
-
-a { color:#6e0909; text-decoration:none; border-bottom:1px solid #d78888;}
-
-a:hover { color:#f99800; border-bottom:1px solid #f7b7b7; }
-
-a img {
- border: none;
-}
-
-h1, h2 { color:#331f0a; font-weight:normal;}
-
-h1 {
- font-size: 200%;
- margin: 0 0 .6em 0;
-}
-
-h2 {
- font-size: 150%;
- margin: .6em 0;
-}
-
-dt { margin-left: 12px; font-style: italic; }
-dd { margin-left: 30px; }
-
-blockquote { padding:0px 15px; color:#5b1111; font-size:125%; margin:0;}
-
-p { line-height:1.5em; }
-
-.clear {
- clear:both;
- height: 0;
-}
-
-#wrapper {
- position: relative;
- min-height: 100%;
-}
-
-#header {
- padding-top: 42px;
- margin: 0 20px;
-}
-
-#body {
- padding-bottom: 35px;
-}
-
-#content-wrapper {
- width: 100%;
- float: left;
- margin-right: -300px;
-}
-
-#content {
- margin: 0 320px 0 20px;
-}
-
-#sidebar {
- width: 300px;
- float: right;
-}
-
-#footer {
- position: absolute;
- bottom: 0;
- width: 100%;
- height: 35px;
- border-top: 1px solid #b5331a;
- background: url('../images/footer-bg.jpg') repeat-x left top #5b2a16;
-}
-
-#header h1 {
- float: left;
- margin: 0;
-}
-
-#header h1 a {
- border: none;
-}
-
-#navigation {
- float: right;
- margin: 0;
- padding: 0;
- list-style-type: none;
-}
-
-#navigation li { float:left; padding:0 10px; font-size:120%; border-right:1px solid #e57919; }
-#navigation li.last { border-right:none; }
-#navigation li a { text-decoration:none; border-bottom:1px solid #ffca9b; color:#e57919;}
-#navigation li a:hover { color:#c35012; border-bottom:1px solid #ef994c}
-
-.breadcrumb a {
- border-bottom: none;
-}
-
-#footer a:hover {
- color: #ffe114;
-}
-
-#footer p {
- margin: 10px 20px;
- line-height: 15px;
- font-size: .85em;
- color: #fff;
-}
-
-#footer p a {
- color: #fff;
-}
-
-#badge {
- float: right;
-}
-
-#badge a {
- border-bottom: none;
-}
-
-.box { margin-bottom:15px; background:url('../images/box-borders-bottom.gif') no-repeat left bottom #4d271c; padding-bottom:5px; }
-.box.download {background-color:#5b1111; }
-.box.download p { color:#d18c59; }
-.box.download a.download { color:#d18c59; background:url('../images/icon-arrow.gif') no-repeat 2px 2px; padding-left:15px; border-bottom:1px solid #a0595d }
-.box.download a:hover.download { color:#FFF;}
-
-.box h3 { padding:10px 10px 0; font-weight:normal; font-size:160%; margin:0.3em 0pt; color:#ffebd2; background:url('../images/box-borders-top.png') no-repeat left top ;}
-.box p { padding:0 10px; font-size:90%; line-height:1.2em}
-
-.box .post { color:#FFF; margin:0pt 13px 5px;
-padding:0pt 0px 5px; border-bottom:4px solid #462217;}
-.box .post.last { border-bottom:none; }
-.box .post p.abstract { padding:0; margin:0; font-size:0.8em; height:1%; line-height:1.3em}
-.box .post p.author { color:#ffbc97; padding:0 0 0 15px; margin:5px 0px; font-size:0.8em; background:url('../images/icon-author.gif') no-repeat 2px 3px;}
-.box .post p.author a { color:#FFF; border-bottom:none }
-.box .post h4 { display:inline;font-size:1em; font-weight:bold; }
-.box .post h4 a {color:#ffe114; border-bottom:1px solid #957020; font-size:0.9em}
-.box .post a.more { font-size:0.8em; color:#ffe114; border-bottom:none;}
-.box .post a:hover.more { color:#FFF;}
diff --git a/sites/scrapy.org/templates/admin/base_site.html b/sites/scrapy.org/templates/admin/base_site.html
deleted file mode 100644
index 3b859a327..000000000
--- a/sites/scrapy.org/templates/admin/base_site.html
+++ /dev/null
@@ -1,37 +0,0 @@
-{% extends "admin/base.html" %}
-{% load i18n %}
-
-{% block title %}{{ title|escape }} | {% trans 'Django site admin' %}{% endblock %}
-
-{% block branding %}
-<h1 id="site-name">{% trans 'Django administration' %}</h1>
-{% endblock %}
-
-{% block nav-global %}{% endblock %}
-
-{% block footer %}
-<script type="text/javascript">
-/* <![CDATA[ */
-function textarea_resize() {
- textareas = document.getElementsByTagName("textarea");
- for (var i = 0; i <= textareas.length-1; i++) {
- try {
- textarea = textareas[i].rows = 30;
- } catch (e) {
- alert("textarea_resize() error:" + e);
- }
- }
-}
-textarea_resize();
-/* ]]> */
-</script>
-
-<style type="text/css">
-textarea {
- font-family: monospace;
-}
-.colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField {
- width:80%;
-}
-</style>
-{% endblock %}
diff --git a/sites/scrapy.org/templates/articles/community.html b/sites/scrapy.org/templates/articles/community.html
deleted file mode 100644
index d0a1f0f09..000000000
--- a/sites/scrapy.org/templates/articles/community.html
+++ /dev/null
@@ -1,28 +0,0 @@
-{% extends "base_home.html" %}
-
-{% block main-content %}
- <h2>Mailing lists</h2>
- <p>
- <a href="http://groups.google.com/group/scrapy-users">scrapy-users</a>: The main list for help and announcements
- </p>
-
- <form action="http://groups.google.com/group/scrapy-users/boxsubscribe">
- <p>Subscribe: <input type="text" size="15" name="email"/> <input type="submit" value="Go"/></p>
- </form>
-
- <p>
-<a href="http://groups.google.com/group/scrapy-developers">scrapy-developers</a>: Where discussions about Scrapy development itself takes place</a>
- </p>
-
- <form action="http://groups.google.com/group/scrapy-developers/boxsubscribe">
- <p>Subscribe: <input type="text" size="15" name="email"/> <input type="submit" value="Go"/></p>
- </form>
-
- <h2>IRC</h2>
-
- <p>
- Join the <a href="irc://irc.freenode.net/scrapy">#scrapy IRC channel</a> at Freenode to chat with other Scrapy users &amp; developers
- </p>
-
-</div>
-{% endblock %}
diff --git a/sites/scrapy.org/templates/articles/doc.html b/sites/scrapy.org/templates/articles/doc.html
deleted file mode 100644
index b5f9c8bb9..000000000
--- a/sites/scrapy.org/templates/articles/doc.html
+++ /dev/null
@@ -1,29 +0,0 @@
-{% extends "base_home.html" %}
-
-{% block main-content %}
- <h1>Scrapy Documentation</h1>
-
- <p>You can browse the Scrapy documentation online at:</p>
-
- <p style="margin-left: 20px; font-size: larger;"><a href="http://doc.scrapy.org/">http://doc.scrapy.org</a></p>
-
- <p>At the moment (January, 2009) our top priority is improving the
- documentation so keep in mind that it will change and grow quite a bit
- these days.</p>
-
- <p>After we finish the documention we'll make it available in another
- formats.</p>
-
- <h1>Getting help</h1>
-
- <p>Having trouble? We’d like to help!</p>
-
- <ul>
- <li>Check the <a href="http://doc.scrapy.org/faq.html">FAQ</a> – it’s got answers to many common questions.</li>
- <li>Looking for specific information? Try the <a href="http://doc.scrapy.org/genindex.html">Index</a>, <a href="http://doc.scrapy.org/modindex.html">Module Index</a> or the <a href="http://doc.scrapy.org/ref/index.html">Scrapy API table of contents</a>.</li>
- <li>Search for information in <a href="http://groups.google.com/group/scrapy-users/">the archives of the scrapy-users mailing list</a>, or <a href="http://groups.google.com/group/scrapy-users/">post a question</a>.</li>
- <li>Ask a question in the <a href="irc://irc.freenode.net/scrapy">#scrapy IRC channel</a>.</li>
- <li>Report bugs with Scrapy in our <a href="http://dev.scrapy.org">ticket tracker</a>.</li>
- </ul>
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/articles/download.html b/sites/scrapy.org/templates/articles/download.html
deleted file mode 100644
index 771677c8d..000000000
--- a/sites/scrapy.org/templates/articles/download.html
+++ /dev/null
@@ -1,47 +0,0 @@
-{% extends "base_home.html" %}
-
-{% block main-content %}
- <h2>How to get Scrapy</h2>
-
- <p>
- Scrapy is available under the <a class="reference" href="http://dev.scrapy.org/browser/scrapy/trunk/LICENSE">BSD license</a>.
- It runs on Linux, Windows and Mac. It requires Python 2.5 and some other Python libraries (see Requirements below)
- </p>
-
- <h2>Requirements</h2>
-
- <ul>
- <li>Python 2.5 (or 2.6)</li>
- <li>Twisted 8.0 or above</li>
- <li>libxml2 2.6.28 or above (including Python bidings)</li>
- </ul>
-
- <p>
- The following libraries are also recommended:
- </p>
-
- <ul>
- <li>pyopenssl - for crawling secure (HTTPS) pages</li>
- <li>spidermonkey - for parsing javascript</li>
- </ul>
-
-
- <h2>Latest release</h2>
-
- <p>
- We're working hard to get the first release of Scrapy out. In the
- meantime, you can download the latest development version in a <a href="http://dev.scrapy.org/changeset/HEAD/scrapy/trunk?old_path=%2F&format=zip">ZIP file</a> (from Trac) or checkout the Subversion repository.
- </p>
-
- <h2>Development version</h2>
-
- <p>You can get the latest (and more stable) release of Scrapy from the
- Subversion repository at: <code>http://svn.scrapy.org/scrapy/trunk/</code>
- </p>
-
- <h2>After you get it</h2>
-
- <p>Read the <a href="http://doc.scrapy.org/intro/install.html">Installation
- steps</a> (in the documentation) for further instructions </p>
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/articles/home.html b/sites/scrapy.org/templates/articles/home.html
deleted file mode 100644
index f52ae3156..000000000
--- a/sites/scrapy.org/templates/articles/home.html
+++ /dev/null
@@ -1,56 +0,0 @@
-{% extends "base_home.html" %}
-
-{% block main-content %}
- <h2>Welcome to Scrapy</h2>
-
- <blockquote><p>
- Scrapy is a high level scraping and web crawling framework for writing
- spiders to crawl and parse web pages for all kinds of purposes, from
- information retrieval to monitoring or testing web sites.
- </p></blockquote>
-
- <h3>Features</h3>
-
- <dl>
-
- <dt>Productive</dt>
- <dd>Just write the rules to extract data from pages and let Scrapy crawl the entire web site for you</dd>
-
- <dt>Scalable</dt>
- <dd>Scrapy is being used in production to scrape more than 500 sites daily, all in one server</dd>
-
- <dt>Distributed<dt>
- <dd>If you need more processing/bandwith power Scrapy comes bundled with a master/slave cluster that lets you scrape using as many servers as possible</li>
-
- <dt>Extensible</dt>
- <dd>Scrapy was designed with extensibility in mind and so it provides several mechanisms to plug new code without having to touch the framework core</li>
-
- <dt>Portable</dt>
- <dd>Scrapy runs on Linux, Windows and Mac</dd>
-
- <dt>100% Python</dt>
- <dd>Scrapy is completely written in Python, which makes it very easy to hack it</dd>
-
- <dt>Well-tested</dt>
- <dd>Scrapy has an extensive test suite with pretty good code coverage</dd>
-
- </dl>
-
- <h3>Project status</h3>
-
- <p>
- We're currently preparing the first official release of Scrapy with a
- very stable API. At the moment we consider the API quite stable, and
- we're writing documentation, tutorials and examples to make it easier
- to start using it.
- </p>
-
- <h3>Where to start?</h3>
-
- <p>
- Please start by reading <a href="/docs/">the documentation</a> and checking
- out the community resources where you can ask for further help while we
- finish improving the documentation.
- </p>
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/base.html b/sites/scrapy.org/templates/base.html
deleted file mode 100644
index f316d56d3..000000000
--- a/sites/scrapy.org/templates/base.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>{% block title %}Scrapy | An open source web scraping framework for Python{% endblock %}</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-
- <link href="{{ MEDIA_URL }}/style/style.css" rel="stylesheet" type="text/css" media="screen" />
- {% block extrastyles %}{% endblock %}
- <!--[if IE 6]>
- <link href="/style/ie60.css" rel="stylesheet" type="text/css" media="screen" />
- <![endif]-->
- <!--[if IE 7]>
- <link href="/style/ie70.css" rel="stylesheet" type="text/css" media="screen" />
- <![endif]-->
-
- {% block extrascripts %}{% endblock %}
- </head>
- <body>
- <div id="wrapper">
- {% include "header.html" %}
- <div id="body">
- <div id="content-wrapper">
- <div id="content">
- {% block main-content %}{% endblock %}
- </div>
- </div>
- <div id="sidebar">
- {% block extra-content %}{% endblock %}
- </div>
- <br class="clear"/>
- </div>
- {% include "footer.html" %}
- </div>
- </body>
-</html>
diff --git a/sites/scrapy.org/templates/base_doc.html b/sites/scrapy.org/templates/base_doc.html
deleted file mode 100644
index 5efcbdb9f..000000000
--- a/sites/scrapy.org/templates/base_doc.html
+++ /dev/null
@@ -1,29 +0,0 @@
-{% extends "base.html" %}
-
-{% block extrastyles %}
-<style type="text/css">
-a.headerlink {
- color: #c60f0f;
- font-size: 0.8em;
- padding: 0 4px 0 4px;
- text-decoration: none;
- visibility: hidden;
-}
-
-h1:hover > a.headerlink,
-h2:hover > a.headerlink,
-h3:hover > a.headerlink,
-h4:hover > a.headerlink,
-h5:hover > a.headerlink,
-h6:hover > a.headerlink,
-dt:hover > a.headerlink {
- visibility: visible;
-}
-
-a.headerlink:hover {
- background-color: #c60f0f;
- color: white;
-}
-</style>
-<link href="{{ MEDIA_URL }}/style/pygments.css" rel="stylesheet" type="text/css" media="screen" />
-{% endblock %}
diff --git a/sites/scrapy.org/templates/base_home.html b/sites/scrapy.org/templates/base_home.html
deleted file mode 100644
index f5a5e5dd6..000000000
--- a/sites/scrapy.org/templates/base_home.html
+++ /dev/null
@@ -1,36 +0,0 @@
-{% extends "base.html" %}
-
-{% block extra-content %}
- {% load download_tags %}
- {% load_download_links as "download_links" %}
-
- {% if download_links %}
- <div class="box download">
- <h3>Download Scrapy</h3>
-
- {% for link in download_links %}
- <p>{{ link.description }} <a href="{{ link.address }}" class="download">{{ link.text }}</a></p>
- {% endfor %}
- </div>
- {% endif %}
-
- {% comment %}
- {% load lastblogentry %}
- {% get_latest_blog_entries 2 as entries %}
-
- {% if entries %}
- <div class="box">
- <h3>Scrapy Weblog</h3>
-
- {% for entry in entries %}
- <div class="post{% if forloop.last %} last{% endif %}">
- <h4><a href="{{ entry.get_absolute_url }}">{{ entry.headline }}</a></h4>
- <p class="author">by {{ entry.author }} on {{ entry.pub_date|date:"M d, Y"}}</p>
- <p class="abstract">{{ entry.summary }}</p>
- <a href="{{ entry.get_absolute_url }}" class="more">&raquo; Read More</a>
- </div>
- {% endfor %}
- </div>
- {% endif %}
- {% endcomment %}
-{% endblock %}
diff --git a/sites/scrapy.org/templates/base_weblog.html b/sites/scrapy.org/templates/base_weblog.html
deleted file mode 100644
index d03d640ff..000000000
--- a/sites/scrapy.org/templates/base_weblog.html
+++ /dev/null
@@ -1,6 +0,0 @@
-{% extends "base_home.html" %}
-
-{% block title %}{{ block.super }} - Weblog{% endblock %}
-
-{% block main-content %}
-{% endblock %}
diff --git a/sites/scrapy.org/templates/blog/base_blog.html b/sites/scrapy.org/templates/blog/base_blog.html
deleted file mode 100644
index 48a039f7d..000000000
--- a/sites/scrapy.org/templates/blog/base_blog.html
+++ /dev/null
@@ -1,5 +0,0 @@
-{% extends "base.html" %}
-oaihdasasihjsd
-
-
-{% block body_class %}blog{% endblock %}
diff --git a/sites/scrapy.org/templates/blog/category_detail.html b/sites/scrapy.org/templates/blog/category_detail.html
deleted file mode 100644
index 880c37515..000000000
--- a/sites/scrapy.org/templates/blog/category_detail.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Posts for {{ category.title }}{% endblock %}
-{% block body_class %}{{ block.super }} category_detail{% endblock %}
-{% block body_id %}category_{{ category.id }}{% endblock %}
-
-
-{% block main-content_title %}
- <h2>Posts for {{ category.title }}</h2>
-{% endblock %}
-
-
-{% block main-content %}
- {% load markup %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/templates/blog/category_list.html b/sites/scrapy.org/templates/blog/category_list.html
deleted file mode 100644
index d136b4bd1..000000000
--- a/sites/scrapy.org/templates/blog/category_list.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post categories{% endblock %}
-{% block body_class %}{{ block.super }} category_list{% endblock %}
-
-
-{% block main-content_title %}
- <h2>Post categories</h2>
-{% endblock %}
-
-
-{% block main-content %}
- {% load markup %}
- <ul class="link_list">
- {% for category in object_list %}
- <li><a href="{{ category.get_absolute_url }}">{{ category }}</a></li>
- {% endfor %}
- </ul>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/templates/blog/post_archive_day.html b/sites/scrapy.org/templates/blog/post_archive_day.html
deleted file mode 100644
index 4c95f8cf0..000000000
--- a/sites/scrapy.org/templates/blog/post_archive_day.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive for {{ day|date:"d F Y" }}{% endblock %}
-{% block body_class %}{{ block.super }} post_archive_day{% endblock %}
-
-
-{% block main-content_title %}
- <h2>Post archive for {{ day|date:"d F Y" }}</h2>
-{% endblock %}
-
-
-{% block main-content %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/templates/blog/post_archive_month.html b/sites/scrapy.org/templates/blog/post_archive_month.html
deleted file mode 100644
index 45c4c53e4..000000000
--- a/sites/scrapy.org/templates/blog/post_archive_month.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive for {{ month|date:"F Y" }}{% endblock %}
-{% block body_class %}{{ block.super }} post_archive_month{% endblock %}
-
-
-{% block main-content_title %}
- <h2>Post archive for {{ month|date:"F Y" }}</h2>
-{% endblock %}
-
-
-{% block main-content %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/templates/blog/post_archive_year.html b/sites/scrapy.org/templates/blog/post_archive_year.html
deleted file mode 100644
index 1a176ef9d..000000000
--- a/sites/scrapy.org/templates/blog/post_archive_year.html
+++ /dev/null
@@ -1,21 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive for {{ year }}{% endblock %}
-{% block body_class %}{{ block.super }} post_archive_year{% endblock %}
-
-
-{% block main-content_title %}
- <h2>Post archive for {{ year }}</h2>
-{% endblock %}
-
-
-{% block main-content %}
- {% load markup %}
-
- <ul class="link_list">
- {% for month in date_list %}
- <li><a href="{% url blog_index %}{{ year }}/{{ month|date:"b" }}/">{{ month|date:"F" }}</a></li>
- {% endfor %}
- </ul>
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/templates/blog/post_detail.html b/sites/scrapy.org/templates/blog/post_detail.html
deleted file mode 100644
index 3df6fd644..000000000
--- a/sites/scrapy.org/templates/blog/post_detail.html
+++ /dev/null
@@ -1,76 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}{{ object.title }}{% endblock %}
-{% block body_class %}{{ block.super }} post_detail{% endblock %}
-{% block body_id %}post_{{ object.id }}{% endblock %}
-
-
-{% block content_title %}
-{% endblock %}
-
-
-{% block main-content %}
- {% load blog markup %}
- <h2>{{ object.title }}</h2>
- <p class="other_posts">
- {% if object.get_previous_by_publish %}
- <a class="previous" href="{{ object.get_previous_post.get_absolute_url }}">&laquo; {{ object.get_previous_post }}</a>
- {% endif %}
- {% if object.get_next_by_publish %}
- | <a class="next" href="{{ object.get_next_post.get_absolute_url }}">{{ object.get_next_post }} &raquo;</a>
- {% endif %}
- </p>
-
- {% comment %}
- {% load comments tagging_tags %}
- {% endcomment %}
-
- <p class="date">{{ object.publish|date:"j F Y" }}</p>
-
- <div class="body">
- {{ object.body|markdown:"safe" }}
- </div>
-
- {% comment %}
- {% tags_for_object object as tag_list %}
- {% if tag_list %}
- <p class="inline_tag_list"><strong>Related tags:</strong>
- {% for tag in tag_list %}
- {{ tag }}{% if not forloop.last %}, {% endif %}
- {% endfor %}
- </p>
- {% endif %}
- {% endcomment %}
-
-
- {% comment %}
- {% get_comment_list for object as comment_list %}
- {% if comment_list %}
- <div id="comments">
- <a name="comments"></a>
- <h3 class="comments_title">Comments</h3>
- {% for comment in comment_list %}
- {% if comment.is_public %}
- <div class="comment">
- <h5 class="name">
- <a name="c{{ comment.id }}" href="{{ comment.get_absolute_url }}" title="Permalink to {{ comment.person_name }}'s comment" class="count">{{ forloop.counter }}</a>
- {% if comment.user_url %}<a href="{{ comment.user_url }}">{{ comment.user_name }}</a>{% else %}{{ comment.user_name }}{% endif %} says...
- </h5>
- {{ comment.comment|urlizetrunc:"60"|markdown:"safe" }}
- <p class="date">Posted at {{ comment.submit_date|date:"P" }} on {{ comment.submit_date|date:"F j, Y" }}</p>
- </div>
- {% endif %}
- {% endfor %}
- </div>
- {% endif %}
- {% if object.allow_comments %}
- {% render_comment_form for object %}
- {% else %}
- <div id="comment_form">
- <h3>Comments are closed.</h3>
- <p>Comments have been close for this post.</p>
- </div>
- {% endif %}
- {% endcomment %}
-{% endblock %}
diff --git a/sites/scrapy.org/templates/blog/post_list.html b/sites/scrapy.org/templates/blog/post_list.html
deleted file mode 100644
index 5f8d8c1cd..000000000
--- a/sites/scrapy.org/templates/blog/post_list.html
+++ /dev/null
@@ -1,35 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post archive{% endblock %}
-{% block body_class %}{{ block.super }} post_list{% endblock %}
-
-
-{% block main-content_title %}
- <h2>Post archive</h2>
-{% endblock %}
-
-
-{% block main-content %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- </div>
- {% endfor %}
- </div>
-
- {% if is_paginated %}
- <p class="pagination">
- {% if has_next %}
- <a class="older" href="?page={{ next }}">Older</a>
- {% endif %}
- {% if has_next and has_previous %} | {% endif %}
- {% if has_previous %}
- <a class="newer" href="?page={{ previous }}">Newer</a>
- {% endif %}
- </p>
- {% endif %}
-{% endblock %}
diff --git a/sites/scrapy.org/templates/blog/post_search.html b/sites/scrapy.org/templates/blog/post_search.html
deleted file mode 100644
index 271000351..000000000
--- a/sites/scrapy.org/templates/blog/post_search.html
+++ /dev/null
@@ -1,37 +0,0 @@
-{% extends "blog/base_blog.html" %}
-
-
-{% block title %}Post search{% endblock %}
-{% block body_class %}{{ block.super }} post_search{% endblock %}
-
-
-{% block main-content_title %}
- <h2>Search</h2>
-{% endblock %}
-
-
-{% block main-content %}
- <form action="." method="get" id="post_search_form">
- <p>
- <input type="text" name="q" value="{{ search_term }}" id="search">
- <input type="submit" class="button" value="Search">
- </p>
- </form>
-
- {% if message %}
- <p class="message">{{ message }}</p>
- {% endif %}
-
- {% if object_list %}
- <div class="post_list">
- {% for post in object_list %}
- <div>
- <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
- <p class="date">{{ post.publish|date:"Y F d" }}</p>
- <p class="tease">{{ post.tease }}</p>
- <p class="comments">{% if comment_count %}{{ comment_count }} comment{{ comment_count|pluralize }}{% endif %}</p>
- </div>
- {% endfor %}
- </div>
- {% endif %}
-{% endblock %}
\ No newline at end of file
diff --git a/sites/scrapy.org/templates/blog_back/entry_archive.html b/sites/scrapy.org/templates/blog_back/entry_archive.html
deleted file mode 100644
index 4adeff722..000000000
--- a/sites/scrapy.org/templates/blog_back/entry_archive.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends "base_weblog.html" %}
-
-{% block main-content %}
-
-{% load comments comment_utils %}
-
-<h2>Latest entries</h2>
-
-{% for object in latest %}
- <h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2>
- {{ object.body }}
- <p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ object.pub_date|date:"F j, Y" }}</p>
-{% endfor %}
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/blog_back/entry_archive_day.html b/sites/scrapy.org/templates/blog_back/entry_archive_day.html
deleted file mode 100644
index 5d7ada069..000000000
--- a/sites/scrapy.org/templates/blog_back/entry_archive_day.html
+++ /dev/null
@@ -1,16 +0,0 @@
-{% extends "base_weblog.html" %}
-
-{% block title %}Weblog | {{ day|date:"F j" }}{% endblock %}
-
-{% block main-content %}
-
-<h2>{{ day|date:"F j" }} archive</h2>
-
-{% for object in object_list %}
-<h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2>
-<p class="small date">{{ object.pub_date|date:"F j, Y" }}</p>
-{{ object.body }}
-
-{% endfor %}
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/blog_back/entry_archive_month.html b/sites/scrapy.org/templates/blog_back/entry_archive_month.html
deleted file mode 100644
index 388ce67eb..000000000
--- a/sites/scrapy.org/templates/blog_back/entry_archive_month.html
+++ /dev/null
@@ -1,16 +0,0 @@
-{% extends "base_weblog.html" %}
-
-{% block title %}Weblog | {{ month|date:"F" }}{% endblock %}
-
-{% block main-content %}
-
-<h2>{{ month|date:"F" }} archive</h2>
-
-{% for object in object_list %}
-<h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2>
-<p class="small date">{{ object.pub_date|date:"F j, Y" }}</p>
-{{ object.body }}
-
-{% endfor %}
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/blog_back/entry_archive_year.html b/sites/scrapy.org/templates/blog_back/entry_archive_year.html
deleted file mode 100644
index d58ff781a..000000000
--- a/sites/scrapy.org/templates/blog_back/entry_archive_year.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends "base_weblog.html" %}
-
-{% block title %}Weblog | {{ year }}{% endblock %}
-
-{% block main-content %}
-
-<h2>{{ year }} archive</h2>
-
-<ul class="linklist">
-{% for date in date_list %}
-<li><a href="{{ date|date:"M"|lower }}/">{{ date|date:"F" }}</a></li>
-{% endfor %}
-</ul>
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/blog_back/entry_detail.html b/sites/scrapy.org/templates/blog_back/entry_detail.html
deleted file mode 100644
index 99ca4694e..000000000
--- a/sites/scrapy.org/templates/blog_back/entry_detail.html
+++ /dev/null
@@ -1,34 +0,0 @@
-{% extends "base_weblog.html" %}
-
-{% block title %}Weblog | {{ object.headline|escape }}{% endblock %}
-
-{% block main-content %}
-
-<h2>{{ object.headline }}</h2>
-{{ object.body }}
-<p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ object.pub_date|date:"F j, Y" }}</p>
-
-{% comment %}
-{% load comments comment_utils %}
-{% get_public_free_comment_list for blog.entry object.id as comment_list %}
-
-<div id="content-secondary">
-<h2 id="comments">Comments</h2>
-
-{% for comment in comment_list %}
-<div class="comment" id="c{{ comment.id }}">
- <h3>{{ comment.person_name|escape }} <span class="small quiet">{{ comment.submit_date|date:"F j, Y" }} at {{ comment.submit_date|date:"P" }}</span></h3>
- {{ comment.comment|escape|urlizetrunc:"40"|linebreaks }}
-</div>
-{% endfor %}
-
-{% if object.comments_enabled %}
-<h2>Post a comment</h2>
-{% free_comment_form for blog.entry object.id %}
-{% else %}
-<h2>Comments are closed</h2>
-<p>To prevent spam, comments are no longer allowed after sixty days.</p>
-{% endif %}
-</div>
-{% endcomment %}
-{% endblock %}
diff --git a/sites/scrapy.org/templates/docs/doc.html b/sites/scrapy.org/templates/docs/doc.html
deleted file mode 100644
index 806aac810..000000000
--- a/sites/scrapy.org/templates/docs/doc.html
+++ /dev/null
@@ -1,34 +0,0 @@
-{% extends "base_doc.html" %}
-
-{% block title %}{{ doc.title|safe }}{% endblock %}
-
-{% block main-content %}
-{% if doc.parents %}
-<div class="breadcrumb">
-<a href="/docs/">Documentation</a> &raquo;
-{% for p in doc.parents %}
-<a href="{{ p.link }}">{{ p.title|safe }}</a> &raquo;
-{% endfor %}
-</div>
-{% endif %}
-{{ doc.body|safe }}
-{% endblock %}
-
-{% block extra-content %}
-
-{% if doc.display_toc %}
-<h3>Contents:</h3>
-{{ doc.toc|safe }}
-{% endif %}
-
-<h3>Browse</h3>
-<ul>
- {% if doc.prev %}
- <li>Prev: <a href="{{ doc.prev.link }}">{{ doc.prev.title|safe }}</a></li>
- {% endif %}
- {% if doc.next %}
- <li>Next: <a href="{{ doc.next.link }}">{{ doc.next.title|safe }}</a></li>
- {% endif %}
-</ul>
-
-{% endblock %}
diff --git a/sites/scrapy.org/templates/footer.html b/sites/scrapy.org/templates/footer.html
deleted file mode 100644
index 8d8bc7e55..000000000
--- a/sites/scrapy.org/templates/footer.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<div id="footer">
- <p id="badge">
- <a href="http://www.djangoproject.com/">
- <img
- src="http://media.djangoproject.com/img/badges/djangosite80x15.gif"
- width="80" height="15" alt="A Django site." title="A Django site."/>
- </a>
- </p>
- <p>&copy; 2007-2008 <a href="http://insophia.com/">Insophia</a>, <a href="http://mydeco.com/the-magazine/style/mydeco-about-us">By Design UK</a></p>
-</div>
diff --git a/sites/scrapy.org/templates/header.html b/sites/scrapy.org/templates/header.html
deleted file mode 100644
index c5baf7f96..000000000
--- a/sites/scrapy.org/templates/header.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<div id="header-wrap">
-<div id="header">
- <h1><a href="/"><img src="{{ MEDIA_URL }}/images/logo.jpg" width="150" height="65" alt="Scrapy"/></a></h1>
- <ul id="navigation">
- <li><a href="/">Home</a></li>
- <li><a href="/download/">Download</a></li>
- <li><a href="/doc/">Documentation</a></li>
- <li><a href="/news/">News</a></li>
- <li><a href="/community/">Community</a></li>
- <li class="last"><a href="http://dev.scrapy.org">Development</a></li>
- </ul>
- <br class="clear"/>
-</div>
-</div>
diff --git a/sites/static.scrapy.org/asc.png b/sites/static.scrapy.org/asc.png
deleted file mode 100644
index 486b73159..000000000
Binary files a/sites/static.scrapy.org/asc.png and /dev/null differ
diff --git a/sites/static.scrapy.org/attachment.png b/sites/static.scrapy.org/attachment.png
deleted file mode 100644
index a4d212439..000000000
Binary files a/sites/static.scrapy.org/attachment.png and /dev/null differ
diff --git a/sites/static.scrapy.org/changeset.png b/sites/static.scrapy.org/changeset.png
deleted file mode 100644
index 31c0356a3..000000000
Binary files a/sites/static.scrapy.org/changeset.png and /dev/null differ
diff --git a/sites/static.scrapy.org/closedticket.png b/sites/static.scrapy.org/closedticket.png
deleted file mode 100644
index 43f7a8447..000000000
Binary files a/sites/static.scrapy.org/closedticket.png and /dev/null differ
diff --git a/sites/static.scrapy.org/collapsed.png b/sites/static.scrapy.org/collapsed.png
deleted file mode 100644
index 4a2ac198c..000000000
Binary files a/sites/static.scrapy.org/collapsed.png and /dev/null differ
diff --git a/sites/static.scrapy.org/css/about.css b/sites/static.scrapy.org/css/about.css
deleted file mode 100644
index f778bc9a9..000000000
--- a/sites/static.scrapy.org/css/about.css
+++ /dev/null
@@ -1,18 +0,0 @@
-/* About page */
-#content.about p.copyright { color: #999; font-size: 90%; }
-#content.about h2 { margin-top: 2em; }
-#content.about table { margin-top: 0; width: auto; }
-#content.about table th, #content.about table td { font-size: 90%; }
-
-#content.about th { background: #f7f7f0; font-weight: bold; text-align: right;
- vertical-align: top;
-}
-
-#content.about #config th { text-align: left; }
-#content.about #config th.section { text-align: right; }
-#content.about #config th, #content.about #config td { border: 1px solid #ddd;
- padding: 3px;
-}
-#content.about #config tr.modified { background: #ffd; }
-#content.about #config tr.modified td.value { font-style: italic; }
-#content.about #config td.doc { padding: 3px 1em; }
diff --git a/sites/static.scrapy.org/css/admin.css b/sites/static.scrapy.org/css/admin.css
deleted file mode 100644
index 9bb40b415..000000000
--- a/sites/static.scrapy.org/css/admin.css
+++ /dev/null
@@ -1,66 +0,0 @@
-#content.admin h1 { float: left; }
-
-#tabs { background: #f7f7f0; border: 1px solid black;
- border-color: #ccc #666 #666 #ccc; clear: left;
- margin: 1em 0 2em; padding: .5em 0 0; float: left; width: 12em;
-}
-#tabs ul { list-style: none; margin: 0 0 .5em; padding: 0; }
-#tabs li { color: #999; font-size: 90%; font-weight: bold; margin: 0;
- padding: 0.1em 5px;
-}
-#tabs li li { color: #000; font-size: 110%; font-weight: normal;
- margin: 0 -3px; padding: 1px 0 1px 10px;
-}
-#tabs li li.active { background: #ddc; border: 1px solid;
- border-color: #ccc #000 #666 #ccc; padding: 0 0 0 9px;
-}
-#tabs :link, #tabs :visited { border: none; display: block }
-#tabs :link:hover, #tabs :visited:hover { background: transparent;
- color: #000;
-}
-
-#tabcontent { padding: 0.4em 2em; margin-left: 12em; min-height: 300px; }
-#tabcontent h2 { color: #333; margin-top: 0; }
-p.help { color: #666; font-size: 90%; margin: 1em .5em .5em; }
-
-#enumlist tbody td { vertical-align: middle; }
-
-form.addnew { clear: right; float: right; margin: -2em 0 4em; width: 33% }
-form.mod { margin-top: 1em; }
-form.mod .field { margin: .5em 0; }
-form .field em { color: #888; font-size: smaller }
-form .field .disabled em { color: #d7d7d7 }
-
-table.listing { clear: none; width: 64% }
-table.listing .sel, table.listing .default { text-align: center; width: 1% }
-
-/* Plugins panel */
-form#addplug { width: 35% }
-.plugin { background: #f7f7f7; border: 1px solid #d7d7d7; margin: 0 0 2em;
- padding: 2px .5em; text-align: left; width: 60%;
-}
-.plugin h3 { margin: .5em 0; color: #bb0000;}
-.plugin h3 a {
- padding: 2px .5em; text-align: left; width: 60%;
-}
-.plugin h3 a { background: url(../expanded.png) 0 50% no-repeat;
- padding-left: 16px;
-}
-.collapsed h3 a { background-image: url(../collapsed.png); }
-.plugin .buttons { margin-top: 0; text-align: right }
-.plugin .uninstall { margin-top: -2.6em; padding: 0 }
-.plugin .summary, .plugin .info { color: #999; font-size: 80%;
- padding-left: 16px;
-}
-.plugin .summary { margin: -.5em 0 .5em }
-.plugin .info { margin: 1em 0 .5em; }
-.plugin .info dt { float: left; width: 7em; }
-.plugin .info dd { padding: 0; margin: 0; }
-.plugin .listing { width: 100% }
-.collapsed .info, .collapsed .listing, .collapsed .update { display: none }
-.plugin .listing td { background: #fff }
-.plugin .listing .name p { color: #999; font-size: 80%; margin: 0 }
-
-/* Perm Panel */
-#permlist div { width: 13em; float: left; }
-fieldset tr.field th { text-align: right; }
diff --git a/sites/static.scrapy.org/css/browser.css b/sites/static.scrapy.org/css/browser.css
deleted file mode 100644
index 8dfa37d9b..000000000
--- a/sites/static.scrapy.org/css/browser.css
+++ /dev/null
@@ -1,183 +0,0 @@
-#prefs { margin-top: -0.6em }
-* html #prefs { width: 34em } /* Set width only for IE */
-#prefs fieldset { margin: 0; }
-#prefs fieldset label { display: block }
-#prefs .buttons { margin-top: -2.3em }
-#prefs .choice {
- float: left;
- margin: 0 .6em 0 .3em;
- border-right: 1px dotted #d7d7d7;
-}
-
-#file-legend { margin-top: 3em; }
-
-/* Browser */
-h1 { margin: 0; padding: 0 0 .5em }
-h1 :link, h1 :visited, h1 .filename { border: none; padding: 0 .2em }
-h1 :link, h1 :visited { color: #b00 }
-h1 .first:link, h1 .first:visited { color: #998 }
-h1 .sep { color: #666; padding: 0 .1em }
-h1 .pathentry { float: left }
-
-#jumprev, #jumploc { float: right; font-size: 10px; margin: 0 0 0.6em }
-#jumprev form, #jumploc form { margin: 0 }
-#jumprev input, #jumploc select, #jumploc input {
- font-size: 10px;
- margin: 0;
-}
-#jumploc div.buttons { margin: 0;}
-#jumploc { margin-right: 2em;}
-
-/* Browser file annotations */
-table.code th.blame { width: 5em; }
-table.code th.blame a { color: #ddd; }
-
-div.message {
- background: #f7f7f0;
- border: 3px double #d7d7d7;
- margin: 0;
- padding: 8px;
- /* Note: border width and padding must be compensated for in the placement */
-}
-
-div.message div.inlinebuttons { float: right; }
-
-/* Styles for the directory entries table
- (extends the styles for "table.listing") */
-#dirlist { margin-top: 0 }
-#dirlist td.rev, #dirlist td.age, #dirlist td.change {
- color: #888;
- white-space: nowrap;
- vertical-align: baseline;
-}
-#dirlist td.rev {
- font-family: monospace;
- letter-spacing: -0.08em;
- font-size: 90%;
- text-align: right;
-}
-#dirlist td.size {
- color: #888;
- white-space: nowrap;
- text-align: right;
- vertical-align: middle;
- font-size: 70%;
-}
-#dirlist td.age {
- border-width: 0 2px 0 0;
- border-style: solid;
- font-size: 85%;
-}
-#dirlist td.name { width: 100% }
-#dirlist td.name a, #dirlist td.name span {
- background-position: 0% 50%;
- background-repeat: no-repeat;
- padding-left: 20px;
-}
-#dirlist td.name a.parent { background-image: url(../parent.png) }
-#dirlist td.name div { white-space: pre }
-#dirlist tr span.expander {
- background-image: url(../expander_normal.png);
- cursor: pointer;
- padding-left: 8px;
- margin-left: 4px;
-}
-#dirlist tr span.expander:hover {
- background-image: url(../expander_normal_hover.png);
-}
-#dirlist tr.expanded span.expander {
- background-image: url(../expander_open.png);
- padding-left: 12px;
- margin-left: 0;
-}
-#dirlist tr.expanded span.expander:hover {
- background-image: url(../expander_open_hover.png);
-}
-#dirlist td.name a.dir { background-image: url(../folder.png) }
-#dirlist td.name a.file { background-image: url(../file.png); display: block }
-#dirlist td.name a, #dirlist td.rev a { border-bottom: none }
-#dirlist td.rev { text-align: right }
-#dirlist td.change {
- font-size: 85%;
- vertical-align: middle;
- white-space: nowrap
-}
-
-#dirlist td span.loading {
- background-image: url(../loading.gif);
- font-style: italic
-}
-
-/* Style for the ''View Changes'' button and the diff preparation form */
-#anydiff { margin: 0 0 1em; float: left }
-#anydiff form, #anydiff div, #anydiff h2 { display: inline }
-#anydiff form th { text-align: right }
-#anydiff input { vertical-align: baseline; margin: 0 -0.5em 0 1em }
-@media print {
- #anydiff form { display: none }
-}
-
-/* Log */
-tr.diff input { padding: 0 1em; margin: 0 }
-
-@media print {
- th.diff, td.diff { display: none }
-}
-
-/* Styles for the revision log table (extends the styles for "table.listing") */
-#chglist { margin-top: 0 }
-#chglist td.change span {
- border: 1px solid #999;
- display: block;
- margin: .2em .5em 0 0;
- width: .8em; height: .8em;
-}
-#chglist td.diff { white-space: nowrap }
-#chglist td.change .comment { display: none }
-#chglist td.old_path { font-style: italic }
-#chglist td.date {
- font-size: 85%;
- vertical-align: top;
- padding-top: 0.55em;
- white-space: nowrap;
-}
-#chglist td.author { font-size: 85%; vertical-align: top; padding-top: 0.55em }
-#chglist td.rev, #chglist td.chgset {
- font-family: monospace;
- letter-spacing: -0.08em;
- font-size: 90%;
- text-align: right;
-}
-#chglist td.rev a, #chglist td.chgset a { border-bottom: none }
-#chglist td.summary {
- width: 100%;
- font-size: 85%;
- vertical-align: middle;
- white-space: nowrap;
-}
-#chglist tr.verbose td.summary {
- border: none;
- color: #333;
- padding: .5em 1em 1em 2em;
- white-space: normal;
-}
-
-#chglist td.summary * { margin-top: 0 }
-
-#paging { margin: 1em 0 }
-
-/* Styles for the revision info in the file view (see also trac.css) */
-#info { margin: 0; }
-#info .props {
- color: #666;
- list-style: square;
- margin: 0 0 .4em 1.6em;
- padding: 0;
-}
-#info .props li { padding: 0; overflow: auto; }
-
-/* Styles for the HTML preview */
-#preview { background: #fff; clear: both; margin: 0 }
-#preview .code-block { border-top: 1px solid #999; margin: 0 }
-#preview .image-file { overflow: hidden }
-#preview .image-file img { max-width: 100% }
diff --git a/sites/static.scrapy.org/css/changeset.css b/sites/static.scrapy.org/css/changeset.css
deleted file mode 100644
index 0c852dd04..000000000
--- a/sites/static.scrapy.org/css/changeset.css
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Changeset overview */
-#overview .files { padding-top: 1em }
-#overview .files ul { margin: 0; padding: 0 }
-#overview .files li { list-style-type: none }
-#overview .files li .comment { display: none }
-#overview .files li div {
- border: 1px solid #999;
- float: left;
- margin: .3em .5em 0 0;
- overflow: hidden;
- width: .8em; height: .8em;
-}
-#overview div.add div, #overview div.cp div, #overview div.mv div {
- border: 0;
- margin: 0;
- float: right;
- width: .35em;
-}
-
-#overview .changeset { padding: 0 0 1px }
-#overview dd.changeset p {
- margin-bottom: 0;
- margin-top: 0;
-}
-#overview .files { padding: 1px 0 }
-
-.diff ul.props {
- font-size: 90%;
- list-style: disc;
- margin: .5em 0 0;
- padding: 0 .5em 1em 2em;
-}
-.diff ul.props li { margin: 0; padding: 0 }
-
-#title dl { display: inline; font-size: 110% }
-#title dt {
- display: inline;
- font-size: 110%;
- font-weight: bold;
- margin-left: 3em;
-}
-#title dd { display: inline; margin-left: 0.4em }
diff --git a/sites/static.scrapy.org/css/code.css b/sites/static.scrapy.org/css/code.css
deleted file mode 100644
index 015e02c7a..000000000
--- a/sites/static.scrapy.org/css/code.css
+++ /dev/null
@@ -1,164 +0,0 @@
-div.code {
- background: #f7f7f7;
- border: 1px solid #d7d7d7;
- margin: 1em 1.75em;
- padding: .25em;
- overflow: auto
-}
-
-div.code pre { margin: 0; }
-
-table.code {
- border: 1px solid #ddd;
- border-spacing: 0;
- border-top: 0;
- border-collapse: collapse;
- empty-cells: show;
- font-size: 12px;
- line-height: 130%;
- padding: 0;
- margin: 0 auto;
- table-layout: fixed;
- width: 100%;
-}
-table.code th {
- border-right: 1px solid #d7d7d7;
- border-bottom: 1px solid #998;
- font-size: 11px;
-}
-table.code th.lineno { width: 4em }
-table.code thead th {
- background: #eee;
- border-top: 1px solid #d7d7d7;
- color: #999;
- padding: 0 .25em;
- text-align: center;
- white-space: nowrap;
-}
-table.code tbody th {
- background: #eed;
- color: #886;
- font-weight: normal;
- padding: 0 .5em;
- text-align: right;
- vertical-align: top;
-}
-table.code tbody th :link, table.code tbody th :visited {
- border: none;
- color: #886;
- text-decoration: none;
-}
-table.code tbody th :link:hover, table.code tbody th :visited:hover {
- color: #000;
-}
-table.code td {
- font: normal 11px monospace;
- overflow: hidden;
- padding: 1px 2px;
- vertical-align: top;
-}
-table.code tr.hilite th {
- background: #ccf;
-}
-table.code tr.hilite td {
- background: #ddf;
-}
-.image-file { background: #eee; padding: .3em }
-.image-file img { background: url(../imggrid.png) }
-
-/* Default */
-.code-block span { font-family: monospace; }
-
-/* Comments */
-.code-comment, .css_comment, .c_comment, .c_commentdoc, .c_commentline,
-.c_commentlinedoc, .h_comment,.pl_commentline, .p_commentblock,
-.p_commentline, .hphp_comment, .hphp_commentblock, .hphp_commentline,
-.yaml_comment {
- color: #998;
- font-style: italic;
-}
-
-/* Language keyword */
-.code-keyword, .pl_word { color: #789; font-weight: bold }
-
-/* Type */
-.code-type, .c_word, .c_word2, .p_classname, .hphp_classname{
- color: #468;
- font-weight: bold;
-}
-
-/* Function */
-.code-func, .p_defname {
- color: #900;
- font-weight: bold;
- border-bottom: none;
-}
-
-/* Pre-processor */
-.code-prep, .c_preprocessor, .pl_preprocessor, .yaml_identifier {
- color: #999;
- font-weight: bold;
-}
-
-/* Language construct */
-.code-lang, .p_word { color: #000; font-weight: bold }
-
-/* String */
-.code-string, .c_string, .c_stringeol, .css_doublestring, .css_singlestring,
-.h_singlestring, .h_doublestring, .pl_string, .pl_string_q, .pl_string_qq,
-.pl_string_qr, .pl_string_qw, .pl_string_qx, .pl_backticks, .pl_character,
-.p_string, .p_stringeol, .hphp_string, .hphp_stringeol, .hphp_triple,
-.hphp_tripledouble, .p_character, .p_triple, .p_tripledouble {
- color: #b84;
- font-weight: normal;
-}
-
-/* Variable name */
-.code-var { color: #f9f }
-
-/* SilverCity-specific styles */
-.css_id, .css_class, .css_pseudoclass, .css_tag { color: #900000 }
-.css_directive { color: #009000; font-weight: bold }
-.css_important { color: blue }
-.css_operator { color: #000090; font-weight: bold }
-.css_tag { font-weight: bold }
-.css_unknown_identifier, .css_unknown_pseudoclass { color: red }
-.css_value { color: navy }
-.c_commentdockeyword { color: navy; font-weight: bold }
-.c_commentdockeyworderror { color: red; font-weight: bold }
-.c_character, .c_regex, .c_uuid, .c_verbatim { color: olive }
-.c_number { color: #099 }
-.h_asp { color: #ff0 }
-.h_aspat { color: #ffdf00 }
-.h_attribute { color: teal }
-.h_attributeunknown { color: red }
-.h_cdata { color: #373 }
-.h_entity { color: purple }
-.h_number { color: #099 }
-.h_other { color: purple }
-.h_script, .h_tag, .h_tagend { color: navy }
-.h_tagunknown { color: red }
-.h_xmlend, .h_xmlstart { color: blue }
-.pl_datasection { color: olive }
-.pl_error { color: red; font-weight: bold }
-.pl_hash { color: #000 }
-.pl_here_delim, .pl_here_q, .pl_here_qq, .pl_here_qx, .pl_longquote { color: olive }
-.pl_number { color: #099 }
-.pl_pod { font-style: italic }
-.pl_regex, .pl_regsubst { color: olive }
-.p_number { color: #099 }
-.hphp_character { color: olive }
-.hphp_defname { color: #099; font-weight: bold }
-.hphp_number { color: #099 }
-.hphp_word { color: navy; font-weight: bold }
-.yaml_document { color: gray; font-style: italic }
-.yaml_keyword { color: #808 }
-.yaml_number { color: #800 }
-.yaml_reference { color: #088 }
-.v_comment { color: gray; font-style: italic }
-.v_commentline, .v_commentlinebang { color: red; font-style: italic }
-.v_number, .v_preprocessor { color: #099 }
-.v_string, .v_stringeol { color: olive }
-.v_user{ color: blue; font-weight: bold }
-.v_word, .v_word3 { color: navy; font-weight: bold }
-.v_word2 { color: green; font-weight: bold }
diff --git a/sites/static.scrapy.org/css/diff.css b/sites/static.scrapy.org/css/diff.css
deleted file mode 100644
index 349b665b0..000000000
--- a/sites/static.scrapy.org/css/diff.css
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Diff preferences */
-#prefs fieldset { margin: 1em .5em .5em; padding: .5em 1em 0 }
-
-/* Diff/change overview */
-#overview { line-height: 130%; margin-top: 1em; padding: .5em }
-#overview dt.property {
- font-weight: bold;
- padding-right: .25em;
- position: absolute;
- left: 0;
- text-align: right;
- width: 7.75em;
-}
-#overview dd { margin-left: 8em }
-
-#overview .message { padding: 1em 0 1px }
-#overview dd.message p, #overview dd.message ul, #overview dd.message ol,
-#overview dd.message pre { margin-bottom: 1em; margin-top: 0; }
-
-/* Colors for change types */
-#chglist .edit, #overview .mod, .diff .legend .mod { background: #fd8 }
-#chglist .delete, #overview .rem, .diff .legend .rem { background: #f88 }
-#chglist .add, #overview .add, .diff .legend .add { background: #bfb }
-#chglist .copy, #overview .cp, .diff .legend .cp { background: #88f }
-#chglist .move, #overview .mv, .diff .legend .mv { background: #ccc }
-#chglist .unknown { background: #fff }
-
-/* Legend for diff and file colors */
-.legend {
- font-size: 9px;
- line-height: 1em;
- padding: .5em 0;
-}
-.legend h3 { display: none; }
-.legend dt {
- background: #fff;
- border: 1px solid #999;
- float: left;
- margin: .1em .5em .1em 0;
- overflow: hidden;
- width: .8em; height: .8em;
-}
-.legend dl {
- display: inline;
- padding: 0;
- margin: 0;
- margin-right: .5em;
-}
-.legend dd {
- display: inline;
- float: left;
- padding: 0;
- margin: 0;
- margin-right: 2em;
-}
-
-#diff-legend {
- float: left;
- clear: right;
- margin: 1em .5em;
-}
-
-#file-legend dd { margin-left: 0; }
-
-/* Styles for the list of diffs */
-.diff ul.entries { clear: both; margin: 0; padding: 0 }
-
-.diff li.entry {
- background: #f7f7f7;
- border: 1px solid #d7d7d7;
- list-style-type: none;
- margin: 0 0 2em;
- padding: 2px;
- position: relative;
- width: 100%;
-}
-.diff h2 {
- color: #333;
- font-size: 14px;
- letter-spacing: normal;
- margin: 0 auto;
- padding: .1em 0 .25em .5em;
-}
-.diff h2 .switch { color: #999; float: right; font-size: 75%;
- line-height: 1.6;
-}
-.diff h2 .switch span { border-left: 1px solid #ccc; cursor: pointer;
- padding: 0 1em;
-}
-.diff h2 .switch span:first-child { border: none; }
-.diff h2 .switch span.active { color: #333; cursor: default; }
-
-/* Styles for the actual diff tables (side-by-side and inline) */
-.diff table {
- border: 1px solid #ddd;
- border-spacing: 0;
- border-top: 0;
- empty-cells: show;
- font-size: 12px;
- line-height: 130%;
- padding: 0;
- margin: 0 auto;
- table-layout: fixed;
- width: 100%;
-}
-.diff table col.lineno { width: 4em }
-.diff table th {
- border-right: 1px solid #d7d7d7;
- border-bottom: 1px solid #998;
- font-size: 11px;
-}
-.diff table thead th {
- background: #eee;
- border-top: 1px solid #d7d7d7;
- color: #999;
- padding: 0 .25em;
- text-align: center;
- white-space: nowrap;
-}
-.diff table tbody th {
- background: #eed;
- color: #886;
- font-weight: normal;
- padding: 0 .5em;
- text-align: right;
- vertical-align: top;
-}
-.diff table tbody td {
- background: #fff;
- font: normal 11px monospace;
- overflow: visible;
- padding: 1px 2px;
- vertical-align: top;
-}
-.diff table tbody.skipped td {
- background: #f7f7f7;
- border: 1px solid #d7d7d7;
-}
-.diff td ins, .diff td del {text-decoration: none;}
-
-/* Styles for the inline diff */
-.diff table.inline tbody.mod td.l, .diff table.inline tbody.rem td.l {
- background: #fdd;
- border-color: #c00;
- border-style: solid;
- border-width: 0 1px 0 1px;
-}
-.diff table.inline tbody.mod td.r, .diff table.inline tbody.add td.r {
- background: #dfd;
- border-color: #0a0;
- border-style: solid;
- border-width: 0 1px 0 1px;
-}
-.diff table.inline tbody.mod tr.first td.l,
-.diff table.inline tbody.rem tr.first td.l { border-top-width: 1px }
-.diff table.inline tbody.mod tr.last td.l,
-.diff table.inline tbody.rem tr.last td.l { border-bottom-width: 1px }
-.diff table.inline tbody.mod tr.first td.r,
-.diff table.inline tbody.add tr.first td.r { border-top-width: 1px }
-.diff table.inline tbody.mod tr.last td.r,
-.diff table.inline tbody.add tr.last td.r { border-bottom-width: 1px }
-.diff table.inline tbody.mod td del {
- background: #e99;
- color: #000;
-}
-.diff table.inline tbody.mod td ins {
- background: #9e9;
- color: #000;
-}
-
-/* Styles for the side-by-side diff */
-.diff table.sidebyside colgroup.content { width: 50% }
-.diff table.sidebyside tbody.mod td.l { background: #fe9 }
-.diff table.sidebyside tbody.mod td.r { background: #fd8 }
-.diff table.sidebyside tbody.add td.l { background: #dfd }
-.diff table.sidebyside tbody.add td.r { background: #cfc }
-.diff table.sidebyside tbody.rem td.l { background: #f88 }
-.diff table.sidebyside tbody.rem td.r { background: #faa }
-.diff table.sidebyside tbody.mod del, .diff table.sidebyside tbody.mod ins {
- background: #fc0;
-}
-
-/* Styles for the plain-text diff view */
-.diff pre { background: #fff; border: 1px solid #ddd; font-size: 85%;
- margin: 0;
-}
diff --git a/sites/static.scrapy.org/css/prefs.css b/sites/static.scrapy.org/css/prefs.css
deleted file mode 100644
index a844e4477..000000000
--- a/sites/static.scrapy.org/css/prefs.css
+++ /dev/null
@@ -1,25 +0,0 @@
-#content.prefs #tabs { list-style: none; margin: 2em 1em 0; padding: 1px; }
-#content.prefs #tabs li { background: #e6e6e6; border: 1px solid;
- border-color: #ccc #666 #ccc #ccc; color: #666; position: relative;
- bottom: -1px; float: left; font-size: 90%; margin: 0 .5em;
- padding: .2em 1em .3em;
-}
-#content.prefs #tabs :link, #content.prefs #tabs :visited {
- border: none; color: #999;
-}
-#content.prefs #tabs :link:hover, #content.prefs #tabs :visited:hover {
- background: transparent; color: #333;
-}
-#content.prefs #tabs li.active { background: #fff;
- border-bottom: 1px solid #fff;
-}
-#content.prefs #tabs #tab_advanced { float: right; }
-#content.prefs #tabcontent { background: url(../vgradient.png) 0 1px repeat-x;
- border-top: 1px solid #ccc; clear: left; padding: 20px 5px;
-}
-* html #content.prefs #tabcontent { padding-top: 0; }
-
-#content.prefs div.field { margin-bottom: 1em; }
-#content.prefs tr.field th { text-align: right; vertical-align: middle;
- white-space: nowrap;
-}
diff --git a/sites/static.scrapy.org/css/report.css b/sites/static.scrapy.org/css/report.css
deleted file mode 100644
index 6f971bafb..000000000
--- a/sites/static.scrapy.org/css/report.css
+++ /dev/null
@@ -1,127 +0,0 @@
-@import url(code.css);
-
-h1 .numrows, h2 .numrows {
- margin-left: 1em;
- color: #999;
- font-size: 65%;
- font-weight: normal;
-}
-h2 {
- background: #f7f7f7;
- border-bottom: 1px solid #d7d7d7;
- margin: 2em 0 0;
- padding: 0 .33em;
-}
-#report-descr { margin: 0 2em; font-size: 90% }
-#report-notfound { margin: 2em; font-size: 110% }
-#content.report .field { margin: 1em 0; }
-#content.report .field label { padding-bottom: .3em; }
-
-#query { clear: right }
-#query fieldset, #query fieldset input, #query fieldset select { font-size: 11px }
-#query fieldset { margin-top: 1em }
-#query fieldset.collapsed {
- border-width: 0;
- margin-bottom: 0pt;
- padding: 0pt .5em;
-}
-#query .option, #query .option input, #query .option select { font-size: 11px }
-#query .option { float: left; line-height: 2em; margin: .9em 2.5em 0 .5em; padding: 0 0 .1em }
-#query .buttons { float: right; margin-top: .5em }
-#query .buttons input { margin: .5em }
-#query hr { clear: both; margin: 0; visibility: hidden }
-
-#filters table { width: 100% }
-#filters tr { height: 2em }
-#filters th, #filters td { padding: 0 .2em; vertical-align: middle }
-#filters th { font-size: 11px; text-align: right; white-space: nowrap; }
-#filters td label { font-size: 11px }
-#filters td.mode { text-align: right }
-#filters td.filter { width: 100% }
-#filters td.filter label { padding-right: 1em }
-#filters td.actions { text-align: right; white-space: nowrap }
-
-#columns div label {
- display: block;
- float: left;
- padding: 0pt 1em .5em 0pt;
-}
-
-/* Styles for the report list and the report results table
- (extends the styles for "table.listing") */
-.reports td.title { width: 100% }
-.reports tbody td :link, .reports tbody td :visited,
-.tickets tbody td :link, .tickets tbody td :visited { display: block }
-.tickets { border-bottom: none }
-.tickets thead th { text-transform: capitalize; white-space: nowrap; }
-.tickets tbody td, .reports tbody td { padding: .1em .5em !important }
-.tickets tbody td a, .reports tbody td a { border-bottom: none }
-.tickets tbody td.id :link, .tickets tbody td.id :visited {
- font-weight: bold;
-}
-.tickets tbody td.time a, .tickets tbody td.changetime a { white-space: nowrap }
-.tickets tbody tr:hover { background: #eed; color: #000 }
-.tickets tr.color1-odd { background: #fdc; border-color: #e88; color: #a22 }
-.tickets tr.color1-even { background: #fed; border-color: #e99; color: #a22 }
-.tickets tr.color2-odd { background: #ffb; border-color: #eea; color: #880 }
-.tickets tr.color2-even { background: #ffd; border-color: #dd8; color: #880 }
-.tickets tr.color3-odd { background: #fbfbfb; border-color: #ddd; color: #444 }
-.tickets tr.color3-even { background: #f6f6f6; border-color: #ccc; color: #333 }
-.tickets tr.color4-odd { background: #e7ffff; border-color: #cee; color: #099 }
-.tickets tr.color4-even { background: #dff; border-color: #bee; color: #099 }
-.tickets tr.color5-odd { background: #e7eeff; border-color: #cde; color: #469 }
-.tickets tr.color5-even { background: #dde7ff; border-color: #cde; color: #469 }
-.tickets tr.color6-odd { background: #f0f0f0; border-color: #ddd; color: #888 }
-.tickets tr.color6-even { background: #f7f7f7; border-color: #ddd; color: #888 }
-.tickets tr.color6-odd a, .color6-even a { color: #b66 }
-.tickets tbody tr.fullrow td, .tickets tbody td.fullrow {
- border: none;
- color: #333;
- background: transparent;
- padding: 0 1em !important; /* Opera 9 is *very* sensitive with this */
- font-size: 85%;
-}
-.tickets tbody tr.fullrow:hover { background: transparent !important }
-.tickets .fullrow :link, .tickets .fullrow :visited { display: inline }
-.tickets .fullrow .meta { color: #999; }
-.tickets .fullrow hr { display: none }
-
-fieldset legend :link, fieldset legend :visited {
- background: url(../expanded.png) 0 50% no-repeat;
- border: none;
- color: #666;
- font-size: 110%;
- padding-left: 16px;
-}
-fieldset legend :link:hover, fieldset legend :visited:hover {
- background-color: transparent;
-}
-
-fieldset.collapsed legend :link, fieldset.collapsed legend :visited {
- background-image: url(../collapsed.png);
-}
-fieldset.collapsed table, fieldset.collapsed div { display: none }
-
-/* Query results table */
-
-table.tickets tbody tr.added td { font-weight: bold }
-table.tickets tbody tr.changed td { font-style: italic }
-table.tickets tbody tr.removed td { color: #999 }
-table.tickets tbody tr.prio1 { background: #fdc; border-color: #e88 }
-table.tickets tbody tr.even.prio1 { background: #fed; border-color: #e99 }
-table.tickets tbody tr.prio2 { background: #ffb; border-color: #eea }
-table.tickets tbody tr.even.prio2 { background: #ffd; border-color: #dd8 }
-table.tickets tbody tr.prio3 { background: #fbfbfb; border-color: #ddd }
-table.tickets tbody tr.even.prio3 { background: #f6f6f6; border-color: #ccc }
-table.tickets tbody tr.prio4 { background: #e7ffff; border-color: #cee }
-table.tickets tbody tr.even.prio4 { background: #dff; border-color: #bee }
-table.tickets tbody tr.prio5 { background: #e7eeff; border-color: #cde }
-table.tickets tbody tr.even.prio5 { background: #dde7ff }
-table.tickets tbody tr.prio6 { background: #f0f0f0; border-color: #ddd }
-table.tickets tbody tr.even.prio6 { background: #f7f7f7 }
-table.tickets tbody tr.fullrow th {
- border: none;
- vertical-align: middle;
- text-align: center;
- font-size: 85%;
-}
diff --git a/sites/static.scrapy.org/css/roadmap.css b/sites/static.scrapy.org/css/roadmap.css
deleted file mode 100644
index 0acf34f63..000000000
--- a/sites/static.scrapy.org/css/roadmap.css
+++ /dev/null
@@ -1,84 +0,0 @@
-/* General styles for the progress bars */
-table.progress {
- border: 1px solid #d7d7d7;
- border-collapse: collapse;
- border-spacing: 0;
- float: left;
- margin: 0;
- padding: 0;
- empty-cells: show;
-}
-table.progress a, table.progress :link, table.progress :visited,
-table.progress :link:hover, table.progress :visited:hover {
- border: none;
- display: block;
- width: 100%;
- height: 1.2em;
- padding: 0;
- margin: 0;
- text-decoration: none
-}
-table.progress td { background: #fff; padding: 0 }
-table.progress td.new { background: #f5f5b5 }
-table.progress td.closed { background: #bae0ba }
-table.progress td :hover { background: none }
-p.percent { font-size: 10px; line-height: 2.4em; margin: 0.9em 0 0 }
-
-/* Styles for the roadmap view */
-ul.milestones { margin: 2em 0 0; padding: 0 }
-li.milestone { list-style: none; margin-bottom: 4em }
-.milestone .info { white-space: nowrap }
-.milestone .info h2 {
- background: #f7f7f7;
- border-bottom: 1px solid #d7d7d7;
- margin: 0;
-}
-.milestone .info h2 :link, .milestone .info h2 :visited {
- color: #000;
- display: block;
- border-bottom: none;
-}
-.milestone .info h2 :link:hover, .milestone .info h2 :visited:hover {
- color: #000;
-}
-.milestone .info h2 em { color: #b00; font-style: normal }
-.milestone .info .date {
- color: #888;
- font-size: 11px;
- font-style: italic;
- margin: 0;
-}
-.milestone .info .progress { margin: 1em 1em 0; width: 40em; max-width: 70% }
-.milestone .info dl {
- font-size: 10px;
- font-style: italic;
- margin: 0 1em 2em;
- white-space: nowrap;
-}
-.milestone .info dt { display: inline; margin-left: .5em }
-.milestone .info dd { display: inline; margin: 0 1em 0 .5em }
-.milestone .description { margin-left: 1em }
-
-/* Styles for the milestone view */
-.milestone .date { color: #888; font-style: italic; margin: 0 }
-.milestone .description { margin: 1em 0 2em }
-
-/* Styles for the milestone statistics table */
-#stats { float: right; margin: 0 0 2em 2em; width: 400px; max-width: 40% }
-#stats legend { white-space: nowrap }
-#stats table { border-collapse: collapse; width: 100% }
-#stats th, #stats td { font-size: 10px; padding: 0; white-space: nowrap }
-#stats th { text-align: right; }
-#stats th :link, #stats th :visited { border: none }
-#stats td { padding-left: 0.5em; width: 100% }
-#stats td table.progress { margin: 3px 4px 3px 0 }
-#stats td table.progress td { padding: 0 }
-#stats td p.percent { line-height: 1.2em; margin-top: 3px }
-
-/* Styles for the milestone edit form */
-#edit fieldset { margin: 1em 0 }
-#edit em { color: #888; font-size: smaller }
-#edit .disabled em { color: #d7d7d7 }
-#edit .field { margin-top: 1.3em }
-#edit label { padding-left: .2em }
-#edit textarea#description { width: 97% }
diff --git a/sites/static.scrapy.org/css/search.css b/sites/static.scrapy.org/css/search.css
deleted file mode 100644
index e7fdd531b..000000000
--- a/sites/static.scrapy.org/css/search.css
+++ /dev/null
@@ -1,14 +0,0 @@
-#content.search .filters { color: #333; font-size: 85%; }
-
-#content.search form { margin: 1em 0 0 }
-#content.search form p { margin: .5em 0 }
-#content.search hr { clear: left; margin-bottom: 0 }
-#content.search #notfound { margin: 2em; font-size: 110% }
-
-#content.search #results { margin-right: 3em }
-#content.search #results dt { margin: 1.5em 0 0 }
-#content.search #results dt a { color: #33c }
-#content.search #results dd { font-size: 80%; margin: 0; padding: 0 }
-#content.search #results .author, #results .date { color: #090; }
-
-#content.search #quickjump { font-style: italic; font-weight: bold; }
diff --git a/sites/static.scrapy.org/css/ticket.css b/sites/static.scrapy.org/css/ticket.css
deleted file mode 100644
index 08c64bc5e..000000000
--- a/sites/static.scrapy.org/css/ticket.css
+++ /dev/null
@@ -1,115 +0,0 @@
-@import url(code.css);
-
-#content.ticket { width: 700px; max-width: 100% }
-
-#newticket #field-description { width: 100% }
-#newticket #properties { width: 100% }
-
-#ticket {
- background: #ffd;
- border: 1px outset #996;
- margin-top: 1em;
- padding: .5em 1em;
- position: relative;
-}
-
-div#ticket.ticketdraft {
- background: #f4f4f4 url(../draft.png);
-}
-div#ticketchange.ticketdraft {
- padding: 0 1em;
- margin: 1em 0;
-}
-div#ticketchange.ticketdraft h3 {
- margin-top: .5em;
-}
-.preview-notice { font-weight: bold; }
-
-.ticketdraft {
- background: #f4f4f4 url(../draft.png);
- border: 1px outset #996;
- padding: 0 .2em;
-}
-
-h1 .status { color: #444; }
-#ticket h2.summary { margin: 0 0 .8em 0 }
-#ticket .date { color: #996; float: right; font-size: 85%; position: relative }
-#ticket .date p { margin: .3em }
-
-#ticket table.properties {
- clear: both;
- border-top: 1px solid #dd9;
- border-collapse: collapse;
- table-layout: fixed;
- width: 100%;
-}
-#ticket table.properties tr { border-bottom: 1px dotted #eed }
-#ticket table.properties td, #ticket table.properties th {
- font-size: 80%;
- padding: .5em 1em;
- vertical-align: top;
-}
-#ticket table.properties th {
- color: #663;
- font-weight: normal;
- text-align: left;
- width: 20%;
-}
-#ticket table.properties td { width: 30% }
-#ticket table.properties .description { border-top: 1px solid #dd9 }
-
-#ticket .description h3 {
- border-bottom: 1px solid #dd9;
- color: #663;
- font-size: 100%;
- font-weight: normal;
-}
-#ticket .description h3 .lastmod {
- font-size: 90%;
-}
-#ticket .inlinebuttons {
- float: right;
- position: relative;
- bottom: 0.3em;
-}
-
-#changelog { border: 1px outset #996; padding: 1em }
-#preview { border: 1px solid #d7d7d7; padding: 1em }
-#preview h3, #changelog h3 {
- border-bottom: 1px solid #d7d7d7;
- color: #999;
- font-size: 100%;
- font-weight: normal;
-}
-.threading, #changelog .inlinebuttons { float: right; }
-.threading { font-size: 90%; }
-
-#preview .changes, #changelog .changes { list-style: square; margin-left: 2em; padding: 0 }
-#preview .comment, #changelog .comment { margin-left: 2em }
-
-form .field { margin-top: .75em; width: 100% }
-form #comment { width: 100% }
-
-#properties { white-space: nowrap; line-height: 160%; padding: .5em }
-#properties table { border-spacing: 0; width: 100%; }
-#properties table th {
- padding: .4em;
- text-align: right;
- width: 20%;
- vertical-align: top;
-}
-#properties table th.col2 { border-left: 1px dotted #d7d7d7 }
-#properties table td { vertical-align: middle; width: 30% }
-#properties table td.fullrow { vertical-align: middle; width: 80% }
-
-#action { line-height: 2em }
-
-fieldset.radio { border: none; margin: 0; padding: 0 }
-fieldset.radio legend {
- color: #000;
- float: left;
- font-size: 100%;
- font-weight: normal;
- padding: 0 1em 0 0;
-}
-fieldset.radio label { padding-right: 1em }
diff --git a/sites/static.scrapy.org/css/timeline.css b/sites/static.scrapy.org/css/timeline.css
deleted file mode 100644
index c0af15cde..000000000
--- a/sites/static.scrapy.org/css/timeline.css
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Timeline */
-
-* html #prefs { width: 34em } /* Set width only for IE */
-#prefs fieldset label { display: block }
-#prefs .buttons { margin-top: -1.6em }
-
-h2 {
- background: #f7f7f7;
- border-bottom: 1px solid #d7d7d7;
- font-size: 105%;
- margin: 2em 0 .5em;
-}
-dl { line-height: 1.3em; margin-left: 1em }
-dt { background: 3px 4px no-repeat; padding: 0 }
-dt :link, dt :visited {
- background: 3px 3px no-repeat;
- border: none;
- color: #000;
- padding: 0 4px 2px 22px;
-}
-dt>:link, dt>:visited {
- /* Hide from IE/Win */
- background-position: 3px 4px;
-}
-dt :link:hover, dt :visited:hover { background-color: #eed; color: #000 }
-dt em {
- border-bottom: 1px dotted #bbb;
- color: #b00;
- font-style: normal;
- text-decoration: none;
-}
-dt .time { color: #999; font-size: 80%; }
-dt .author { color: #666; }
-dt.highlight { background-color: #ffa; }
-dd {
- font-size: 80%;
- margin: 0 0 .75em 5.5em;
- padding: 0;
- color: #776;
-}
-
-/* Apply icon background-image twice to avoid hover-flicker in IE/Win */
-dt.changeset, dt.changeset a { background-image: url(../changeset.png) !important }
-dt.newticket, dt.newticket a { background-image: url(../newticket.png) !important }
-dt.reopenedticket, dt.reopenedticket a { background-image: url(../newticket.png) !important }
-dt.editedticket, dt.editedticket a { background-image: url(../editedticket.png) !important }
-dt.closedticket, dt.closedticket a { background-image: url(../closedticket.png) !important }
-dt.wiki, dt.wiki a { background-image: url(../wiki.png) !important }
-dt.milestone, dt.milestone a { background-image: url(../milestone.png) !important }
-dt.attachment, dt.attachment a { background-image: url(../attachment.png) !important }
-
-/* styles for the 'changeset_long_messages' option */
-dd.changeset p { margin: 0; padding: 0 }
-dd.changeset ul { padding-left: 15px; }
-
-/* Styles for the 'changeset_show_files' option */
-dd.changeset .changes { color: #aaa; font-size: 90%; }
-dd.changeset ul.changes {
- padding-left: 0;
- list-style-type: none;
-}
-dd.changeset .changes li div {
- border: 1px solid #999;
- float: left;
- margin: .5em .5em 0 0;
- overflow: hidden;
- width: .8em; height: .8em;
-}
-dd.changeset .changes li span {
- float: left;
- margin-right: .8em;
-}
-dd.changeset .changes .add { background: #bfb }
-dd.changeset .changes .delete { background: #f88 }
-dd.changeset .changes .edit { background: #fd8 }
-dd.changeset .changes .copy { background: #88f }
-dd.changeset .changes .move { background: #ccc }
diff --git a/sites/static.scrapy.org/css/trac-0.11rc2.css.diff b/sites/static.scrapy.org/css/trac-0.11rc2.css.diff
deleted file mode 100644
index f313debf8..000000000
--- a/sites/static.scrapy.org/css/trac-0.11rc2.css.diff
+++ /dev/null
@@ -1,13 +0,0 @@
-1c1,6
-< body { background: #fff; color: #000; margin: 10px; padding: 0; }
----
-> body {
-> background: #FFFFFF url('/scrapy/chrome/site/main-bg.jpg') repeat-x left top;
-> color: #000;
-> margin: 10px;
-> padding: 0;
-> }
-113a119,121
-> #header {
-> margin-top: 42px;
-> }
diff --git a/sites/static.scrapy.org/css/trac.css b/sites/static.scrapy.org/css/trac.css
deleted file mode 100644
index 3686b2627..000000000
--- a/sites/static.scrapy.org/css/trac.css
+++ /dev/null
@@ -1,587 +0,0 @@
-body {
- background: #FFFFFF url('/main-bg.jpg') repeat-x left top;
- color: #000;
- margin: 10px;
- padding: 0;
-}
-body, th, td {
- color:#333333;
- font-family:"Lucida Sans",Verdana,Helvetica,sans-serif; font-size:small;
-}
-h1, h2, h3, h4 {
- font-family:"Lucida Sans",Verdana,Helvetica,sans-serif;
- font-weight: bold;
- color:#331F0A;
- page-break-after: avoid;
-}
-h1 { font-size: 22px; margin: .15em 1em 0.5em 0 }
-h2 { font-size: 18px }
-h3 { font-size: 16px }
-hr { border: none; border-top: 1px solid #ccb; margin: 2em 0 }
-address { font-style: normal }
-img { border: none }
-
-.underline { text-decoration: underline }
-ol.loweralpha { list-style-type: lower-alpha }
-ol.upperalpha { list-style-type: upper-alpha }
-ol.lowerroman { list-style-type: lower-roman }
-ol.upperroman { list-style-type: upper-roman }
-ol.arabic { list-style-type: decimal }
-
-/* Link styles */
-:link, :visited {
- text-decoration: none;
-
-border-bottom:1px solid #D78888;
-color:#6E0909;
-}
-:link:hover, :visited:hover { color:#c35012; }
-h1 :link, h1 :visited ,h2 :link, h2 :visited, h3 :link, h3 :visited,
-h4 :link, h4 :visited, h5 :link, h5 :visited, h6 :link, h6 :visited {
- color: inherit;
-}
-
-/* Heading anchors */
-.anchor:link, .anchor:visited {
- border: none;
- color: #d7d7d7;
- font-size: .8em;
- vertical-align: text-top;
-}
-* > .anchor:link, * > .anchor:visited {
- visibility: hidden;
-}
-h1:hover .anchor, h2:hover .anchor, h3:hover .anchor,
-h4:hover .anchor, h5:hover .anchor, h6:hover .anchor {
- visibility: visible;
-}
-
-@media screen {
- a.ext-link .icon {
- background: url(../extlink.gif) left center no-repeat;
- padding-left: 16px;
- }
- a.mail-link .icon {
- background: url(../envelope.png) left center no-repeat;
- padding-left: 16px;
- }
-}
-
-/* Forms */
-input, textarea, select { margin: 2px }
-input, select { vertical-align: middle }
-input[type=button], input[type=submit], input[type=reset] {
- background: #eee;
- color: #222;
- border: 1px outset #ccc;
- padding: .1em .5em;
-}
-input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
- background: #ccb;
-}
-input[type=button][disabled], input[type=submit][disabled],
-input[type=reset][disabled] {
- background: #f6f6f6;
- border-style: solid;
- color: #999;
-}
-input[type=text], input.textwidget, textarea { border: 1px solid #d7d7d7 }
-input[type=text], input.textwidget { padding: .25em .5em }
-input[type=text]:focus, input.textwidget:focus, textarea:focus {
- border: 1px solid #886;
-}
-option { border-bottom: 1px dotted #d7d7d7 }
-fieldset { border: 1px solid #d7d7d7; padding: .5em; margin: 1em 0 }
-form p.hint, form span.hint { color: #666; font-size: 85%; font-style: italic; margin: .5em 0;
- padding-left: 1em;
-}
-fieldset.iefix {
- background: transparent;
- border: none;
- padding: 0;
- margin: 0;
-}
-* html fieldset.iefix { width: 98% }
-fieldset.iefix p { margin: 0 }
-legend { color: #999; padding: 0 .25em; font-size: 90%; font-weight: bold }
-label.disabled { color: #d7d7d7 }
-.buttons { margin: .5em .5em .5em 0 }
-.buttons form, .buttons form div { display: inline }
-.buttons input { margin: 1em .5em .1em 0 }
-.inlinebuttons input {
- font-size: 70%;
- border-width: 1px;
- border-style: dotted;
- margin: 0 .1em;
- padding: 0.1em;
- background: none;
-}
-
-/* Header */
-#header {
- margin-top: 42px;
-}
-#header hr { display: none }
-#header h1 { margin: 1.5em 0 -1.5em; }
-#header img { border: none; margin: 0 0 -3em }
-* html #header img { margin-top:-10px }
-* +html #header img { margin-top:-10px }
-#header :link, #header :visited, #header :link:hover, #header :visited:hover {
- background: transparent;
- color: #555;
- margin-bottom: 2px;
- border: none;
-}
-#header h1 :link:hover, #header h1 :visited:hover { color: #000 }
-
-/* Quick search */
-#search {
- clear: both;
- font-size: 10px;
- height: 2.2em;
- margin: 0 0 1em;
- text-align: right;
-}
-#search input { font-size: 10px }
-#search label { display: none }
-
-/* Navigation */
-.nav h2, .nav hr { display: none }
-.nav ul { font-size: 12px; list-style: none; margin:0; text-align: right }
-.nav li {
- border-right: 1px solid #d7d7d7;
- display: inline;
- padding: 0 .75em;
- white-space: nowrap;
-}
-.nav li.last { border-right: none }
-.nav ul a { color:#E57919;;
- border-bottom: 1px solid #FFCA9B; }
-/* Main navigation bar */
-#mainnav {
- /* background: #f7f7f7 url(../topbar_gradient.png) 0 0; */
- border:1px solid #FFDDCC;;
- font: normal 10px 'Lucida Sans','Bitstream Vera Sans',helvetica,arial,sans-serif;
- margin: 1em 0 .66em;
- padding: .5em;
-}
-#mainnav li { border-right: none; padding: .25em 0; font-size:12px; }
-#mainnav :link, #mainnav :visited {
- /* background: url(../dots.gif) 0 0 no-repeat;
- border-right: 1px solid #fff;
- border-left: 1px solid #555; */
- border-bottom: none;
- color: #ae3413;
- padding: .2em 20px;
-}
-* html #mainnav :link, * html #mainnav :visited { background-position: 1px 0 }
-#mainnav :link:hover, #mainnav :visited:hover {
- background-color: #fff3ca;
-
-}
-#mainnav .active :link, #mainnav .active :visited {
- background-color: #ae3413 ;
- border-top: none;
- /* border-right: 1px solid #000; */
- color: #FFF;
- font-weight: bold;
-}
-#mainnav .active :link:hover, #mainnav .active :visited:hover {
- /* border-right: 1px solid #000; */
-}
-
-/* Context-dependent navigation links */
-#ctxtnav { height: 1em }
-#ctxtnav li ul {
- background: #f7f7f7;
- color: #ccc;
- border: 1px solid;
- padding: 0;
- display: inline;
- margin: 0;
-}
-#ctxtnav li li { padding: 0; }
-#ctxtnav li li :link, #ctxtnav li li :visited { padding: 0 1em }
-#ctxtnav li li :link:hover, #ctxtnav li li :visited:hover {
- background: #bba;
- color: #fff;
-}
-
-/* Alternate links */
-#altlinks { clear: both; text-align: center }
-#altlinks h3 { font-size: 12px; letter-spacing: normal; margin: 0 }
-#altlinks ul { list-style: none; margin: 0; padding: 0 0 1em }
-#altlinks li {
- border-right: 1px solid #d7d7d7;
- display: inline;
- font-size: 11px;
- line-height: 1.5;
- padding: 0 1em;
- white-space: nowrap;
-}
-#altlinks li.last { border-right: none }
-#altlinks li :link, #altlinks li :visited {
- background-repeat: no-repeat;
- color: #666;
- border: none;
- padding: 0 0 2px;
-}
-#altlinks li a.ics { background-image: url(../ics.png); padding-left: 22px }
-#altlinks li a.rss { background-image: url(../feed.png); padding-left: 20px }
-
-/* Footer */
-#footer {
- clear: both;
- color: #bbb;
- font-size: 10px;
- border-top: 1px solid;
- height: 31px;
- padding: .25em 0;
-}
-#footer :link, #footer :visited { color: #bbb; }
-#footer hr { display: none }
-#footer #tracpowered { border: 0; float: left }
-#footer #tracpowered:hover { background: transparent }
-#footer p { margin: 0 }
-#footer p.left {
- float: left;
- margin-left: 1em;
- padding: 0 1em;
- border-left: 1px solid #d7d7d7;
- border-right: 1px solid #d7d7d7;
-}
-#footer p.right {
- float: right;
- text-align: right;
-}
-
-#content { padding-bottom: 2em; position: relative }
-
-#help {
- clear: both;
- color: #999;
- font-size: 90%;
- margin: 1em;
- text-align: right;
-}
-#help :link, #help :visited { cursor: help }
-#help hr { display: none }
-
-/* Page preferences form */
-#prefs {
- background: #f7f7f0;
- border: 1px outset #998;
- float: right;
- font-size: 9px;
- padding: .8em;
- position: relative;
- margin: 0 1em 1em;
-}
-* html #prefs { width: 26em } /* Set width only for IE */
-#prefs input, #prefs select { font-size: 9px; vertical-align: middle }
-#prefs fieldset {
- background: transparent;
- border: none;
- margin: .5em;
- padding: 0;
-}
-#prefs fieldset legend {
- background: transparent;
- color: #000;
- font-size: 9px;
- font-weight: normal;
- margin: 0 0 0 -1.5em;
- padding: 0;
-}
-#prefs .buttons { text-align: right }
-
-/* Version information (browser, wiki, attachments) */
-#info {
- margin: 1em 0 0 0;
- background: #f7f7f0;
- border: 1px solid #d7d7d7;
- border-collapse: collapse;
- border-spacing: 0;
- clear: both;
- width: 100%;
-}
-#info th, #info td { font-size: 85%; padding: 2px .5em; vertical-align: top }
-#info th { font-weight: bold; text-align: left; white-space: nowrap }
-#info td.message { width: 100% }
-#info .message ul { padding: 0; margin: 0 2em }
-#info .message p { margin: 0; padding: 0 }
-
-/* Wiki */
-.wikipage { padding-left: 18px }
-.wikipage h1, .wikipage h2, .wikipage h3 { margin-left: -18px }
-
-a.missing:link, a.missing:visited, span.missing { color: #998 }
-a.missing:link, a.missing:visited { background: #fafaf0 }
-a.missing:hover { color: #000 }
-a.closed:link, a.closed:visited { text-decoration: line-through }
-span.closed { text-decoration: line-through }
-span.forbidden, a.forbidden { background: #fafaf0; color: #998; }
-
-/* User-selectable styles for blocks */
-.important {
- background: #fcb;
- border: 1px dotted #d00;
- color: #500;
- padding: 0 .5em 0 .5em;
- margin: .5em;
-}
-
-dl.wiki dt { font-weight: bold }
-dl.compact dt { float: left; padding-right: .5em }
-dl.compact dd { margin: 0; padding: 0 }
-
-pre.wiki, pre.literal-block {
- background: #f7f7f7;
- border: 1px solid #d7d7d7;
- margin: 1em 1.75em;
- padding: .25em;
- overflow: auto;
-}
-
-blockquote.citation {
- margin: -0.6em 0;
- border-style: solid;
- border-width: 0 0 0 2px;
- padding-left: .5em;
- border-color: #b44;
-}
-.citation blockquote.citation { border-color: #4b4; }
-.citation .citation blockquote.citation { border-color: #44b; }
-.citation .citation .citation blockquote.citation { border-color: #c55; }
-
-table.wiki {
- border: 2px solid #ccc;
- border-collapse: collapse;
- border-spacing: 0;
-}
-table.wiki td { border: 1px solid #ccc; padding: .1em .25em; }
-
-.wikitoolbar {
- border: solid #d7d7d7;
- border-width: 1px 1px 1px 0;
- height: 18px;
- width: 234px;
-}
-.wikitoolbar :link, .wikitoolbar :visited {
- background: transparent url(../edit_toolbar.png) no-repeat;
- border: 1px solid #fff;
- border-left-color: #d7d7d7;
- cursor: default;
- display: block;
- float: left;
- width: 24px;
- height: 16px;
-}
-.wikitoolbar :link:hover, .wikitoolbar :visited:hover {
- background-color: transparent;
- border: 1px solid #fb2;
-}
-.wikitoolbar a#em { background-position: 0 0 }
-.wikitoolbar a#strong { background-position: 0 -16px }
-.wikitoolbar a#heading { background-position: 0 -32px }
-.wikitoolbar a#link { background-position: 0 -48px }
-.wikitoolbar a#code { background-position: 0 -64px }
-.wikitoolbar a#hr { background-position: 0 -80px }
-.wikitoolbar a#np { background-position: 0 -96px }
-.wikitoolbar a#br { background-position: 0 -112px }
-.wikitoolbar a#img { background-position: 0 -128px }
-
-/* Styles for the form for adding attachments. */
-#attachment .field { margin-top: 1.3em }
-#attachment label { padding-left: .2em }
-#attachment fieldset { margin-top: 2em }
-#attachment fieldset .field { float: left; margin: 0 1em .5em 0 }
-#attachment .options { float: left; padding: 0 0 1em 1em }
-#attachment br { clear: left }
-.attachment #preview { margin-top: 1em }
-
-/* Styles for the list of attachments. */
-#attachments { border: 1px outset #996; padding: 1em }
-#attachments .attachments { margin-left: 2em; padding: 0 }
-#attachments dt { display: list-item; list-style: square; }
-#attachments dd { font-style: italic; margin-left: 0; padding-left: 0; }
-
-/* Styles for tabular listings such as those used for displaying directory
- contents and report results. */
-table.listing {
- clear: both;
- border-bottom: 1px solid #d7d7d7;
- border-collapse: collapse;
- border-spacing: 0;
- margin-top: 1em;
- width: 100%;
-}
-table.listing th { text-align: left; padding: 0 1em .1em 0; font-size: 12px }
-table.listing thead { background: #f7f7f0 }
-table.listing thead th {
- border: 1px solid #d7d7d7;
- border-bottom-color: #999;
- font-size: 11px;
- font-weight: bold;
- padding: 2px .5em;
- vertical-align: bottom;
-}
-table.listing thead th :link:hover, table.listing thead th :visited:hover {
- background-color: transparent;
-}
-table.listing thead th a { border: none; padding-right: 12px }
-table.listing th.asc a, table.listing th.desc a { font-weight: bold }
-table.listing th.asc a, table.listing th.desc a {
- background-position: 100% 50%;
- background-repeat: no-repeat;
-}
-table.listing th.asc a { background-image: url(../asc.png) }
-table.listing th.desc a { background-image: url(../desc.png) }
-table.listing tbody td, table.listing tbody th {
- border: 1px dotted #ddd;
- padding: .3em .5em;
- vertical-align: top;
-}
-table.listing tbody td a:hover, table.listing tbody th a:hover {
- background-color: transparent;
-}
-table.listing tbody tr { border-top: 1px solid #ddd }
-table.listing tbody tr.even { background-color: #fcfcfc }
-table.listing tbody tr.odd { background-color: #f7f7f7 }
-table.listing tbody tr:hover { background: #eed !important }
-table.listing tbody tr.focus { background: #ddf !important }
-
-/* Styles for the page history table
- (extends the styles for "table.listing") */
-#fieldhist td { padding: 0 .5em }
-#fieldhist td.date, #fieldhist td.diff, #fieldhist td.version,
-#fieldhist td.author {
- white-space: nowrap;
-}
-#fieldhist td.version { text-align: center }
-#fieldhist td.comment { width: 100% }
-
-/* Auto-completion interface */
-.suggestions { background: #fff; border: 1px solid #886; color: #222; }
-.suggestions ul {
- font-family: sans-serif;
- max-height: 20em;
- min-height: 3em;
- list-style: none;
- margin: 0;
- overflow: auto;
- padding: 0;
- width: 440px;
-}
-* html .suggestions ul { height: 10em; }
-.suggestions li { background: #fff; cursor: pointer; padding: 2px 5px }
-.suggestions li.selected { background: #b9b9b9 }
-
-/* Styles for the error page (and rst errors) */
-#content.error .message, div.system-message {
- background: #fdc;
- border: 2px solid #d00;
- color: #500;
- padding: .5em;
- margin: 1em 0;
-}
-#content.error div.message pre, div.system-message pre {
- margin-left: 1em;
- overflow: hidden;
- white-space: normal;
-}
-div.system-message p { margin: 0; }
-div.system-message p.system-message-title { font-weight: bold; }
-
-#warning.system-message { background: #ffa; border: 2px solid #886; }
-#warning.system-message li { list-style-type: square; }
-
-#notice.system-message { background: #bfb; border: 2px solid #484; }
-#notice.system-message li { list-style-type: square; }
-
-#content.error form.newticket { display: inline; }
-#content.error form.newticket textarea { display: none; }
-
-#content.error #systeminfo { margin: 1em; width: auto; }
-#content.error #systeminfo th { font-weight: bold; text-align: right; }
-
-#content.error #traceback { margin-left: 1em; }
-#content.error #traceback :link, #content.error #traceback :visited {
- border: none;
-}
-#content.error #tbtoggle { font-size: 80%; }
-#content.error #traceback div { margin-left: 1em; }
-#content.error #traceback h3 { font-size: 95%; margin: .5em 0 0; }
-#content.error #traceback :link var, #content.error #traceback :visited var {
- font-family: monospace;
- font-style: normal;
- font-weight: bold;
-}
-#content.error #traceback span.file { color: #666; font-size: 85%; }
-#content.error #traceback ul { list-style: none; margin: .5em 0; padding: 0; }
-#content.error #traceback ol {
- border: 1px dotted #d7d7d7;
- color: #999;
- font-size: 85%;
- line-height: 1;
- margin: .5em 0;
-}
-#content.error #traceback ol li { white-space: pre; }
-#content.error #traceback ol li.current { background: #e6e6e6; color: #333; }
-#content.error #traceback ol li code { color: #666; }
-#content.error #traceback ol li.current code { color: #000; }
-#content.error #traceback table { margin: .5em 0 1em; }
-#content.error #traceback th, #content.error #traceback td {
- font-size: 85%; padding: 1px;
-}
-#content.error #traceback th var {
- font-family: monospace;
- font-style: normal;
-}
-#content.error #traceback td code { white-space: pre; }
-#content.error #traceback pre { font-size: 95%; }
-
-#content .paging { margin: 0 0 2em; padding: .5em 0 0;
- font-size: 85%; line-height: 2em; text-align: center;
-}
-#content .paging .current {
- padding: .1em .3em;
- border: 1px solid #333;
- background: #999; color: #fff;
-}
-
-#content .paging :link, #content .paging :visited {
- padding: .1em .3em;
- border: 1px solid #666;
- background: transparent; color: #666;
-}
-#content .paging :link:hover, #content .paging :visited:hover {
- background: #999; color: #fff; border-color: #333;
-}
-#content .paging .previous a,
-#content .paging .next a {
- font-size: 150%; font-weight: bold; border: none;
-}
-#content .paging .previous a:hover,
-#content .paging .next a:hover {
- background: transparent; color: #666;
-}
-
-#content h2 .numresults { color: #666; font-size: 90%; }
-
-/* Styles for search word highlighting */
-@media screen {
- .searchword0 { background: #ff9 }
- .searchword1 { background: #cfc }
- .searchword2 { background: #cff }
- .searchword3 { background: #ccf }
- .searchword4 { background: #fcf }
-}
-
-@media print {
- #header, #altlinks, #footer, #help { display: none }
- .nav, form, .buttons form, form .buttons, form .inlinebuttons {
- display: none;
- }
- form.printableform { display: block }
-}
diff --git a/sites/static.scrapy.org/css/wiki.css b/sites/static.scrapy.org/css/wiki.css
deleted file mode 100644
index 90f5deeab..000000000
--- a/sites/static.scrapy.org/css/wiki.css
+++ /dev/null
@@ -1,44 +0,0 @@
-@import url(code.css);
-
-/* Styles for the page editing form */
-#edit #rows { float: right; font-size: 80% }
-#edit #rows select { font-size: 90% }
-#edit #text { clear: both; width: 100% }
-#edit .wikitoolbar { float: left; }
-#changeinfo { padding: .5em }
-#changeinfo .field { float: left; margin: 0 1em .5em 0 }
-#changeinfo br { clear: left }
-#changeinfo .options { padding: 0 0 1em 1em }
-#changeinfo .options, #changeinfo .buttons { clear: left }
-#delete, #save { margin-left: 6em }
-#preview {
- background: #f4f4f4 url(../draft.png);
- margin: 1em 0 2em;
- overflow: auto;
-}
-#template { vertical-align: middle; padding-top: 1em; }
-
-/* Diff view */
-#overview .multi { color: #999 }
-#overview .ipnr { color: #999; font-size: 80% }
-#overview .comment { padding: 1em 0 0 }
-
-@media print {
- th.diff, td.diff { display: none }
-}
-
-/* Styles for the TracGuideToc wikimacro */
-.wiki-toc {
- padding: .5em 1em;
- margin: 0 0 2em 1em;
- float: right;
- border: 1px outset #ddc;
- background: #ffd;
- font-size: 85%;
- position: relative;
-}
-.wiki-toc h4 { font-size: 12px; margin: 0 }
-.wiki-toc ul, .wiki-toc ol { list-style: none; padding: 0; margin: 0 }
-.wiki-toc ul ul, .wiki-toc ol ol { padding-left: 1.2em }
-.wiki-toc li { margin: 0; padding: 0 }
-.wiki-toc .active { background: #ff9; position: relative; }
diff --git a/sites/static.scrapy.org/desc.png b/sites/static.scrapy.org/desc.png
deleted file mode 100644
index 207018551..000000000
Binary files a/sites/static.scrapy.org/desc.png and /dev/null differ
diff --git a/sites/static.scrapy.org/dots.gif b/sites/static.scrapy.org/dots.gif
deleted file mode 100644
index c6ae052fe..000000000
Binary files a/sites/static.scrapy.org/dots.gif and /dev/null differ
diff --git a/sites/static.scrapy.org/draft.png b/sites/static.scrapy.org/draft.png
deleted file mode 100644
index cd6a67a55..000000000
Binary files a/sites/static.scrapy.org/draft.png and /dev/null differ
diff --git a/sites/static.scrapy.org/edit_toolbar.png b/sites/static.scrapy.org/edit_toolbar.png
deleted file mode 100644
index 1269b3fb9..000000000
Binary files a/sites/static.scrapy.org/edit_toolbar.png and /dev/null differ
diff --git a/sites/static.scrapy.org/editedticket.png b/sites/static.scrapy.org/editedticket.png
deleted file mode 100644
index 9d12a9107..000000000
Binary files a/sites/static.scrapy.org/editedticket.png and /dev/null differ
diff --git a/sites/static.scrapy.org/envelope.png b/sites/static.scrapy.org/envelope.png
deleted file mode 100644
index 74676b359..000000000
Binary files a/sites/static.scrapy.org/envelope.png and /dev/null differ
diff --git a/sites/static.scrapy.org/expanded.png b/sites/static.scrapy.org/expanded.png
deleted file mode 100644
index 4f8a587f7..000000000
Binary files a/sites/static.scrapy.org/expanded.png and /dev/null differ
diff --git a/sites/static.scrapy.org/expander_normal.png b/sites/static.scrapy.org/expander_normal.png
deleted file mode 100644
index fb580df47..000000000
Binary files a/sites/static.scrapy.org/expander_normal.png and /dev/null differ
diff --git a/sites/static.scrapy.org/expander_normal_hover.png b/sites/static.scrapy.org/expander_normal_hover.png
deleted file mode 100644
index e3a866c4b..000000000
Binary files a/sites/static.scrapy.org/expander_normal_hover.png and /dev/null differ
diff --git a/sites/static.scrapy.org/expander_open.png b/sites/static.scrapy.org/expander_open.png
deleted file mode 100644
index a4c90a29e..000000000
Binary files a/sites/static.scrapy.org/expander_open.png and /dev/null differ
diff --git a/sites/static.scrapy.org/expander_open_hover.png b/sites/static.scrapy.org/expander_open_hover.png
deleted file mode 100644
index 255064b89..000000000
Binary files a/sites/static.scrapy.org/expander_open_hover.png and /dev/null differ
diff --git a/sites/static.scrapy.org/extlink.gif b/sites/static.scrapy.org/extlink.gif
deleted file mode 100644
index d47e14ca5..000000000
Binary files a/sites/static.scrapy.org/extlink.gif and /dev/null differ
diff --git a/sites/static.scrapy.org/feed.png b/sites/static.scrapy.org/feed.png
deleted file mode 100644
index fec919dd2..000000000
Binary files a/sites/static.scrapy.org/feed.png and /dev/null differ
diff --git a/sites/static.scrapy.org/file.png b/sites/static.scrapy.org/file.png
deleted file mode 100644
index f35fc99b3..000000000
Binary files a/sites/static.scrapy.org/file.png and /dev/null differ
diff --git a/sites/static.scrapy.org/folder.png b/sites/static.scrapy.org/folder.png
deleted file mode 100644
index d26c06cfc..000000000
Binary files a/sites/static.scrapy.org/folder.png and /dev/null differ
diff --git a/sites/static.scrapy.org/guide/basic-workflow.png b/sites/static.scrapy.org/guide/basic-workflow.png
deleted file mode 100644
index 0074ef18a..000000000
Binary files a/sites/static.scrapy.org/guide/basic-workflow.png and /dev/null differ
diff --git a/sites/static.scrapy.org/guide/original-workflow.png b/sites/static.scrapy.org/guide/original-workflow.png
deleted file mode 100644
index 821365226..000000000
Binary files a/sites/static.scrapy.org/guide/original-workflow.png and /dev/null differ
diff --git a/sites/static.scrapy.org/ics.png b/sites/static.scrapy.org/ics.png
deleted file mode 100644
index 69b9193d0..000000000
Binary files a/sites/static.scrapy.org/ics.png and /dev/null differ
diff --git a/sites/static.scrapy.org/imggrid.png b/sites/static.scrapy.org/imggrid.png
deleted file mode 100644
index d1e60d977..000000000
Binary files a/sites/static.scrapy.org/imggrid.png and /dev/null differ
diff --git a/sites/static.scrapy.org/js/blame.js b/sites/static.scrapy.org/js/blame.js
deleted file mode 100644
index 187dd67c8..000000000
--- a/sites/static.scrapy.org/js/blame.js
+++ /dev/null
@@ -1,102 +0,0 @@
-
-(function($){
-
- window.enableBlame = function(url, original_path) {
- var message = null;
- var message_rev = null;
-
- /* for each blame cell containing a changeset link... */
- var rev_paths = {};
- $("table.code th.blame a").each(function() {
- href = $(this).attr("href");
- $(this).removeAttr("href");
- rev_href = href.substr(href.indexOf("changeset/") + 10);
- elts = rev_href.split("/");
- var path = elts.slice(1).join("/");
- if (path != original_path)
- rev_paths["r"+elts[0]] = path;
- });
-
- /* for each blame cell... */
- $("table.code th.blame").each(function() {
- var rev = $(this).attr("class").split(" ")[1]; // "blame r123"
- var path = rev_paths[rev] || original_path; // only found if != orig
-
- if (!rev)
- return;
-
- $(this).css("cursor", "pointer").click(function() {
- var row = this.parentNode;
- var message_is_visible = message && message.css("display") == "block";
- var highlight_rev = null;
-
- function show() {
- /* Display commit message for the selected revision */
-
- var message_w = message.get(0).offsetWidth;
-
- // limit message panel width to 3/5 of the row width
- var row_w = row.offsetWidth;
- var max_w = (3.0 * row_w / 5.0);
- if (!message_w || message_w > max_w) {
- message_w = max_w;
- var borderw = (3+8)*2; // borderwidth + padding on both sides
- message.css({width: message_w - borderw + "px"});
- }
-
- var row_offset = $(row).offset();
- var left = row_offset.left + row.offsetWidth - message_w;
- message.css({display: "block", top: row_offset.top+"px", left: left-2+"px"});
- }
-
- function hide() {
- /* Hide commit message */
- message.css({display: "none"});
-
- /* Remove highlighting for lines of the current revision */
- $("table.code th."+message_rev).each(function() {
- $(this.parentNode).removeClass("hilite")
- });
- }
-
- if (message_rev != rev) { // fetch a new revision
- if (message_is_visible) {
- hide();
- }
- message_rev = rev;
- highlight_rev = message_rev;
-
- $.get(url + rev.substr(1), {annotate: path}, function(data) {
- // remove former message panel if any
- if (message)
- message.remove();
- // create new message panel
- message = $('<div class="message">').css("position", "absolute")
- .append($('<div class="inlinebuttons">')
- .append($('<input value="Close" type="button">').click(hide)))
- .append($('<div>').html(data || "<strong>(no changeset information)</strong>"))
- .appendTo("body");
-
- // workaround non-clickable "Close" issue in Firefox
- if ($.browser.mozilla)
- message.find("div.inlinebuttons").next().css("clear", "right");
-
- show();
- });
- } else if (message_is_visible) {
- hide();
- } else {
- show();
- highlight_rev = message_rev;
- }
-
- /* Highlight all lines of the current revision */
- $("table.code th."+highlight_rev).each(function() {
- $(this.parentNode).addClass("hilite")
- });
-
- });
- });
- }
-
-})(jQuery);
diff --git a/sites/static.scrapy.org/js/diff.js b/sites/static.scrapy.org/js/diff.js
deleted file mode 100644
index 14f8bf9b4..000000000
--- a/sites/static.scrapy.org/js/diff.js
+++ /dev/null
@@ -1,113 +0,0 @@
-(function($){
-
- function convertDiff(name, table) {
- var inline = table.className == 'inline';
- var ths = table.tHead.rows[0].cells;
- var afile, bfile;
- if ( inline ) {
- afile = ths[0].title;
- bfile = ths[1].title;
- } else {
- afile = $(ths[0]).find('a').text();
- bfile = $(ths[1]).find('a').text();
- }
- if ( afile.match(/^Revision /) ) {
- afile = 'a/' + name;
- bfile = 'b/' + name;
- }
- var lines = [
- "Index: " + name,
- "===================================================================",
- "--- " + afile.replace(/File /, ''),
- "+++ " + bfile.replace(/File /, ''),
- ];
- var sepIndex = 0;
- var oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;
-
- for (var i = 0; i < table.tBodies.length; i++) {
- var tBody = table.tBodies[i];
- if (i == 0 || tBody.className == "skipped") {
- if (i > 0) {
- if (!oldOffset && oldLength) oldOffset = 1
- if (!newOffset && newLength) newOffset = 1
- lines[sepIndex] = lines[sepIndex]
- .replace("{1}", oldOffset).replace("{2}", oldLength)
- .replace("{3}", newOffset).replace("{4}", newLength);
- }
- sepIndex = lines.length;
- lines.push("@@ -{1},{2} +{3},{4} @@");
- oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;
- if (tBody.className == "skipped") continue;
- }
- var tmpLines = [];
- for (var j = 0; j < tBody.rows.length; j++) {
- var cells = tBody.rows[j].cells;
- var oldLineNo = parseInt($(cells[0]).text());
- var newLineNo = parseInt($(cells[inline ? 1 : 2]).text());
- if (tBody.className == 'unmod') {
- lines.push(" " + $(cells[inline ? 2 : 1]).text());
- oldLength += 1;
- newLength += 1;
- if (!oldOffset) oldOffset = oldLineNo;
- if (!newOffset) newOffset = newLineNo;
- } else {
- var oldLine;
- var newLine;
- if (inline) {
- oldLine = newLine = $(cells[2]).text();
- } else {
- oldLine = $(cells[1]).text();
- newLine = $(cells[3]).text();
- }
- if (!isNaN(oldLineNo)) {
- lines.push("-" + oldLine);
- oldLength += 1;
- }
- if (!isNaN(newLineNo)) {
- tmpLines.push("+" + newLine);
- newLength += 1;
- }
- }
- }
- if (tmpLines.length > 0) {
- lines = lines.concat(tmpLines);
- }
- }
-
- if (!oldOffset && oldLength) oldOffset = 1;
- if (!newOffset && newLength) newOffset = 1;
- lines[sepIndex] = lines[sepIndex]
- .replace("{1}", oldOffset).replace("{2}", oldLength)
- .replace("{3}", newOffset).replace("{4}", newLength);
-
- /* remove trailing &nbsp; and join lines (with CR for IExplorer) */
- for ( var i = 0; i < lines.length; i++ )
- if ( lines[i] )
- lines[i] = lines[i].replace(/\xa0$/, '');
- return lines.join($.browser.msie ? "\r" : "\n");
- }
-
- $(document).ready(function($) {
- $("div.diff h2").each(function() {
- var switcher = $("<span class='switch'></span>").prependTo(this);
- var name = $.trim($(this).text());
- var table = $(this).siblings("table").get(0);
- if (! table) return;
- var pre = $("<pre></pre>").hide().insertAfter(table);
- $("<span>Tabular</span>").click(function() {
- $(pre).hide();
- $(table).show();
- $(this).addClass("active").siblings("span").removeClass("active");
- return false;
- }).addClass("active").appendTo(switcher);
- $("<span>Unified</span>").click(function() {
- $(table).hide();
- if (!pre.get(0).firstChild) pre.text(convertDiff(name, table));
- $(pre).fadeIn("fast")
- $(this).addClass("active").siblings("span").removeClass("active");
- return false;
- }).appendTo(switcher);
- });
- });
-
-})(jQuery);
diff --git a/sites/static.scrapy.org/js/expand_dir.js b/sites/static.scrapy.org/js/expand_dir.js
deleted file mode 100644
index 223eefb40..000000000
--- a/sites/static.scrapy.org/js/expand_dir.js
+++ /dev/null
@@ -1,116 +0,0 @@
-// Enable expanding/folding folders in TracBrowser
-
-(function($){
- var FOLDERID_COUNTER = 0;
- var SUBFOLDER_INDENT = 20;
-
- // enableExpandDir adds the capability to folder rows to be expanded and folded
- // It also teach the rows about their ancestors. It expects:
- // - `parent_tr`, the logical parent row (`null` if there's no ancestor)
- // - a `rows` jQuery object matching the newly created entry rows
- // - `qargs`, additional parameters to send to the server when expanding
-
- window.enableExpandDir = function(parent_tr, rows, qargs) {
- // the ancestors folder ids are present in the parent_tr class attribute
- var ancestor_folderids = [];
- if (parent_tr)
- ancestor_folderids = $.grep(parent_tr.attr("class").split(" "),
- function(c) { return c.match(/^f\d+$/)});
- rows.each(function () {
- var a = $(this).find("a.dir");
-
- if (a.length) { // then the entry is a folder
- // create new folder id
- var folderid = "f" + FOLDERID_COUNTER++;
- this.id = folderid;
- $(this).addClass(folderid);
-
- // add the expander icon
- a.wrap('<div></div>');
- var expander = a.before('<span class="expander">&nbsp;</span>').prev();
- expander.attr("title", "Expand sub-directory in place")
- .click(function() { toggleDir($(this), qargs); });
- }
-
- // tie that row to ancestor folders
- if (parent_tr)
- $(this).addClass(ancestor_folderids.join(" "));
- });
- }
-
- // handler for click event on the expander icons
- window.toggleDir = function(expander, qargs) {
- var tr = expander.parents("tr");
- var folderid = tr.get(0).id;
-
- if ( tr.filter(".expanded").length ) { // then *fold*
- tr.removeClass("expanded").addClass("collapsed");
- tr.siblings("tr."+folderid).hide();
- expander.attr("title", "Re-expand directory");
- return;
- }
-
- if ( tr.filter(".collapsed").length ) { // then *expand*
- tr.removeClass("collapsed").addClass("expanded");
- tr.siblings("tr."+folderid).show();
- // Note that the above will show all the already fetched subtree,
- // so we have to fold again the folders which were already collapsed.
- tr.siblings("tr.collapsed").each(function() {
- tr.siblings("tr."+this.id).not(this).hide();
- });
- } else { // then *fetch*
- var td = expander.parents("td");
- var td_class = td.attr("class");
- var a = expander.next("a");
- var depth =
- parseFloat(td.css("padding-left").replace(/^(\d*\.\d*).*$/, "$1")) +
- SUBFOLDER_INDENT;
-
- tr.addClass("expanded");
- // insert "Loading ..." row
- tr.after('<tr><td><span class="loading"></span></td></tr>');
- var loading_row = tr.next();
- loading_row.children("td").addClass(td_class)
- .attr("colspan", tr.children("td").length)
- .css("padding-left", depth);
- loading_row.find("span.loading").text("Loading " + a.text() + "...");
-
- // XHR for getting the rows corresponding to the folder entries
- $.ajax({
- type: "GET",
- url: a.attr("href"),
- data: qargs,
- dataType: "html",
- success: function(data) {
- // Safari 3.1.1 has some trouble reconstructing HTML snippets
- // bigger than 50k - splitting in rows before building DOM nodes
- var rows = data.replace(/^<!DOCTYPE[^>]+>/, "").split("</tr>");
- if (rows.length) {
- // insert entry rows
- $(rows).each(function() {
- row = $(this+"</tr>");
- row.children("td."+td_class).css("padding-left", depth);
- // make all entry rows collapsible but only subdir rows expandable
- enableExpandDir(tr, row, qargs);
- loading_row.before(row);
- });
- // remove "Loading ..." row
- loading_row.remove();
- } else {
- loading_row.find("span.loading").text("").append("<i>(empty)</i>")
- .removeClass("loading");
- // make the (empty) row collapsible
- enableExpandDir(tr, loading_row, qargs);
- }
- },
- error: function(req, err, exc) {
- loading_row.find("span.loading").text("").append("<i>(error)</i>")
- .removeClass("loading");
- enableExpandDir(tr, loading_row, qargs);
- }
- });
- }
- expander.attr("title", "Fold directory");
- }
-
-})(jQuery);
diff --git a/sites/static.scrapy.org/js/folding.js b/sites/static.scrapy.org/js/folding.js
deleted file mode 100644
index 0f16a2de1..000000000
--- a/sites/static.scrapy.org/js/folding.js
+++ /dev/null
@@ -1,26 +0,0 @@
-(function($){
-
- $.fn.enableFolding = function(autofold) {
- var fragId = document.location.hash;
- if (fragId && /^#no\d+$/.test(fragId)) {
- fragId = parseInt(fragId.substr(3));
- }
-
- var count = 1;
- return this.each(function() {
- var t = $(this).text();
- $(this).text("");
- var trigger = $(this).append("<a href='#no" + count + "'></a>").children();
- trigger.text(t);
-
- trigger.click(function() {
- if (fragId == count) { fragId = 0; return; }
- $(this.parentNode.parentNode).toggleClass("collapsed");
- });
- if ( autofold )
- trigger.click();
- count++;
- }).css("cursor", "pointer");
- }
-
-})(jQuery);
\ No newline at end of file
diff --git a/sites/static.scrapy.org/js/ie_pre7_hacks.js b/sites/static.scrapy.org/js/ie_pre7_hacks.js
deleted file mode 100644
index a2701adba..000000000
--- a/sites/static.scrapy.org/js/ie_pre7_hacks.js
+++ /dev/null
@@ -1,7 +0,0 @@
-jQuery(function($) { // onload
- $('select').bind('focusin', function() {
- this.tmpIndex = this.selectedIndex;
- }).bind('focus', function() {
- this.selectedIndex = this.tmpIndex;
- });
-});
diff --git a/sites/static.scrapy.org/js/jquery.js b/sites/static.scrapy.org/js/jquery.js
deleted file mode 100644
index 74cdfee17..000000000
--- a/sites/static.scrapy.org/js/jquery.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * jQuery 1.2.3 - New Wave Javascript
- *
- * Copyright (c) 2008 John Resig (jquery.com)
- * Dual licensed under the MIT (MIT-LICENSE.txt)
- * and GPL (GPL-LICENSE.txt) licenses.
- *
- * $Date: 2008-02-06 00:21:25 -0500 (Wed, 06 Feb 2008) $
- * $Rev: 4663 $
- */
-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(J(){7(1e.3N)L w=1e.3N;L E=1e.3N=J(a,b){K 1B E.2l.4T(a,b)};7(1e.$)L D=1e.$;1e.$=E;L u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;L G=/^.[^:#\\[\\.]*$/;E.1n=E.2l={4T:J(d,b){d=d||T;7(d.15){6[0]=d;6.M=1;K 6}N 7(1o d=="25"){L c=u.2O(d);7(c&&(c[1]||!b)){7(c[1])d=E.4a([c[1]],b);N{L a=T.5J(c[3]);7(a)7(a.2w!=c[3])K E().2s(d);N{6[0]=a;6.M=1;K 6}N d=[]}}N K 1B E(b).2s(d)}N 7(E.1q(d))K 1B E(T)[E.1n.21?"21":"3U"](d);K 6.6E(d.1k==1M&&d||(d.5h||d.M&&d!=1e&&!d.15&&d[0]!=10&&d[0].15)&&E.2I(d)||[d])},5h:"1.2.3",87:J(){K 6.M},M:0,22:J(a){K a==10?E.2I(6):6[a]},2F:J(b){L a=E(b);a.54=6;K a},6E:J(a){6.M=0;1M.2l.1g.1i(6,a);K 6},R:J(a,b){K E.R(6,a,b)},4X:J(b){L a=-1;6.R(J(i){7(6==b)a=i});K a},1J:J(c,a,b){L d=c;7(c.1k==4e)7(a==10)K 6.M&&E[b||"1J"](6[0],c)||10;N{d={};d[c]=a}K 6.R(J(i){Q(c 1p d)E.1J(b?6.W:6,c,E.1l(6,d[c],b,i,c))})},1j:J(b,a){7((b==\'27\'||b==\'1R\')&&2M(a)<0)a=10;K 6.1J(b,a,"2o")},1u:J(b){7(1o b!="3V"&&b!=V)K 6.4x().3t((6[0]&&6[0].2i||T).5r(b));L a="";E.R(b||6,J(){E.R(6.3p,J(){7(6.15!=8)a+=6.15!=1?6.6K:E.1n.1u([6])})});K a},5m:J(b){7(6[0])E(b,6[0].2i).5k().3o(6[0]).2c(J(){L a=6;2b(a.1C)a=a.1C;K a}).3t(6);K 6},8w:J(a){K 6.R(J(){E(6).6z().5m(a)})},8p:J(a){K 6.R(J(){E(6).5m(a)})},3t:J(){K 6.3O(18,P,S,J(a){7(6.15==1)6.38(a)})},6q:J(){K 6.3O(18,P,P,J(a){7(6.15==1)6.3o(a,6.1C)})},6o:J(){K 6.3O(18,S,S,J(a){6.1a.3o(a,6)})},5a:J(){K 6.3O(18,S,P,J(a){6.1a.3o(a,6.2B)})},3h:J(){K 6.54||E([])},2s:J(b){L c=E.2c(6,J(a){K E.2s(b,a)});K 6.2F(/[^+>] [^+>]/.17(b)||b.1f("..")>-1?E.57(c):c)},5k:J(e){L f=6.2c(J(){7(E.14.1d&&!E.3E(6)){L a=6.69(P),4Y=T.3s("1x");4Y.38(a);K E.4a([4Y.3d])[0]}N K 6.69(P)});L d=f.2s("*").4R().R(J(){7(6[F]!=10)6[F]=V});7(e===P)6.2s("*").4R().R(J(i){7(6.15==3)K;L c=E.O(6,"2R");Q(L a 1p c)Q(L b 1p c[a])E.16.1b(d[i],a,c[a][b],c[a][b].O)});K f},1E:J(b){K 6.2F(E.1q(b)&&E.3y(6,J(a,i){K b.1P(a,i)})||E.3e(b,6))},56:J(b){7(b.1k==4e)7(G.17(b))K 6.2F(E.3e(b,6,P));N b=E.3e(b,6);L a=b.M&&b[b.M-1]!==10&&!b.15;K 6.1E(J(){K a?E.33(6,b)<0:6!=b})},1b:J(a){K!a?6:6.2F(E.37(6.22(),a.1k==4e?E(a).22():a.M!=10&&(!a.12||E.12(a,"3u"))?a:[a]))},3H:J(a){K a?E.3e(a,6).M>0:S},7j:J(a){K 6.3H("."+a)},5O:J(b){7(b==10){7(6.M){L c=6[0];7(E.12(c,"2k")){L e=c.3T,5I=[],11=c.11,2X=c.U=="2k-2X";7(e<0)K V;Q(L i=2X?e:0,2f=2X?e+1:11.M;i<2f;i++){L d=11[i];7(d.2p){b=E.14.1d&&!d.9J.1A.9y?d.1u:d.1A;7(2X)K b;5I.1g(b)}}K 5I}N K(6[0].1A||"").1r(/\\r/g,"")}K 10}K 6.R(J(){7(6.15!=1)K;7(b.1k==1M&&/5u|5t/.17(6.U))6.3k=(E.33(6.1A,b)>=0||E.33(6.31,b)>=0);N 7(E.12(6,"2k")){L a=b.1k==1M?b:[b];E("98",6).R(J(){6.2p=(E.33(6.1A,a)>=0||E.33(6.1u,a)>=0)});7(!a.M)6.3T=-1}N 6.1A=b})},3q:J(a){K a==10?(6.M?6[0].3d:V):6.4x().3t(a)},6S:J(a){K 6.5a(a).1V()},6Z:J(i){K 6.2K(i,i+1)},2K:J(){K 6.2F(1M.2l.2K.1i(6,18))},2c:J(b){K 6.2F(E.2c(6,J(a,i){K b.1P(a,i,a)}))},4R:J(){K 6.1b(6.54)},O:J(d,b){L a=d.23(".");a[1]=a[1]?"."+a[1]:"";7(b==V){L c=6.5n("8P"+a[1]+"!",[a[0]]);7(c==10&&6.M)c=E.O(6[0],d);K c==V&&a[1]?6.O(a[0]):c}N K 6.1N("8K"+a[1]+"!",[a[0],b]).R(J(){E.O(6,d,b)})},35:J(a){K 6.R(J(){E.35(6,a)})},3O:J(g,f,h,d){L e=6.M>1,3n;K 6.R(J(){7(!3n){3n=E.4a(g,6.2i);7(h)3n.8D()}L b=6;7(f&&E.12(6,"1O")&&E.12(3n[0],"4v"))b=6.3S("1U")[0]||6.38(6.2i.3s("1U"));L c=E([]);E.R(3n,J(){L a=e?E(6).5k(P)[0]:6;7(E.12(a,"1m")){c=c.1b(a)}N{7(a.15==1)c=c.1b(E("1m",a).1V());d.1P(b,a)}});c.R(6A)})}};E.2l.4T.2l=E.2l;J 6A(i,a){7(a.3Q)E.3P({1c:a.3Q,3l:S,1H:"1m"});N E.5g(a.1u||a.6x||a.3d||"");7(a.1a)a.1a.34(a)}E.1s=E.1n.1s=J(){L b=18[0]||{},i=1,M=18.M,5c=S,11;7(b.1k==8d){5c=b;b=18[1]||{};i=2}7(1o b!="3V"&&1o b!="J")b={};7(M==1){b=6;i=0}Q(;i<M;i++)7((11=18[i])!=V)Q(L a 1p 11){7(b===11[a])6w;7(5c&&11[a]&&1o 11[a]=="3V"&&b[a]&&!11[a].15)b[a]=E.1s(b[a],11[a]);N 7(11[a]!=10)b[a]=11[a]}K b};L F="3N"+(1B 3v()).3L(),6t=0,5b={};L H=/z-?4X|86-?84|1w|6k|7Z-?1R/i;E.1s({7Y:J(a){1e.$=D;7(a)1e.3N=w;K E},1q:J(a){K!!a&&1o a!="25"&&!a.12&&a.1k!=1M&&/J/i.17(a+"")},3E:J(a){K a.1F&&!a.1h||a.28&&a.2i&&!a.2i.1h},5g:J(a){a=E.3g(a);7(a){L b=T.3S("6f")[0]||T.1F,1m=T.3s("1m");1m.U="1u/4m";7(E.14.1d)1m.1u=a;N 1m.38(T.5r(a));b.38(1m);b.34(1m)}},12:J(b,a){K b.12&&b.12.2E()==a.2E()},1T:{},O:J(c,d,b){c=c==1e?5b:c;L a=c[F];7(!a)a=c[F]=++6t;7(d&&!E.1T[a])E.1T[a]={};7(b!=10)E.1T[a][d]=b;K d?E.1T[a][d]:a},35:J(c,b){c=c==1e?5b:c;L a=c[F];7(b){7(E.1T[a]){2V E.1T[a][b];b="";Q(b 1p E.1T[a])1Q;7(!b)E.35(c)}}N{1S{2V c[F]}1X(e){7(c.52)c.52(F)}2V E.1T[a]}},R:J(c,a,b){7(b){7(c.M==10){Q(L d 1p c)7(a.1i(c[d],b)===S)1Q}N Q(L i=0,M=c.M;i<M;i++)7(a.1i(c[i],b)===S)1Q}N{7(c.M==10){Q(L d 1p c)7(a.1P(c[d],d,c[d])===S)1Q}N Q(L i=0,M=c.M,1A=c[0];i<M&&a.1P(1A,i,1A)!==S;1A=c[++i]){}}K c},1l:J(b,a,c,i,d){7(E.1q(a))a=a.1P(b,i);K a&&a.1k==51&&c=="2o"&&!H.17(d)?a+"2S":a},1t:{1b:J(c,b){E.R((b||"").23(/\\s+/),J(i,a){7(c.15==1&&!E.1t.3Y(c.1t,a))c.1t+=(c.1t?" ":"")+a})},1V:J(c,b){7(c.15==1)c.1t=b!=10?E.3y(c.1t.23(/\\s+/),J(a){K!E.1t.3Y(b,a)}).6a(" "):""},3Y:J(b,a){K E.33(a,(b.1t||b).3X().23(/\\s+/))>-1}},68:J(b,c,a){L e={};Q(L d 1p c){e[d]=b.W[d];b.W[d]=c[d]}a.1P(b);Q(L d 1p c)b.W[d]=e[d]},1j:J(d,e,c){7(e=="27"||e=="1R"){L b,46={43:"4W",4U:"1Z",19:"3D"},3c=e=="27"?["7O","7M"]:["7J","7I"];J 5E(){b=e=="27"?d.7H:d.7F;L a=0,2N=0;E.R(3c,J(){a+=2M(E.2o(d,"7E"+6,P))||0;2N+=2M(E.2o(d,"2N"+6+"5X",P))||0});b-=24.7C(a+2N)}7(E(d).3H(":4d"))5E();N E.68(d,46,5E);K 24.2f(0,b)}K E.2o(d,e,c)},2o:J(e,k,j){L d;J 3x(b){7(!E.14.2d)K S;L a=T.4c.4K(b,V);K!a||a.4M("3x")==""}7(k=="1w"&&E.14.1d){d=E.1J(e.W,"1w");K d==""?"1":d}7(E.14.2z&&k=="19"){L c=e.W.50;e.W.50="0 7r 7o";e.W.50=c}7(k.1D(/4g/i))k=y;7(!j&&e.W&&e.W[k])d=e.W[k];N 7(T.4c&&T.4c.4K){7(k.1D(/4g/i))k="4g";k=k.1r(/([A-Z])/g,"-$1").2h();L h=T.4c.4K(e,V);7(h&&!3x(e))d=h.4M(k);N{L f=[],2C=[];Q(L a=e;a&&3x(a);a=a.1a)2C.4J(a);Q(L i=0;i<2C.M;i++)7(3x(2C[i])){f[i]=2C[i].W.19;2C[i].W.19="3D"}d=k=="19"&&f[2C.M-1]!=V?"2H":(h&&h.4M(k))||"";Q(L i=0;i<f.M;i++)7(f[i]!=V)2C[i].W.19=f[i]}7(k=="1w"&&d=="")d="1"}N 7(e.4n){L g=k.1r(/\\-(\\w)/g,J(a,b){K b.2E()});d=e.4n[k]||e.4n[g];7(!/^\\d+(2S)?$/i.17(d)&&/^\\d/.17(d)){L l=e.W.26,3K=e.3K.26;e.3K.26=e.4n.26;e.W.26=d||0;d=e.W.7f+"2S";e.W.26=l;e.3K.26=3K}}K d},4a:J(l,h){L k=[];h=h||T;7(1o h.3s==\'10\')h=h.2i||h[0]&&h[0].2i||T;E.R(l,J(i,d){7(!d)K;7(d.1k==51)d=d.3X();7(1o d=="25"){d=d.1r(/(<(\\w+)[^>]*?)\\/>/g,J(b,a,c){K c.1D(/^(aa|a6|7e|a5|4D|7a|a0|3m|9W|9U|9S)$/i)?b:a+"></"+c+">"});L f=E.3g(d).2h(),1x=h.3s("1x");L e=!f.1f("<9P")&&[1,"<2k 74=\'74\'>","</2k>"]||!f.1f("<9M")&&[1,"<73>","</73>"]||f.1D(/^<(9G|1U|9E|9B|9x)/)&&[1,"<1O>","</1O>"]||!f.1f("<4v")&&[2,"<1O><1U>","</1U></1O>"]||(!f.1f("<9w")||!f.1f("<9v"))&&[3,"<1O><1U><4v>","</4v></1U></1O>"]||!f.1f("<7e")&&[2,"<1O><1U></1U><6V>","</6V></1O>"]||E.14.1d&&[1,"1x<1x>","</1x>"]||[0,"",""];1x.3d=e[1]+d+e[2];2b(e[0]--)1x=1x.5o;7(E.14.1d){L g=!f.1f("<1O")&&f.1f("<1U")<0?1x.1C&&1x.1C.3p:e[1]=="<1O>"&&f.1f("<1U")<0?1x.3p:[];Q(L j=g.M-1;j>=0;--j)7(E.12(g[j],"1U")&&!g[j].3p.M)g[j].1a.34(g[j]);7(/^\\s/.17(d))1x.3o(h.5r(d.1D(/^\\s*/)[0]),1x.1C)}d=E.2I(1x.3p)}7(d.M===0&&(!E.12(d,"3u")&&!E.12(d,"2k")))K;7(d[0]==10||E.12(d,"3u")||d.11)k.1g(d);N k=E.37(k,d)});K k},1J:J(d,e,c){7(!d||d.15==3||d.15==8)K 10;L f=E.3E(d)?{}:E.46;7(e=="2p"&&E.14.2d)d.1a.3T;7(f[e]){7(c!=10)d[f[e]]=c;K d[f[e]]}N 7(E.14.1d&&e=="W")K E.1J(d.W,"9u",c);N 7(c==10&&E.14.1d&&E.12(d,"3u")&&(e=="9r"||e=="9o"))K d.9m(e).6K;N 7(d.28){7(c!=10){7(e=="U"&&E.12(d,"4D")&&d.1a)6Q"U 9i 9h\'t 9g 9e";d.9b(e,""+c)}7(E.14.1d&&/6O|3Q/.17(e)&&!E.3E(d))K d.4z(e,2);K d.4z(e)}N{7(e=="1w"&&E.14.1d){7(c!=10){d.6k=1;d.1E=(d.1E||"").1r(/6M\\([^)]*\\)/,"")+(2M(c).3X()=="96"?"":"6M(1w="+c*6L+")")}K d.1E&&d.1E.1f("1w=")>=0?(2M(d.1E.1D(/1w=([^)]*)/)[1])/6L).3X():""}e=e.1r(/-([a-z])/95,J(a,b){K b.2E()});7(c!=10)d[e]=c;K d[e]}},3g:J(a){K(a||"").1r(/^\\s+|\\s+$/g,"")},2I:J(b){L a=[];7(1o b!="93")Q(L i=0,M=b.M;i<M;i++)a.1g(b[i]);N a=b.2K(0);K a},33:J(b,a){Q(L i=0,M=a.M;i<M;i++)7(a[i]==b)K i;K-1},37:J(a,b){7(E.14.1d){Q(L i=0;b[i];i++)7(b[i].15!=8)a.1g(b[i])}N Q(L i=0;b[i];i++)a.1g(b[i]);K a},57:J(a){L c=[],2r={};1S{Q(L i=0,M=a.M;i<M;i++){L b=E.O(a[i]);7(!2r[b]){2r[b]=P;c.1g(a[i])}}}1X(e){c=a}K c},3y:J(c,a,d){L b=[];Q(L i=0,M=c.M;i<M;i++)7(!d&&a(c[i],i)||d&&!a(c[i],i))b.1g(c[i]);K b},2c:J(d,a){L c=[];Q(L i=0,M=d.M;i<M;i++){L b=a(d[i],i);7(b!==V&&b!=10){7(b.1k!=1M)b=[b];c=c.71(b)}}K c}});L v=8Y.8W.2h();E.14={5K:(v.1D(/.+(?:8T|8S|8R|8O)[\\/: ]([\\d.]+)/)||[])[1],2d:/77/.17(v),2z:/2z/.17(v),1d:/1d/.17(v)&&!/2z/.17(v),48:/48/.17(v)&&!/(8L|77)/.17(v)};L y=E.14.1d?"6H":"75";E.1s({8I:!E.14.1d||T.6F=="79",46:{"Q":"8F","8E":"1t","4g":y,75:y,6H:y,3d:"3d",1t:"1t",1A:"1A",2Y:"2Y",3k:"3k",8C:"8B",2p:"2p",8A:"8z",3T:"3T",6C:"6C",28:"28",12:"12"}});E.R({6B:J(a){K a.1a},8y:J(a){K E.4u(a,"1a")},8x:J(a){K E.2Z(a,2,"2B")},8v:J(a){K E.2Z(a,2,"4t")},8u:J(a){K E.4u(a,"2B")},8t:J(a){K E.4u(a,"4t")},8s:J(a){K E.5i(a.1a.1C,a)},8r:J(a){K E.5i(a.1C)},6z:J(a){K E.12(a,"8q")?a.8o||a.8n.T:E.2I(a.3p)}},J(c,d){E.1n[c]=J(b){L a=E.2c(6,d);7(b&&1o b=="25")a=E.3e(b,a);K 6.2F(E.57(a))}});E.R({6y:"3t",8m:"6q",3o:"6o",8l:"5a",8k:"6S"},J(c,b){E.1n[c]=J(){L a=18;K 6.R(J(){Q(L i=0,M=a.M;i<M;i++)E(a[i])[b](6)})}});E.R({8j:J(a){E.1J(6,a,"");7(6.15==1)6.52(a)},8i:J(a){E.1t.1b(6,a)},8h:J(a){E.1t.1V(6,a)},8g:J(a){E.1t[E.1t.3Y(6,a)?"1V":"1b"](6,a)},1V:J(a){7(!a||E.1E(a,[6]).r.M){E("*",6).1b(6).R(J(){E.16.1V(6);E.35(6)});7(6.1a)6.1a.34(6)}},4x:J(){E(">*",6).1V();2b(6.1C)6.34(6.1C)}},J(a,b){E.1n[a]=J(){K 6.R(b,18)}});E.R(["8f","5X"],J(i,c){L b=c.2h();E.1n[b]=J(a){K 6[0]==1e?E.14.2z&&T.1h["5e"+c]||E.14.2d&&1e["8e"+c]||T.6F=="79"&&T.1F["5e"+c]||T.1h["5e"+c]:6[0]==T?24.2f(24.2f(T.1h["5d"+c],T.1F["5d"+c]),24.2f(T.1h["5L"+c],T.1F["5L"+c])):a==10?(6.M?E.1j(6[0],b):V):6.1j(b,a.1k==4e?a:a+"2S")}});L C=E.14.2d&&4s(E.14.5K)<8c?"(?:[\\\\w*4r-]|\\\\\\\\.)":"(?:[\\\\w\\8b-\\8a*4r-]|\\\\\\\\.)",6v=1B 4q("^>\\\\s*("+C+"+)"),6u=1B 4q("^("+C+"+)(#)("+C+"+)"),6s=1B 4q("^([#.]?)("+C+"*)");E.1s({6r:{"":J(a,i,m){K m[2]=="*"||E.12(a,m[2])},"#":J(a,i,m){K a.4z("2w")==m[2]},":":{89:J(a,i,m){K i<m[3]-0},88:J(a,i,m){K i>m[3]-0},2Z:J(a,i,m){K m[3]-0==i},6Z:J(a,i,m){K m[3]-0==i},3j:J(a,i){K i==0},3J:J(a,i,m,r){K i==r.M-1},6n:J(a,i){K i%2==0},6l:J(a,i){K i%2},"3j-4p":J(a){K a.1a.3S("*")[0]==a},"3J-4p":J(a){K E.2Z(a.1a.5o,1,"4t")==a},"83-4p":J(a){K!E.2Z(a.1a.5o,2,"4t")},6B:J(a){K a.1C},4x:J(a){K!a.1C},82:J(a,i,m){K(a.6x||a.81||E(a).1u()||"").1f(m[3])>=0},4d:J(a){K"1Z"!=a.U&&E.1j(a,"19")!="2H"&&E.1j(a,"4U")!="1Z"},1Z:J(a){K"1Z"==a.U||E.1j(a,"19")=="2H"||E.1j(a,"4U")=="1Z"},80:J(a){K!a.2Y},2Y:J(a){K a.2Y},3k:J(a){K a.3k},2p:J(a){K a.2p||E.1J(a,"2p")},1u:J(a){K"1u"==a.U},5u:J(a){K"5u"==a.U},5t:J(a){K"5t"==a.U},59:J(a){K"59"==a.U},3I:J(a){K"3I"==a.U},58:J(a){K"58"==a.U},6j:J(a){K"6j"==a.U},6i:J(a){K"6i"==a.U},2G:J(a){K"2G"==a.U||E.12(a,"2G")},4D:J(a){K/4D|2k|6h|2G/i.17(a.12)},3Y:J(a,i,m){K E.2s(m[3],a).M},7X:J(a){K/h\\d/i.17(a.12)},7W:J(a){K E.3y(E.3G,J(b){K a==b.Y}).M}}},6g:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,1B 4q("^([:.#]*)("+C+"+)")],3e:J(a,c,b){L d,2m=[];2b(a&&a!=d){d=a;L f=E.1E(a,c,b);a=f.t.1r(/^\\s*,\\s*/,"");2m=b?c=f.r:E.37(2m,f.r)}K 2m},2s:J(t,p){7(1o t!="25")K[t];7(p&&p.15!=1&&p.15!=9)K[];p=p||T;L d=[p],2r=[],3J,12;2b(t&&3J!=t){L r=[];3J=t;t=E.3g(t);L o=S;L g=6v;L m=g.2O(t);7(m){12=m[1].2E();Q(L i=0;d[i];i++)Q(L c=d[i].1C;c;c=c.2B)7(c.15==1&&(12=="*"||c.12.2E()==12))r.1g(c);d=r;t=t.1r(g,"");7(t.1f(" ")==0)6w;o=P}N{g=/^([>+~])\\s*(\\w*)/i;7((m=g.2O(t))!=V){r=[];L l={};12=m[2].2E();m=m[1];Q(L j=0,3f=d.M;j<3f;j++){L n=m=="~"||m=="+"?d[j].2B:d[j].1C;Q(;n;n=n.2B)7(n.15==1){L h=E.O(n);7(m=="~"&&l[h])1Q;7(!12||n.12.2E()==12){7(m=="~")l[h]=P;r.1g(n)}7(m=="+")1Q}}d=r;t=E.3g(t.1r(g,""));o=P}}7(t&&!o){7(!t.1f(",")){7(p==d[0])d.4l();2r=E.37(2r,d);r=d=[p];t=" "+t.6e(1,t.M)}N{L k=6u;L m=k.2O(t);7(m){m=[0,m[2],m[3],m[1]]}N{k=6s;m=k.2O(t)}m[2]=m[2].1r(/\\\\/g,"");L f=d[d.M-1];7(m[1]=="#"&&f&&f.5J&&!E.3E(f)){L q=f.5J(m[2]);7((E.14.1d||E.14.2z)&&q&&1o q.2w=="25"&&q.2w!=m[2])q=E(\'[@2w="\'+m[2]+\'"]\',f)[0];d=r=q&&(!m[3]||E.12(q,m[3]))?[q]:[]}N{Q(L i=0;d[i];i++){L a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];7(a=="*"&&d[i].12.2h()=="3V")a="3m";r=E.37(r,d[i].3S(a))}7(m[1]==".")r=E.55(r,m[2]);7(m[1]=="#"){L e=[];Q(L i=0;r[i];i++)7(r[i].4z("2w")==m[2]){e=[r[i]];1Q}r=e}d=r}t=t.1r(k,"")}}7(t){L b=E.1E(t,r);d=r=b.r;t=E.3g(b.t)}}7(t)d=[];7(d&&p==d[0])d.4l();2r=E.37(2r,d);K 2r},55:J(r,m,a){m=" "+m+" ";L c=[];Q(L i=0;r[i];i++){L b=(" "+r[i].1t+" ").1f(m)>=0;7(!a&&b||a&&!b)c.1g(r[i])}K c},1E:J(t,r,h){L d;2b(t&&t!=d){d=t;L p=E.6g,m;Q(L i=0;p[i];i++){m=p[i].2O(t);7(m){t=t.7V(m[0].M);m[2]=m[2].1r(/\\\\/g,"");1Q}}7(!m)1Q;7(m[1]==":"&&m[2]=="56")r=G.17(m[3])?E.1E(m[3],r,P).r:E(r).56(m[3]);N 7(m[1]==".")r=E.55(r,m[2],h);N 7(m[1]=="["){L g=[],U=m[3];Q(L i=0,3f=r.M;i<3f;i++){L a=r[i],z=a[E.46[m[2]]||m[2]];7(z==V||/6O|3Q|2p/.17(m[2]))z=E.1J(a,m[2])||\'\';7((U==""&&!!z||U=="="&&z==m[5]||U=="!="&&z!=m[5]||U=="^="&&z&&!z.1f(m[5])||U=="$="&&z.6e(z.M-m[5].M)==m[5]||(U=="*="||U=="~=")&&z.1f(m[5])>=0)^h)g.1g(a)}r=g}N 7(m[1]==":"&&m[2]=="2Z-4p"){L e={},g=[],17=/(-?)(\\d*)n((?:\\+|-)?\\d*)/.2O(m[3]=="6n"&&"2n"||m[3]=="6l"&&"2n+1"||!/\\D/.17(m[3])&&"7U+"+m[3]||m[3]),3j=(17[1]+(17[2]||1))-0,d=17[3]-0;Q(L i=0,3f=r.M;i<3f;i++){L j=r[i],1a=j.1a,2w=E.O(1a);7(!e[2w]){L c=1;Q(L n=1a.1C;n;n=n.2B)7(n.15==1)n.4k=c++;e[2w]=P}L b=S;7(3j==0){7(j.4k==d)b=P}N 7((j.4k-d)%3j==0&&(j.4k-d)/3j>=0)b=P;7(b^h)g.1g(j)}r=g}N{L f=E.6r[m[1]];7(1o f=="3V")f=f[m[2]];7(1o f=="25")f=6c("S||J(a,i){K "+f+";}");r=E.3y(r,J(a,i){K f(a,i,m,r)},h)}}K{r:r,t:t}},4u:J(b,c){L d=[];L a=b[c];2b(a&&a!=T){7(a.15==1)d.1g(a);a=a[c]}K d},2Z:J(a,e,c,b){e=e||1;L d=0;Q(;a;a=a[c])7(a.15==1&&++d==e)1Q;K a},5i:J(n,a){L r=[];Q(;n;n=n.2B){7(n.15==1&&(!a||n!=a))r.1g(n)}K r}});E.16={1b:J(f,i,g,e){7(f.15==3||f.15==8)K;7(E.14.1d&&f.53!=10)f=1e;7(!g.2D)g.2D=6.2D++;7(e!=10){L h=g;g=J(){K h.1i(6,18)};g.O=e;g.2D=h.2D}L j=E.O(f,"2R")||E.O(f,"2R",{}),1v=E.O(f,"1v")||E.O(f,"1v",J(){L a;7(1o E=="10"||E.16.5f)K a;a=E.16.1v.1i(18.3R.Y,18);K a});1v.Y=f;E.R(i.23(/\\s+/),J(c,b){L a=b.23(".");b=a[0];g.U=a[1];L d=j[b];7(!d){d=j[b]={};7(!E.16.2y[b]||E.16.2y[b].4j.1P(f)===S){7(f.3F)f.3F(b,1v,S);N 7(f.6b)f.6b("4i"+b,1v)}}d[g.2D]=g;E.16.2a[b]=P});f=V},2D:1,2a:{},1V:J(e,h,f){7(e.15==3||e.15==8)K;L i=E.O(e,"2R"),29,4X;7(i){7(h==10||(1o h=="25"&&h.7T(0)=="."))Q(L g 1p i)6.1V(e,g+(h||""));N{7(h.U){f=h.2q;h=h.U}E.R(h.23(/\\s+/),J(b,a){L c=a.23(".");a=c[0];7(i[a]){7(f)2V i[a][f.2D];N Q(f 1p i[a])7(!c[1]||i[a][f].U==c[1])2V i[a][f];Q(29 1p i[a])1Q;7(!29){7(!E.16.2y[a]||E.16.2y[a].4h.1P(e)===S){7(e.67)e.67(a,E.O(e,"1v"),S);N 7(e.66)e.66("4i"+a,E.O(e,"1v"))}29=V;2V i[a]}}})}Q(29 1p i)1Q;7(!29){L d=E.O(e,"1v");7(d)d.Y=V;E.35(e,"2R");E.35(e,"1v")}}},1N:J(g,c,d,f,h){c=E.2I(c||[]);7(g.1f("!")>=0){g=g.2K(0,-1);L a=P}7(!d){7(6.2a[g])E("*").1b([1e,T]).1N(g,c)}N{7(d.15==3||d.15==8)K 10;L b,29,1n=E.1q(d[g]||V),16=!c[0]||!c[0].36;7(16)c.4J(6.4Z({U:g,2L:d}));c[0].U=g;7(a)c[0].65=P;7(E.1q(E.O(d,"1v")))b=E.O(d,"1v").1i(d,c);7(!1n&&d["4i"+g]&&d["4i"+g].1i(d,c)===S)b=S;7(16)c.4l();7(h&&E.1q(h)){29=h.1i(d,b==V?c:c.71(b));7(29!==10)b=29}7(1n&&f!==S&&b!==S&&!(E.12(d,\'a\')&&g=="4V")){6.5f=P;1S{d[g]()}1X(e){}}6.5f=S}K b},1v:J(c){L a;c=E.16.4Z(c||1e.16||{});L b=c.U.23(".");c.U=b[0];L f=E.O(6,"2R")&&E.O(6,"2R")[c.U],42=1M.2l.2K.1P(18,1);42.4J(c);Q(L j 1p f){L d=f[j];42[0].2q=d;42[0].O=d.O;7(!b[1]&&!c.65||d.U==b[1]){L e=d.1i(6,42);7(a!==S)a=e;7(e===S){c.36();c.44()}}}7(E.14.1d)c.2L=c.36=c.44=c.2q=c.O=V;K a},4Z:J(c){L a=c;c=E.1s({},a);c.36=J(){7(a.36)a.36();a.7S=S};c.44=J(){7(a.44)a.44();a.7R=P};7(!c.2L)c.2L=c.7Q||T;7(c.2L.15==3)c.2L=a.2L.1a;7(!c.4S&&c.5w)c.4S=c.5w==c.2L?c.7P:c.5w;7(c.64==V&&c.63!=V){L b=T.1F,1h=T.1h;c.64=c.63+(b&&b.2v||1h&&1h.2v||0)-(b.62||0);c.7N=c.7L+(b&&b.2x||1h&&1h.2x||0)-(b.60||0)}7(!c.3c&&((c.4f||c.4f===0)?c.4f:c.5Z))c.3c=c.4f||c.5Z;7(!c.7b&&c.5Y)c.7b=c.5Y;7(!c.3c&&c.2G)c.3c=(c.2G&1?1:(c.2G&2?3:(c.2G&4?2:0)));K c},2y:{21:{4j:J(){5M();K},4h:J(){K}},3C:{4j:J(){7(E.14.1d)K S;E(6).2j("4P",E.16.2y.3C.2q);K P},4h:J(){7(E.14.1d)K S;E(6).3w("4P",E.16.2y.3C.2q);K P},2q:J(a){7(I(a,6))K P;18[0].U="3C";K E.16.1v.1i(6,18)}},3B:{4j:J(){7(E.14.1d)K S;E(6).2j("4O",E.16.2y.3B.2q);K P},4h:J(){7(E.14.1d)K S;E(6).3w("4O",E.16.2y.3B.2q);K P},2q:J(a){7(I(a,6))K P;18[0].U="3B";K E.16.1v.1i(6,18)}}}};E.1n.1s({2j:J(c,a,b){K c=="4H"?6.2X(c,a,b):6.R(J(){E.16.1b(6,c,b||a,b&&a)})},2X:J(d,b,c){K 6.R(J(){E.16.1b(6,d,J(a){E(6).3w(a);K(c||b).1i(6,18)},c&&b)})},3w:J(a,b){K 6.R(J(){E.16.1V(6,a,b)})},1N:J(c,a,b){K 6.R(J(){E.16.1N(c,a,6,P,b)})},5n:J(c,a,b){7(6[0])K E.16.1N(c,a,6[0],S,b);K 10},2g:J(){L b=18;K 6.4V(J(a){6.4N=0==6.4N?1:0;a.36();K b[6.4N].1i(6,18)||S})},7D:J(a,b){K 6.2j(\'3C\',a).2j(\'3B\',b)},21:J(a){5M();7(E.2Q)a.1P(T,E);N E.3A.1g(J(){K a.1P(6,E)});K 6}});E.1s({2Q:S,3A:[],21:J(){7(!E.2Q){E.2Q=P;7(E.3A){E.R(E.3A,J(){6.1i(T)});E.3A=V}E(T).5n("21")}}});L x=S;J 5M(){7(x)K;x=P;7(T.3F&&!E.14.2z)T.3F("5W",E.21,S);7(E.14.1d&&1e==3b)(J(){7(E.2Q)K;1S{T.1F.7B("26")}1X(3a){3z(18.3R,0);K}E.21()})();7(E.14.2z)T.3F("5W",J(){7(E.2Q)K;Q(L i=0;i<T.4L.M;i++)7(T.4L[i].2Y){3z(18.3R,0);K}E.21()},S);7(E.14.2d){L a;(J(){7(E.2Q)K;7(T.39!="5V"&&T.39!="1y"){3z(18.3R,0);K}7(a===10)a=E("W, 7a[7A=7z]").M;7(T.4L.M!=a){3z(18.3R,0);K}E.21()})()}E.16.1b(1e,"3U",E.21)}E.R(("7y,7x,3U,7w,5d,4H,4V,7v,"+"7G,7u,7t,4P,4O,7s,2k,"+"58,7K,7q,7p,3a").23(","),J(i,b){E.1n[b]=J(a){K a?6.2j(b,a):6.1N(b)}});L I=J(a,c){L b=a.4S;2b(b&&b!=c)1S{b=b.1a}1X(3a){b=c}K b==c};E(1e).2j("4H",J(){E("*").1b(T).3w()});E.1n.1s({3U:J(g,d,c){7(E.1q(g))K 6.2j("3U",g);L e=g.1f(" ");7(e>=0){L i=g.2K(e,g.M);g=g.2K(0,e)}c=c||J(){};L f="4Q";7(d)7(E.1q(d)){c=d;d=V}N{d=E.3m(d);f="61"}L h=6;E.3P({1c:g,U:f,1H:"3q",O:d,1y:J(a,b){7(b=="1W"||b=="5U")h.3q(i?E("<1x/>").3t(a.4b.1r(/<1m(.|\\s)*?\\/1m>/g,"")).2s(i):a.4b);h.R(c,[a.4b,b,a])}});K 6},7n:J(){K E.3m(6.5T())},5T:J(){K 6.2c(J(){K E.12(6,"3u")?E.2I(6.7m):6}).1E(J(){K 6.31&&!6.2Y&&(6.3k||/2k|6h/i.17(6.12)||/1u|1Z|3I/i.17(6.U))}).2c(J(i,c){L b=E(6).5O();K b==V?V:b.1k==1M?E.2c(b,J(a,i){K{31:c.31,1A:a}}):{31:c.31,1A:b}}).22()}});E.R("5S,6d,5R,6D,5Q,6m".23(","),J(i,o){E.1n[o]=J(f){K 6.2j(o,f)}});L B=(1B 3v).3L();E.1s({22:J(d,b,a,c){7(E.1q(b)){a=b;b=V}K E.3P({U:"4Q",1c:d,O:b,1W:a,1H:c})},7l:J(b,a){K E.22(b,V,a,"1m")},7k:J(c,b,a){K E.22(c,b,a,"3i")},7i:J(d,b,a,c){7(E.1q(b)){a=b;b={}}K E.3P({U:"61",1c:d,O:b,1W:a,1H:c})},85:J(a){E.1s(E.4I,a)},4I:{2a:P,U:"4Q",2U:0,5P:"4o/x-7h-3u-7g",5N:P,3l:P,O:V,6p:V,3I:V,49:{3M:"4o/3M, 1u/3M",3q:"1u/3q",1m:"1u/4m, 4o/4m",3i:"4o/3i, 1u/4m",1u:"1u/a7",4G:"*/*"}},4F:{},3P:J(s){L f,2W=/=\\?(&|$)/g,1z,O;s=E.1s(P,s,E.1s(P,{},E.4I,s));7(s.O&&s.5N&&1o s.O!="25")s.O=E.3m(s.O);7(s.1H=="4E"){7(s.U.2h()=="22"){7(!s.1c.1D(2W))s.1c+=(s.1c.1D(/\\?/)?"&":"?")+(s.4E||"7d")+"=?"}N 7(!s.O||!s.O.1D(2W))s.O=(s.O?s.O+"&":"")+(s.4E||"7d")+"=?";s.1H="3i"}7(s.1H=="3i"&&(s.O&&s.O.1D(2W)||s.1c.1D(2W))){f="4E"+B++;7(s.O)s.O=(s.O+"").1r(2W,"="+f+"$1");s.1c=s.1c.1r(2W,"="+f+"$1");s.1H="1m";1e[f]=J(a){O=a;1W();1y();1e[f]=10;1S{2V 1e[f]}1X(e){}7(h)h.34(g)}}7(s.1H=="1m"&&s.1T==V)s.1T=S;7(s.1T===S&&s.U.2h()=="22"){L i=(1B 3v()).3L();L j=s.1c.1r(/(\\?|&)4r=.*?(&|$)/,"$a4="+i+"$2");s.1c=j+((j==s.1c)?(s.1c.1D(/\\?/)?"&":"?")+"4r="+i:"")}7(s.O&&s.U.2h()=="22"){s.1c+=(s.1c.1D(/\\?/)?"&":"?")+s.O;s.O=V}7(s.2a&&!E.5H++)E.16.1N("5S");7((!s.1c.1f("a3")||!s.1c.1f("//"))&&s.1H=="1m"&&s.U.2h()=="22"){L h=T.3S("6f")[0];L g=T.3s("1m");g.3Q=s.1c;7(s.7c)g.a2=s.7c;7(!f){L l=S;g.9Z=g.9Y=J(){7(!l&&(!6.39||6.39=="5V"||6.39=="1y")){l=P;1W();1y();h.34(g)}}}h.38(g);K 10}L m=S;L k=1e.78?1B 78("9X.9V"):1B 76();k.9T(s.U,s.1c,s.3l,s.6p,s.3I);1S{7(s.O)k.4C("9R-9Q",s.5P);7(s.5C)k.4C("9O-5A-9N",E.4F[s.1c]||"9L, 9K 9I 9H 5z:5z:5z 9F");k.4C("X-9C-9A","76");k.4C("9z",s.1H&&s.49[s.1H]?s.49[s.1H]+", */*":s.49.4G)}1X(e){}7(s.6Y)s.6Y(k);7(s.2a)E.16.1N("6m",[k,s]);L c=J(a){7(!m&&k&&(k.39==4||a=="2U")){m=P;7(d){6I(d);d=V}1z=a=="2U"&&"2U"||!E.6X(k)&&"3a"||s.5C&&E.6J(k,s.1c)&&"5U"||"1W";7(1z=="1W"){1S{O=E.6W(k,s.1H)}1X(e){1z="5x"}}7(1z=="1W"){L b;1S{b=k.5q("6U-5A")}1X(e){}7(s.5C&&b)E.4F[s.1c]=b;7(!f)1W()}N E.5v(s,k,1z);1y();7(s.3l)k=V}};7(s.3l){L d=53(c,13);7(s.2U>0)3z(J(){7(k){k.9t();7(!m)c("2U")}},s.2U)}1S{k.9s(s.O)}1X(e){E.5v(s,k,V,e)}7(!s.3l)c();J 1W(){7(s.1W)s.1W(O,1z);7(s.2a)E.16.1N("5Q",[k,s])}J 1y(){7(s.1y)s.1y(k,1z);7(s.2a)E.16.1N("5R",[k,s]);7(s.2a&&!--E.5H)E.16.1N("6d")}K k},5v:J(s,a,b,e){7(s.3a)s.3a(a,b,e);7(s.2a)E.16.1N("6D",[a,s,e])},5H:0,6X:J(r){1S{K!r.1z&&9q.9p=="59:"||(r.1z>=6T&&r.1z<9n)||r.1z==6R||r.1z==9l||E.14.2d&&r.1z==10}1X(e){}K S},6J:J(a,c){1S{L b=a.5q("6U-5A");K a.1z==6R||b==E.4F[c]||E.14.2d&&a.1z==10}1X(e){}K S},6W:J(r,b){L c=r.5q("9k-U");L d=b=="3M"||!b&&c&&c.1f("3M")>=0;L a=d?r.9j:r.4b;7(d&&a.1F.28=="5x")6Q"5x";7(b=="1m")E.5g(a);7(b=="3i")a=6c("("+a+")");K a},3m:J(a){L s=[];7(a.1k==1M||a.5h)E.R(a,J(){s.1g(3r(6.31)+"="+3r(6.1A))});N Q(L j 1p a)7(a[j]&&a[j].1k==1M)E.R(a[j],J(){s.1g(3r(j)+"="+3r(6))});N s.1g(3r(j)+"="+3r(a[j]));K s.6a("&").1r(/%20/g,"+")}});E.1n.1s({1G:J(c,b){K c?6.2e({1R:"1G",27:"1G",1w:"1G"},c,b):6.1E(":1Z").R(J(){6.W.19=6.5s||"";7(E.1j(6,"19")=="2H"){L a=E("<"+6.28+" />").6y("1h");6.W.19=a.1j("19");7(6.W.19=="2H")6.W.19="3D";a.1V()}}).3h()},1I:J(b,a){K b?6.2e({1R:"1I",27:"1I",1w:"1I"},b,a):6.1E(":4d").R(J(){6.5s=6.5s||E.1j(6,"19");6.W.19="2H"}).3h()},6N:E.1n.2g,2g:J(a,b){K E.1q(a)&&E.1q(b)?6.6N(a,b):a?6.2e({1R:"2g",27:"2g",1w:"2g"},a,b):6.R(J(){E(6)[E(6).3H(":1Z")?"1G":"1I"]()})},9f:J(b,a){K 6.2e({1R:"1G"},b,a)},9d:J(b,a){K 6.2e({1R:"1I"},b,a)},9c:J(b,a){K 6.2e({1R:"2g"},b,a)},9a:J(b,a){K 6.2e({1w:"1G"},b,a)},99:J(b,a){K 6.2e({1w:"1I"},b,a)},97:J(c,a,b){K 6.2e({1w:a},c,b)},2e:J(l,k,j,h){L i=E.6P(k,j,h);K 6[i.2P===S?"R":"2P"](J(){7(6.15!=1)K S;L g=E.1s({},i);L f=E(6).3H(":1Z"),4A=6;Q(L p 1p l){7(l[p]=="1I"&&f||l[p]=="1G"&&!f)K E.1q(g.1y)&&g.1y.1i(6);7(p=="1R"||p=="27"){g.19=E.1j(6,"19");g.32=6.W.32}}7(g.32!=V)6.W.32="1Z";g.40=E.1s({},l);E.R(l,J(c,a){L e=1B E.2t(4A,g,c);7(/2g|1G|1I/.17(a))e[a=="2g"?f?"1G":"1I":a](l);N{L b=a.3X().1D(/^([+-]=)?([\\d+-.]+)(.*)$/),1Y=e.2m(P)||0;7(b){L d=2M(b[2]),2A=b[3]||"2S";7(2A!="2S"){4A.W[c]=(d||1)+2A;1Y=((d||1)/e.2m(P))*1Y;4A.W[c]=1Y+2A}7(b[1])d=((b[1]=="-="?-1:1)*d)+1Y;e.45(1Y,d,2A)}N e.45(1Y,a,"")}});K P})},2P:J(a,b){7(E.1q(a)||(a&&a.1k==1M)){b=a;a="2t"}7(!a||(1o a=="25"&&!b))K A(6[0],a);K 6.R(J(){7(b.1k==1M)A(6,a,b);N{A(6,a).1g(b);7(A(6,a).M==1)b.1i(6)}})},94:J(b,c){L a=E.3G;7(b)6.2P([]);6.R(J(){Q(L i=a.M-1;i>=0;i--)7(a[i].Y==6){7(c)a[i](P);a.72(i,1)}});7(!c)6.5p();K 6}});L A=J(b,c,a){7(!b)K 10;c=c||"2t";L q=E.O(b,c+"2P");7(!q||a)q=E.O(b,c+"2P",a?E.2I(a):[]);K q};E.1n.5p=J(a){a=a||"2t";K 6.R(J(){L q=A(6,a);q.4l();7(q.M)q[0].1i(6)})};E.1s({6P:J(b,a,c){L d=b&&b.1k==92?b:{1y:c||!c&&a||E.1q(b)&&b,2u:b,3Z:c&&a||a&&a.1k!=91&&a};d.2u=(d.2u&&d.2u.1k==51?d.2u:{90:8Z,9D:6T}[d.2u])||8X;d.5y=d.1y;d.1y=J(){7(d.2P!==S)E(6).5p();7(E.1q(d.5y))d.5y.1i(6)};K d},3Z:{70:J(p,n,b,a){K b+a*p},5j:J(p,n,b,a){K((-24.8V(p*24.8U)/2)+0.5)*a+b}},3G:[],3W:V,2t:J(b,c,a){6.11=c;6.Y=b;6.1l=a;7(!c.47)c.47={}}});E.2t.2l={4y:J(){7(6.11.30)6.11.30.1i(6.Y,[6.2J,6]);(E.2t.30[6.1l]||E.2t.30.4G)(6);7(6.1l=="1R"||6.1l=="27")6.Y.W.19="3D"},2m:J(a){7(6.Y[6.1l]!=V&&6.Y.W[6.1l]==V)K 6.Y[6.1l];L r=2M(E.1j(6.Y,6.1l,a));K r&&r>-8Q?r:2M(E.2o(6.Y,6.1l))||0},45:J(c,b,d){6.5B=(1B 3v()).3L();6.1Y=c;6.3h=b;6.2A=d||6.2A||"2S";6.2J=6.1Y;6.4B=6.4w=0;6.4y();L e=6;J t(a){K e.30(a)}t.Y=6.Y;E.3G.1g(t);7(E.3W==V){E.3W=53(J(){L a=E.3G;Q(L i=0;i<a.M;i++)7(!a[i]())a.72(i--,1);7(!a.M){6I(E.3W);E.3W=V}},13)}},1G:J(){6.11.47[6.1l]=E.1J(6.Y.W,6.1l);6.11.1G=P;6.45(0,6.2m());7(6.1l=="27"||6.1l=="1R")6.Y.W[6.1l]="8N";E(6.Y).1G()},1I:J(){6.11.47[6.1l]=E.1J(6.Y.W,6.1l);6.11.1I=P;6.45(6.2m(),0)},30:J(a){L t=(1B 3v()).3L();7(a||t>6.11.2u+6.5B){6.2J=6.3h;6.4B=6.4w=1;6.4y();6.11.40[6.1l]=P;L b=P;Q(L i 1p 6.11.40)7(6.11.40[i]!==P)b=S;7(b){7(6.11.19!=V){6.Y.W.32=6.11.32;6.Y.W.19=6.11.19;7(E.1j(6.Y,"19")=="2H")6.Y.W.19="3D"}7(6.11.1I)6.Y.W.19="2H";7(6.11.1I||6.11.1G)Q(L p 1p 6.11.40)E.1J(6.Y.W,p,6.11.47[p])}7(b&&E.1q(6.11.1y))6.11.1y.1i(6.Y);K S}N{L n=t-6.5B;6.4w=n/6.11.2u;6.4B=E.3Z[6.11.3Z||(E.3Z.5j?"5j":"70")](6.4w,n,0,1,6.11.2u);6.2J=6.1Y+((6.3h-6.1Y)*6.4B);6.4y()}K P}};E.2t.30={2v:J(a){a.Y.2v=a.2J},2x:J(a){a.Y.2x=a.2J},1w:J(a){E.1J(a.Y.W,"1w",a.2J)},4G:J(a){a.Y.W[a.1l]=a.2J+a.2A}};E.1n.5L=J(){L b=0,3b=0,Y=6[0],5l;7(Y)8M(E.14){L d=Y.1a,41=Y,1K=Y.1K,1L=Y.2i,5D=2d&&4s(5K)<8J&&!/a1/i.17(v),2T=E.1j(Y,"43")=="2T";7(Y.6G){L c=Y.6G();1b(c.26+24.2f(1L.1F.2v,1L.1h.2v),c.3b+24.2f(1L.1F.2x,1L.1h.2x));1b(-1L.1F.62,-1L.1F.60)}N{1b(Y.5G,Y.5F);2b(1K){1b(1K.5G,1K.5F);7(48&&!/^t(8H|d|h)$/i.17(1K.28)||2d&&!5D)2N(1K);7(!2T&&E.1j(1K,"43")=="2T")2T=P;41=/^1h$/i.17(1K.28)?41:1K;1K=1K.1K}2b(d&&d.28&&!/^1h|3q$/i.17(d.28)){7(!/^8G|1O.*$/i.17(E.1j(d,"19")))1b(-d.2v,-d.2x);7(48&&E.1j(d,"32")!="4d")2N(d);d=d.1a}7((5D&&(2T||E.1j(41,"43")=="4W"))||(48&&E.1j(41,"43")!="4W"))1b(-1L.1h.5G,-1L.1h.5F);7(2T)1b(24.2f(1L.1F.2v,1L.1h.2v),24.2f(1L.1F.2x,1L.1h.2x))}5l={3b:3b,26:b}}J 2N(a){1b(E.2o(a,"a8",P),E.2o(a,"a9",P))}J 1b(l,t){b+=4s(l)||0;3b+=4s(t)||0}K 5l}})();',62,631,'||||||this|if||||||||||||||||||||||||||||||||||||||function|return|var|length|else|data|true|for|each|false|document|type|null|style||elem||undefined|options|nodeName||browser|nodeType|event|test|arguments|display|parentNode|add|url|msie|window|indexOf|push|body|apply|css|constructor|prop|script|fn|typeof|in|isFunction|replace|extend|className|text|handle|opacity|div|complete|status|value|new|firstChild|match|filter|documentElement|show|dataType|hide|attr|offsetParent|doc|Array|trigger|table|call|break|height|try|cache|tbody|remove|success|catch|start|hidden||ready|get|split|Math|string|left|width|tagName|ret|global|while|map|safari|animate|max|toggle|toLowerCase|ownerDocument|bind|select|prototype|cur||curCSS|selected|handler|done|find|fx|duration|scrollLeft|id|scrollTop|special|opera|unit|nextSibling|stack|guid|toUpperCase|pushStack|button|none|makeArray|now|slice|target|parseFloat|border|exec|queue|isReady|events|px|fixed|timeout|delete|jsre|one|disabled|nth|step|name|overflow|inArray|removeChild|removeData|preventDefault|merge|appendChild|readyState|error|top|which|innerHTML|multiFilter|rl|trim|end|json|first|checked|async|param|elems|insertBefore|childNodes|html|encodeURIComponent|createElement|append|form|Date|unbind|color|grep|setTimeout|readyList|mouseleave|mouseenter|block|isXMLDoc|addEventListener|timers|is|password|last|runtimeStyle|getTime|xml|jQuery|domManip|ajax|src|callee|getElementsByTagName|selectedIndex|load|object|timerId|toString|has|easing|curAnim|offsetChild|args|position|stopPropagation|custom|props|orig|mozilla|accepts|clean|responseText|defaultView|visible|String|charCode|float|teardown|on|setup|nodeIndex|shift|javascript|currentStyle|application|child|RegExp|_|parseInt|previousSibling|dir|tr|state|empty|update|getAttribute|self|pos|setRequestHeader|input|jsonp|lastModified|_default|unload|ajaxSettings|unshift|getComputedStyle|styleSheets|getPropertyValue|lastToggle|mouseout|mouseover|GET|andSelf|relatedTarget|init|visibility|click|absolute|index|container|fix|outline|Number|removeAttribute|setInterval|prevObject|classFilter|not|unique|submit|file|after|windowData|deep|scroll|client|triggered|globalEval|jquery|sibling|swing|clone|results|wrapAll|triggerHandler|lastChild|dequeue|getResponseHeader|createTextNode|oldblock|checkbox|radio|handleError|fromElement|parsererror|old|00|Modified|startTime|ifModified|safari2|getWH|offsetTop|offsetLeft|active|values|getElementById|version|offset|bindReady|processData|val|contentType|ajaxSuccess|ajaxComplete|ajaxStart|serializeArray|notmodified|loaded|DOMContentLoaded|Width|ctrlKey|keyCode|clientTop|POST|clientLeft|clientX|pageX|exclusive|detachEvent|removeEventListener|swap|cloneNode|join|attachEvent|eval|ajaxStop|substr|head|parse|textarea|reset|image|zoom|odd|ajaxSend|even|before|username|prepend|expr|quickClass|uuid|quickID|quickChild|continue|textContent|appendTo|contents|evalScript|parent|defaultValue|ajaxError|setArray|compatMode|getBoundingClientRect|styleFloat|clearInterval|httpNotModified|nodeValue|100|alpha|_toggle|href|speed|throw|304|replaceWith|200|Last|colgroup|httpData|httpSuccess|beforeSend|eq|linear|concat|splice|fieldset|multiple|cssFloat|XMLHttpRequest|webkit|ActiveXObject|CSS1Compat|link|metaKey|scriptCharset|callback|col|pixelLeft|urlencoded|www|post|hasClass|getJSON|getScript|elements|serialize|black|keyup|keypress|solid|change|mousemove|mouseup|dblclick|resize|focus|blur|stylesheet|rel|doScroll|round|hover|padding|offsetHeight|mousedown|offsetWidth|Bottom|Top|keydown|clientY|Right|pageY|Left|toElement|srcElement|cancelBubble|returnValue|charAt|0n|substring|animated|header|noConflict|line|enabled|innerText|contains|only|weight|ajaxSetup|font|size|gt|lt|uFFFF|u0128|417|Boolean|inner|Height|toggleClass|removeClass|addClass|removeAttr|replaceAll|insertAfter|prependTo|contentWindow|contentDocument|wrap|iframe|children|siblings|prevAll|nextAll|prev|wrapInner|next|parents|maxLength|maxlength|readOnly|readonly|reverse|class|htmlFor|inline|able|boxModel|522|setData|compatible|with|1px|ie|getData|10000|ra|it|rv|PI|cos|userAgent|400|navigator|600|slow|Function|Object|array|stop|ig|NaN|fadeTo|option|fadeOut|fadeIn|setAttribute|slideToggle|slideUp|changed|slideDown|be|can|property|responseXML|content|1223|getAttributeNode|300|method|protocol|location|action|send|abort|cssText|th|td|cap|specified|Accept|With|colg|Requested|fast|tfoot|GMT|thead|1970|Jan|attributes|01|Thu|leg|Since|If|opt|Type|Content|embed|open|area|XMLHTTP|hr|Microsoft|onreadystatechange|onload|meta|adobeair|charset|http|1_|img|br|plain|borderLeftWidth|borderTopWidth|abbr'.split('|'),0,{}))
\ No newline at end of file
diff --git a/sites/static.scrapy.org/js/keyboard_nav.js b/sites/static.scrapy.org/js/keyboard_nav.js
deleted file mode 100644
index 9719888e4..000000000
--- a/sites/static.scrapy.org/js/keyboard_nav.js
+++ /dev/null
@@ -1,61 +0,0 @@
-(function($){
- var SELECTED_FILE_ELEM = null;
- var ENABLE_KEY_NAV = true;
-
- $(document).keydown(function(event) {
- if (!ENABLE_KEY_NAV)
- return true;
- var selection = SELECTED_FILE_ELEM;
- switch (event.keyCode) {
- case 74: // j
- if (selection == null) {
- selection = $('#f0');
- } else {
- do {
- selection = selection.next();
- } while (selection.length > 0 && selection.css('display') == 'none');
- }
- break;
- case 75: // k
- if (selection == null) {
- selection = $('#f0');
- } else {
- do {
- selection = selection.prev();
- } while (selection.length > 0 && selection.css('display') == 'none');
- }
- break;
- case 13: // Enter
- case 79: // o
- if (selection != null) {
- var expander = selection.find('.expander');
- if (expander.length > 0) {
- expander.click();
- } else {
- window.location = selection.find('a.file').attr('href');
- }
- }
- return false;
- break;
- default:
- return true;
- }
- if (selection.length > 0) {
- if (SELECTED_FILE_ELEM != null)
- SELECTED_FILE_ELEM.removeClass('focus');
- selection.addClass('focus');
- SELECTED_FILE_ELEM = selection;
- }
- return false;
- });
-
- $(function() {
- $('a,input,select,textarea,button')
- .focus(function(event) {
- ENABLE_KEY_NAV = false;
- })
- .blur(function(event) {
- ENABLE_KEY_NAV = true;
- });
- });
-})(jQuery);
diff --git a/sites/static.scrapy.org/js/noconflict.js b/sites/static.scrapy.org/js/noconflict.js
deleted file mode 100644
index 8e4a663c2..000000000
--- a/sites/static.scrapy.org/js/noconflict.js
+++ /dev/null
@@ -1,3 +0,0 @@
-jQuery.noConflict(); // jQuery is now removed from the $ namespace
- // to use the $ shorthand, use (function($){ ... })(jQuery);
- // and for the onload handler: jQuery(function($){ ... });
\ No newline at end of file
diff --git a/sites/static.scrapy.org/js/query.js b/sites/static.scrapy.org/js/query.js
deleted file mode 100644
index a8b97d96c..000000000
--- a/sites/static.scrapy.org/js/query.js
+++ /dev/null
@@ -1,278 +0,0 @@
-
-(function($){
-
- window.initializeFilters = function() {
-
- // Bail early for Konqueror and IE5.2/Mac, which don't fully support dynamic
- // creation of form controls
- try {
- var test = document.createElement("input");
- test.type = "button";
- if (test.type != "button") throw Error();
- } catch (e) {
- return;
- }
-
- // Removes an existing row from the filters table
- function removeRow(button, propertyName) {
- var tr = getAncestorByTagName(button, "tr");
-
- var mode = null;
- var selects = tr.getElementsByTagName("select");
- for (var i = 0; i < selects.length; i++) {
- if (selects[i].name == propertyName + "_mode") {
- mode = selects[i];
- break;
- }
- }
- if (mode && (getAncestorByTagName(mode, "tr") == tr)) {
- // Check whether there are more 'or' rows for this filter
- var next = tr.nextSibling;
- if (next && (next.className == propertyName)) {
- function getChildElementAt(e, idx) {
- e = e.firstChild;
- var cur = 0;
- while (cur <= idx) {
- while (e && e.nodeType != 1) e = e.nextSibling;
- if (cur++ == idx) break;
- e = e.nextSibling;
- }
- return e;
- }
-
- var thisTh = getChildElementAt(tr, 0);
- var nextTh = getChildElementAt(next, 0);
- next.insertBefore(thisTh, nextTh);
- nextTh.colSpan = 1;
-
- thisTd = getChildElementAt(tr, 0);
- nextTd = getChildElementAt(next, 1);
- next.replaceChild(thisTd, nextTd);
- }
- }
-
- var tBody = tr.parentNode;
- tBody.deleteRow(tr.sectionRowIndex);
- if (!tBody.rows.length) {
- tBody.parentNode.removeChild(tBody);
- }
-
- if (propertyName) {
- var select = document.forms["query"].elements["add_filter"];
- for (var i = 0; i < select.options.length; i++) {
- var option = select.options[i];
- if (option.value == propertyName) option.disabled = false;
- }
- }
- }
-
- // Initializes a filter row, the 'input' parameter is the submit
- // button for removing the filter
- function initializeFilter(input) {
- var removeButton = document.createElement("input");
- removeButton.type = "button";
- removeButton.value = input.value;
- if (input.name.substr(0, 10) == "rm_filter_") {
- removeButton.onclick = function() {
- var endIndex = input.name.search(/_\d+$/);
- if (endIndex < 0) endIndex = input.name.length;
- removeRow(removeButton, input.name.substring(10, endIndex));
- return false;
- }
- } else {
- removeButton.onclick = function() {
- removeRow(removeButton);
- return false;
- }
- }
- input.parentNode.replaceChild(removeButton, input);
- }
-
- // Make the submit buttons for removing filters client-side triggers
- var filters = document.getElementById("filters");
- var inputs = filters.getElementsByTagName("input");
- for (var i = 0; i < inputs.length; i++) {
- var input = inputs[i];
- if (input.type == "submit" && input.name
- && input.name.match(/^rm_filter_/)) {
- initializeFilter(input);
- }
- }
-
- // Make the drop-down menu for adding a filter a client-side trigger
- var addButton = document.forms["query"].elements["add"];
- addButton.parentNode.removeChild(addButton);
- var select = document.getElementById("add_filter");
- select.onchange = function() {
- if (select.selectedIndex < 1) return;
-
- if (select.options[select.selectedIndex].disabled) {
- // Neither IE nor Safari supported disabled options at the time this was
- // written, so alert the user
- alert("A filter already exists for that property");
- return;
- }
-
- // Convenience function for creating a <label>
- function createLabel(text, htmlFor) {
- var label = document.createElement("label");
- if (text) label.appendChild(document.createTextNode(text));
- if (htmlFor) label.htmlFor = htmlFor;
- return label;
- }
-
- // Convenience function for creating an <input type="checkbox">
- function createCheckbox(name, value, id) {
- var input = document.createElement("input");
- input.type = "checkbox";
- if (name) input.name = name;
- if (value) input.value = value;
- if (id) input.id = id;
- return input;
- }
-
- // Convenience function for creating an <input type="radio">
- function createRadio(name, value, id) {
- var str = '<input type="radio"';
- if (name) str += ' name="' + name + '"';
- if (value) str += ' value="' + value + '"';
- if (id) str += ' id="' + id + '"';
- str += '/>';
- var span = document.createElement('span');
- // create radio button with innerHTML to avoid IE mangling it.
- span.innerHTML = str;
- return span;
- }
-
- // Convenience function for creating a <select>
- function createSelect(name, options, optional) {
- var e = document.createElement("select");
- if (name) e.name = name;
- if (optional) e.options[0] = new Option();
- if (options) {
- for (var i = 0; i < options.length; i++) {
- var option;
- if (typeof(options[i]) == "object") {
- option = new Option(options[i].text, options[i].value);
- } else {
- option = new Option(options[i], options[i]);
- }
- e.options[e.options.length] = option;
- }
- }
- return e;
- }
-
- var propertyName = select.options[select.selectedIndex].value;
- var property = properties[propertyName];
- var table = document.getElementById("filters").getElementsByTagName("table")[0];
- var tr = document.createElement("tr");
- tr.className = propertyName;
-
- var alreadyPresent = false;
- for (var i = 0; i < table.rows.length; i++) {
- if (table.rows[i].className == propertyName) {
- var existingTBody = table.rows[i].parentNode;
- alreadyPresent = true;
- break;
- }
- }
-
- // Add the row header
- var th = document.createElement("th");
- th.scope = "row";
- if (!alreadyPresent) {
- th.appendChild(createLabel(property.label));
- } else {
- th.colSpan = 2;
- th.appendChild(createLabel("or"));
- }
- tr.appendChild(th);
-
- var td = document.createElement("td");
- if (property.type == "radio" || property.type == "checkbox") {
- td.colSpan = 2;
- td.className = "filter";
- if (property.type == "radio") {
- for (var i = 0; i < property.options.length; i++) {
- var option = property.options[i];
- td.appendChild(createCheckbox(propertyName, option,
- propertyName + "_" + option));
- td.appendChild(createLabel(option ? option : "none",
- propertyName + "_" + option));
- }
- } else {
- td.appendChild(createRadio(propertyName, "1", propertyName + "_on"));
- td.appendChild(document.createTextNode(" "));
- td.appendChild(createLabel("yes", propertyName + "_on"));
- td.appendChild(createRadio(propertyName, "0", propertyName + "_off"));
- td.appendChild(document.createTextNode(" "));
- td.appendChild(createLabel("no", propertyName + "_off"));
- }
- tr.appendChild(td);
- } else {
- if (!alreadyPresent) {
- // Add the mode selector
- td.className = "mode";
- var modeSelect = createSelect(propertyName + "_mode",
- modes[property.type]);
- td.appendChild(modeSelect);
- tr.appendChild(td);
- }
-
- // Add the selector or text input for the actual filter value
- td = document.createElement("td");
- td.className = "filter";
- if (property.type == "select") {
- var element = createSelect(propertyName, property.options, true);
- } else if (property.type == "text") {
- var element = document.createElement("input");
- element.type = "text";
- element.name = propertyName;
- element.size = 42;
- }
- td.appendChild(element);
- element.focus();
- tr.appendChild(td);
- }
-
- // Add the add and remove buttons
- td = document.createElement("td");
- td.className = "actions";
- var removeButton = document.createElement("input");
- removeButton.type = "button";
- removeButton.value = "-";
- removeButton.onclick = function() { removeRow(removeButton, propertyName) };
- td.appendChild(removeButton);
- tr.appendChild(td);
-
- if (alreadyPresent) {
- existingTBody.appendChild(tr);
- } else {
- // Find the insertion point for the new row. We try to keep the filter rows
- // in the same order as the options in the 'Add filter' drop-down, because
- // that's the order they'll appear in when submitted.
- var insertionPoint = getAncestorByTagName(select, "tbody");
- outer: for (var i = select.selectedIndex + 1; i < select.options.length; i++) {
- for (var j = 0; j < table.tBodies.length; j++) {
- if (table.tBodies[j].rows[0].className == select.options[i].value) {
- insertionPoint = table.tBodies[j];
- break outer;
- }
- }
- }
- // Finally add the new row to the table
- var tbody = document.createElement("tbody");
- tbody.appendChild(tr);
- insertionPoint.parentNode.insertBefore(tbody, insertionPoint);
- }
-
- // Disable the add filter in the drop-down list
- if (property.type == "radio" || property.type == "checkbox") {
- select.options[select.selectedIndex].disabled = true;
- }
- select.selectedIndex = 0;
- }
- }
-
-})(jQuery);
\ No newline at end of file
diff --git a/sites/static.scrapy.org/js/search.js b/sites/static.scrapy.org/js/search.js
deleted file mode 100644
index 684bbf059..000000000
--- a/sites/static.scrapy.org/js/search.js
+++ /dev/null
@@ -1,59 +0,0 @@
-
-(function($){
-
- /* Adapted from http://www.kryogenix.org/code/browser/searchhi/ */
- $.fn.highlightText = function(text, className) {
- function highlight(node) {
- if (node.nodeType == 3) { // Node.TEXT_NODE
- var val = node.nodeValue;
- var pos = val.toLowerCase().indexOf(text);
- if (pos >= 0 && !$.className.has(node.parentNode, className)) {
- var span = document.createElement("span");
- span.className = className;
- span.appendChild(document.createTextNode(val.substr(pos, text.length)));
- node.parentNode.insertBefore(span, node.parentNode.insertBefore(
- document.createTextNode(val.substr(pos + text.length)),
- node.nextSibling));
- node.nodeValue = val.substr(0, pos);
- }
- } else if (!$(node).is("button, select, textarea")) {
- $.each(node.childNodes, function() { highlight(this) });
- }
- }
- return this.each(function() { highlight(this) });
- }
-
- $(document).ready(function() {
- var elems = $(".searchable");
- if (!elems.length) return;
-
- function getSearchTerms(url) {
- if (url.indexOf("?") == -1) return [];
- var params = url.substr(url.indexOf("?") + 1).split("&");
- for (var p in params) {
- var param = params[p].split("=");
- if (param.length < 2) continue;
- if (param[0] == "q" || param[0] == "p") { // q= for Google, p= for Yahoo
- var query = decodeURIComponent(param[1].replace(/\+/g, " "));
- if (query[0] == "!") query = query.slice(1);
- var terms = [];
- $.each(query.split(/(".*?")|('.*?')|(\s+)/), function() {
- term = this.replace(/^\s+$/, "");
- if (term.length) {
- terms.push(term.replace(/^['"]/, "").replace(/['"]$/, ""));
- }
- });
- return terms;
- }
- }
- return [];
- }
-
- var terms = getSearchTerms(document.URL);
- if (!terms.length) terms = getSearchTerms(document.referrer);
- $.each(terms, function(idx) {
- elems.highlightText(this.toLowerCase(), "searchword" + (idx % 5));
- });
- });
-
-})(jQuery);
\ No newline at end of file
diff --git a/sites/static.scrapy.org/js/suggest.js b/sites/static.scrapy.org/js/suggest.js
deleted file mode 100644
index 834a1dd7b..000000000
--- a/sites/static.scrapy.org/js/suggest.js
+++ /dev/null
@@ -1,144 +0,0 @@
-
-(function($){
-
-
- /*
- Text field auto-completion plugin for jQuery.
- Based on http://www.dyve.net/jquery/?autocomplete by Dylan Verheul.
- */
- $.suggest = function(input, url, paramName, minChars, delay) {
- var input = $(input).addClass("suggest").attr("autocomplete", "off");
- var timeout = null;
- var prev = "";
- var selectedIndex = -1;
- var results = null;
-
- input.keydown(function(e) {
- switch(e.keyCode) {
- case 27: // escape
- hide();
- break;
- case 38: // up
- case 40: // down
- e.preventDefault();
- if (results) {
- var items = $("li", results);
- if (!items) return;
- var index = selectedIndex + (e.keyCode == 38 ? -1 : 1);
- if (index >= 0 && index < items.length) {
- move(index);
- }
- } else {
- show();
- }
- break;
- case 9: // tab
- case 13: // return
- case 39: // right
- if (results) {
- var li = $("li.selected", results);
- if (li.length) {
- select(li);
- e.preventDefault();
- }
- }
- break;
- default:
- if (timeout) clearTimeout(timeout);
- timeout = setTimeout(show, delay);
- break;
- }
- });
- input.blur(function() {
- if (timeout) clearTimeout(timeout);
- timeout = setTimeout(hide, 200);
- });
-
- function hide() {
- if (timeout) clearTimeout(timeout);
- input.removeClass("loading");
- if (results) {
- results.fadeOut("fast").remove();
- results = null;
- }
- $("iframe.iefix").remove();
- selectedIndex = -1;
- }
-
- function move(index) {
- if (!results) return;
- items = $("li", results);
- items.removeClass("selected");
- $(items[index]).addClass("selected");
- selectedIndex = index;
- }
-
- function select(li) {
- if (!li) li = $("<li>");
- else li = $(li);
- var val = $.trim(li.text());
- prev = val;
- input.val(val);
- hide();
- selectedIndex = -1;
- }
-
- function show() {
- var val = input.val();
- if (val == prev) return;
- prev = val;
- if (val.length < minChars) { hide(); return; }
- input.addClass("loading");
- var params = {};
- params[paramName] = val;
- $.get(url, params, function(data) {
- if (!data) { hide(); return; }
- if (!results) {
- var offset = input.offset();
- results = $("<div>").addClass("suggestions").css({
- position: "absolute",
- minWidth: input.get(0).offsetWidth + "px",
- top: (offset.top + input.get(0).offsetHeight) + "px",
- left: offset.left + "px",
- zIndex: 2
- }).appendTo("body");
- if ($.browser.msie) {
- var iframe = $("<iframe style='display:none;position:absolute;" +
- "filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);'" +
- " class='iefix' src='javascript:false;' frameborder='0'" +
- " scrolling='no'></iframe>").insertAfter(results);
- setTimeout(function() {
- var offset = getOffset(results);
- iframe.css({
- top: offset.top + "px",
- right: (offset.left + results.get(0).offsetWidth) + "px",
- bottom: (offset.top + results.get(0).offsetHeight) + "px",
- left: offset.left + "px",
- zIndex: 1
- });
- iframe.show();
- }, 10);
- }
- }
- results.html(data).fadeTo("fast", 0.92);
- items = $("li", results);
- items
- .hover(function() { move(items.index(this)) },
- function() { $(this).removeClass("selected") })
- .click(function() { select(this); input.get(0).focus() });
- move(0);
- });
- }
- }
-
- $.fn.suggest = function(url, paramName, minChars, delay) {
- url = url || window.location.pathname;
- paramName = paramName || 'q';
- minChars = minChars || 1;
- delay = delay || 400;
- return this.each(function() {
- new $.suggest(this, url, paramName, minChars, delay);
- });
- }
-
-})(jQuery);
diff --git a/sites/static.scrapy.org/js/trac.js b/sites/static.scrapy.org/js/trac.js
deleted file mode 100644
index addb7695a..000000000
--- a/sites/static.scrapy.org/js/trac.js
+++ /dev/null
@@ -1,75 +0,0 @@
-(function($){
-
- $.fn.addAnchor = function(title) {
- title = title || "Link here";
- return this.filter("*[@id]").each(function() {
- $("<a class='anchor'> \u00B6</a>").attr("href", "#" + this.id)
- .attr("title", title).appendTo(this);
- });
- }
-
- $.fn.checked = function(checked) {
- if (checked == undefined) { // getter
- if (!this.length) return false;
- return this.get(0).checked;
- } else { // setter
- return this.each(function() {
- this.checked = checked;
- });
- }
- }
-
- $.fn.enable = function(enabled) {
- if (enabled == undefined) enabled = true;
- return this.each(function() {
- this.disabled = !enabled;
- var label = $(this).parents("label");
- if (!label.length && this.id) {
- label = $("label[@for='" + this.id + "']");
- }
- if (!enabled) {
- label.addClass("disabled");
- } else {
- label.removeClass("disabled");
- }
- });
- }
-
- $.loadStyleSheet = function(href, type) {
- type = type || "text/css";
- $(document).ready(function() {
- if (document.createStyleSheet) { // MSIE
- document.createStyleSheet(href);
- } else {
- $("<link rel='stylesheet' type='" + type + "' href='" + href + "' />")
- .appendTo("head");
- }
- });
- }
-
- // Used for dynamically updating the height of a textarea
- window.resizeTextArea = function (id, rows) {
- var textarea = $("#" + id).get(0);
- if (!textarea || textarea.rows == undefined) return;
- textarea.rows = rows;
- }
-
- // The following are defined for backwards compatibility with releases prior
- // to Trac 0.11
-
- window.addEvent = function(elem, type, func) {
- $(elem).bind(type, func);
- }
- window.addHeadingLinks = function(container, title) {
- $.each(["h1", "h2", "h3", "h4", "h5", "h6"], function() {
- $(this, container).addAnchor(title);
- });
- }
- window.enableControl = function(id, enabled) {
- $("#" + id).enable(enabled);
- }
- window.getAncestorByTagName = function(elem, tagName) {
- return $(elem).parents(tagName).get(0);
- }
-
-})(jQuery);
\ No newline at end of file
diff --git a/sites/static.scrapy.org/js/wikitoolbar.js b/sites/static.scrapy.org/js/wikitoolbar.js
deleted file mode 100644
index 107e4d27a..000000000
--- a/sites/static.scrapy.org/js/wikitoolbar.js
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-(function($){
-
-
- window.addWikiFormattingToolbar = function(textarea) {
- if ((document.selection == undefined)
- && (textarea.setSelectionRange == undefined)) {
- return;
- }
-
- var toolbar = document.createElement("div");
- toolbar.className = "wikitoolbar";
-
- function addButton(id, title, fn) {
- var a = document.createElement("a");
- a.href = "#";
- a.id = id;
- a.title = title;
- a.onclick = function() { try { fn() } catch (e) { } return false };
- a.tabIndex = 400;
- toolbar.appendChild(a);
- }
-
- function encloseSelection(prefix, suffix) {
- textarea.focus();
- var start, end, sel, scrollPos, subst;
- if (document.selection != undefined) {
- sel = document.selection.createRange().text;
- } else if (textarea.setSelectionRange != undefined) {
- start = textarea.selectionStart;
- end = textarea.selectionEnd;
- scrollPos = textarea.scrollTop;
- sel = textarea.value.substring(start, end);
- }
- if (sel.match(/ $/)) { // exclude ending space char, if any
- sel = sel.substring(0, sel.length - 1);
- suffix = suffix + " ";
- }
- subst = prefix + sel + suffix;
- if (document.selection != undefined) {
- var range = document.selection.createRange().text = subst;
- textarea.caretPos -= suffix.length;
- } else if (textarea.setSelectionRange != undefined) {
- textarea.value = textarea.value.substring(0, start) + subst +
- textarea.value.substring(end);
- if (sel) {
- textarea.setSelectionRange(start + subst.length, start + subst.length);
- } else {
- textarea.setSelectionRange(start + prefix.length, start + prefix.length);
- }
- textarea.scrollTop = scrollPos;
- }
- }
-
- addButton("strong", "Bold text: '''Example'''", function() {
- encloseSelection("'''", "'''");
- });
- addButton("em", "Italic text: ''Example''", function() {
- encloseSelection("''", "''");
- });
- addButton("heading", "Heading: == Example ==", function() {
- encloseSelection("\n== ", " ==\n", "Heading");
- });
- addButton("link", "Link: [http://www.example.com/ Example]", function() {
- encloseSelection("[", "]");
- });
- addButton("code", "Code block: {{{ example }}}", function() {
- encloseSelection("\n{{{\n", "\n}}}\n");
- });
- addButton("hr", "Horizontal rule: ----", function() {
- encloseSelection("\n----\n", "");
- });
- addButton("np", "New paragraph", function() {
- encloseSelection("\n\n", "");
- });
- addButton("br", "Line break: [[BR]]", function() {
- encloseSelection("[[BR]]\n", "");
- });
- addButton("img", "Image: [[Image()]]", function() {
- encloseSelection("[[Image(", ")]]");
- });
-
- $(textarea).before(toolbar);
- }
-
-})(jQuery);
-
-// Add the toolbar to all <textarea> elements on the page with the class
-// 'wikitext'.
-jQuery(document).ready(function($) {
- $("textarea.wikitext").each(function() { addWikiFormattingToolbar(this) });
-});
diff --git a/sites/static.scrapy.org/loading.gif b/sites/static.scrapy.org/loading.gif
deleted file mode 100644
index c1eb1c9a2..000000000
Binary files a/sites/static.scrapy.org/loading.gif and /dev/null differ
diff --git a/sites/static.scrapy.org/lock-locked.png b/sites/static.scrapy.org/lock-locked.png
deleted file mode 100644
index d3b5d2434..000000000
Binary files a/sites/static.scrapy.org/lock-locked.png and /dev/null differ
diff --git a/sites/static.scrapy.org/logo.jpg b/sites/static.scrapy.org/logo.jpg
deleted file mode 100644
index c244578fa..000000000
Binary files a/sites/static.scrapy.org/logo.jpg and /dev/null differ
diff --git a/sites/static.scrapy.org/main-bg.jpg b/sites/static.scrapy.org/main-bg.jpg
deleted file mode 100644
index 523edba79..000000000
Binary files a/sites/static.scrapy.org/main-bg.jpg and /dev/null differ
diff --git a/sites/static.scrapy.org/milestone.png b/sites/static.scrapy.org/milestone.png
deleted file mode 100644
index e48a1d131..000000000
Binary files a/sites/static.scrapy.org/milestone.png and /dev/null differ
diff --git a/sites/static.scrapy.org/newticket.png b/sites/static.scrapy.org/newticket.png
deleted file mode 100644
index cc973c44d..000000000
Binary files a/sites/static.scrapy.org/newticket.png and /dev/null differ
diff --git a/sites/static.scrapy.org/parent.png b/sites/static.scrapy.org/parent.png
deleted file mode 100644
index 7ece2987e..000000000
Binary files a/sites/static.scrapy.org/parent.png and /dev/null differ
diff --git a/sites/static.scrapy.org/python.png b/sites/static.scrapy.org/python.png
deleted file mode 100644
index 9d2a8060d..000000000
Binary files a/sites/static.scrapy.org/python.png and /dev/null differ
diff --git a/sites/static.scrapy.org/topbar_gradient.png b/sites/static.scrapy.org/topbar_gradient.png
deleted file mode 100644
index d0605a3ee..000000000
Binary files a/sites/static.scrapy.org/topbar_gradient.png and /dev/null differ
diff --git a/sites/static.scrapy.org/topbar_gradient2.png b/sites/static.scrapy.org/topbar_gradient2.png
deleted file mode 100644
index 5f7ed4ae2..000000000
Binary files a/sites/static.scrapy.org/topbar_gradient2.png and /dev/null differ
diff --git a/sites/static.scrapy.org/trac.ico b/sites/static.scrapy.org/trac.ico
deleted file mode 100644
index 3547a134e..000000000
Binary files a/sites/static.scrapy.org/trac.ico and /dev/null differ
diff --git a/sites/static.scrapy.org/trac_banner.png b/sites/static.scrapy.org/trac_banner.png
deleted file mode 100644
index 3e040983c..000000000
Binary files a/sites/static.scrapy.org/trac_banner.png and /dev/null differ
diff --git a/sites/static.scrapy.org/trac_logo_mini.png b/sites/static.scrapy.org/trac_logo_mini.png
deleted file mode 100644
index 38c038d64..000000000
Binary files a/sites/static.scrapy.org/trac_logo_mini.png and /dev/null differ
diff --git a/sites/static.scrapy.org/vgradient.png b/sites/static.scrapy.org/vgradient.png
deleted file mode 100644
index 6ec350df9..000000000
Binary files a/sites/static.scrapy.org/vgradient.png and /dev/null differ
diff --git a/sites/static.scrapy.org/wiki.png b/sites/static.scrapy.org/wiki.png
deleted file mode 100644
index 8a72b09bb..000000000
Binary files a/sites/static.scrapy.org/wiki.png and /dev/null differ