Permalink
Browse files

Merge remove-google-5768: Remove the deprecated twisted.web.google mo…

…dule.

Author: thijs
Reviewer: spiv
Fixes: #5768

Removes twisted.web.google, which was deprecated in Twisted 11.1, and
associated documentation.


git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@34796 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information...
1 parent 1f8b20a commit 51384b317053bdb2d18cfe596752b32bb7128f32 spiv committed Jul 15, 2012
View
@@ -1,21 +0,0 @@
-# Copyright (c) Twisted Matrix Laboratories
-# See LICENSE for details.
-
-"""
-This program will print out the URL corresponding to the first webpage given by
-a Google search.
-
-Usage:
- $ python google.py <keyword(s)>
-"""
-
-import sys
-
-from twisted.web.google import checkGoogle
-from twisted.python.util import println
-from twisted.internet import reactor
-
-checkGoogle(sys.argv[1:]).addCallbacks(
- lambda l:(println(l),reactor.stop()),
- lambda e:(println('error:',e),reactor.stop()))
-reactor.run()
@@ -85,9 +85,6 @@
distributed web setup with a master and slave using
<code>twisted.web.distrib</code> and
<code>twisted.spread.pb</code></li>
- <li><a href="google.py">google.py</a> - use
- <code>twisted.web.google</code> to get the I'm Feeling Lucky
- page for a search term</li>
<li><a href="soap.py">soap.py</a> - use
<code>twisted.web.soap</code> to publish SOAP methods</li>
</ul>
View
@@ -10,12 +10,6 @@
"""
from twisted.web._version import version
-from twisted.python.versions import Version
-from twisted.python.deprecate import deprecatedModuleAttribute
__version__ = version.short()
-deprecatedModuleAttribute(
- Version('Twisted', 11, 1, 0),
- "Google module is deprecated. Use Google's API instead",
- __name__, "google")
View
@@ -1,75 +0,0 @@
-# Copyright (c) Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-#
-"""\"I'm Feeling Lucky\" with U{Google<http://google.com>}.
-"""
-import urllib
-from twisted.internet import protocol, reactor, defer
-from twisted.web import http
-
-class GoogleChecker(http.HTTPClient):
-
- def connectionMade(self):
- self.sendCommand('GET', self.factory.url)
- self.sendHeader('Host', self.factory.host)
- self.sendHeader('User-Agent', self.factory.agent)
- self.endHeaders()
-
- def handleHeader(self, key, value):
- key = key.lower()
- if key == 'location':
- self.factory.gotLocation(value)
-
- def handleStatus(self, version, status, message):
- if status != '302':
- self.factory.noLocation(ValueError("bad status"))
-
- def handleEndHeaders(self):
- self.factory.noLocation(ValueError("no location"))
-
- def handleResponsePart(self, part):
- pass
-
- def handleResponseEnd(self):
- pass
-
- def connectionLost(self, reason):
- self.factory.noLocation(reason)
-
-
-class GoogleCheckerFactory(protocol.ClientFactory):
-
- protocol = GoogleChecker
-
- def __init__(self, words):
- self.url = ('/search?q=%s&btnI=%s' %
- (urllib.quote_plus(' '.join(words)),
- urllib.quote_plus("I'm Feeling Lucky")))
- self.agent="Twisted/GoogleChecker"
- self.host = "www.google.com"
- self.deferred = defer.Deferred()
-
- def clientConnectionFailed(self, _, reason):
- self.noLocation(reason)
-
- def gotLocation(self, location):
- if self.deferred:
- self.deferred.callback(location)
- self.deferred = None
-
- def noLocation(self, error):
- if self.deferred:
- self.deferred.errback(error)
- self.deferred = None
-
-
-def checkGoogle(words):
- """Check google for a match.
-
- @returns: a Deferred which will callback with a URL or errback with a
- Failure.
- """
- factory = GoogleCheckerFactory(words)
- reactor.connectTCP('www.google.com', 80, factory)
- return factory.deferred
@@ -587,27 +587,6 @@ def test_unmodifiedWithContentType(self):
-
-from twisted.web import google
-class GoogleTestCase(unittest.TestCase):
- def testCheckGoogle(self):
- raise unittest.SkipTest("no violation of google ToS")
- d = google.checkGoogle('site:www.twistedmatrix.com twisted')
- d.addCallback(self.assertEqual, 'http://twistedmatrix.com/')
- return d
-
-
- def test_deprecated(self):
- """
- Google module is deprecated since Twisted 11.1.0
- """
- from twisted.web import google
- warnings = self.flushWarnings(offendingFunctions=[self.test_deprecated])
- self.assertEqual(len(warnings), 1)
- self.assertEqual(warnings[0]['category'], DeprecationWarning)
-
-
-
class RequestTests(unittest.TestCase):
"""
Tests for the HTTP request class, L{server.Request}.
@@ -0,0 +1 @@
+twisted.web.google, deprecated since Twisted 11.1, is removed now.

0 comments on commit 51384b3

Please sign in to comment.