[wwwsearch-commits] r21642 - wwwsearch/ClientForm/trunk

jjlee at codespeak.net jjlee at codespeak.net
Mon Jan 2 19:49:26 CET 2006


Author: jjlee
Date: Mon Jan  2 19:49:25 2006
New Revision: 21642

Modified:
   wwwsearch/ClientForm/trunk/ClientForm.py
Log:
Formatting nits

Modified: wwwsearch/ClientForm/trunk/ClientForm.py
==============================================================================
--- wwwsearch/ClientForm/trunk/ClientForm.py	(original)
+++ wwwsearch/ClientForm/trunk/ClientForm.py	Mon Jan  2 19:49:25 2006
@@ -174,8 +174,8 @@
                         l.append(k + '=' + urllib.quote_plus(str(elt)))
     return '&'.join(l)
 
-def unescape(data, entities, encoding='latin-1'):
-    if data is None or '&' not in data:
+def unescape(data, entities, encoding="latin-1"):
+    if data is None or "&" not in data:
         return data
 
     def replace_entities(match, entities=entities, encoding=encoding):
@@ -195,7 +195,7 @@
 
         return repl
 
-    return re.sub(r'&#?\S+?;', replace_entities, data)
+    return re.sub(r"&#?\S+?;", replace_entities, data)
 
 def unescape_charref(data, encoding):
     name, base = data, 10
@@ -249,7 +249,7 @@
 
 # --------------------------------------------------------------------
 # grabbed from Python standard library mimetools module and tweaked to
-# avoid socket.gaierror and to avoid dots ('.') in MIME boundaries
+# avoid socket.gaierror and to avoid dots (".") in MIME boundaries
 try:
     import thread
     _thread = thread; del thread
@@ -471,7 +471,7 @@
 class _AbstractFormParser:
     """forms attribute contains HTMLForm instances on completion."""
     # thanks to Moshe Zadka for an example of sgmllib/htmllib usage
-    def __init__(self, entitydefs=None, encoding='latin-1'):
+    def __init__(self, entitydefs=None, encoding="latin-1"):
         if entitydefs is None:
             entitydefs = get_entitydefs()
         self._entitydefs = entitydefs
@@ -765,13 +765,13 @@
     import HTMLParser
 except ImportError:
     class XHTMLCompatibleFormParser:
-        def __init__(self, entitydefs=None, encoding='latin-1'):
+        def __init__(self, entitydefs=None, encoding="latin-1"):
             raise ValueError("HTMLParser could not be imported")
 else:
     class XHTMLCompatibleFormParser(_AbstractFormParser, HTMLParser.HTMLParser):
         """Good for XHTML, bad for tolerance of incorrect HTML."""
         # thanks to Michael Howitz for this!
-        def __init__(self, entitydefs=None, encoding='latin-1'):
+        def __init__(self, entitydefs=None, encoding="latin-1"):
             HTMLParser.HTMLParser.__init__(self)
             _AbstractFormParser.__init__(self, entitydefs, encoding)
 
@@ -814,7 +814,7 @@
 
 import sgmllib
 # monkeypatch to fix http://www.python.org/sf/803422 :-(
-sgmllib.charref = re.compile('&#(x?[0-9a-fA-F]+)[^0-9a-fA-F]')
+sgmllib.charref = re.compile("&#(x?[0-9a-fA-F]+)[^0-9a-fA-F]")
 class _AbstractSgmllibParser(_AbstractFormParser):
     def do_option(self, attrs):
         _AbstractFormParser._start_option(self, attrs)
@@ -826,7 +826,7 @@
 
 class FormParser(_AbstractSgmllibParser, sgmllib.SGMLParser):
     """Good for tolerance of incorrect HTML, bad for XHTML."""
-    def __init__(self, entitydefs=None, encoding='latin-1'):
+    def __init__(self, entitydefs=None, encoding="latin-1"):
         sgmllib.SGMLParser.__init__(self)
         _AbstractFormParser.__init__(self, entitydefs, encoding)
 
@@ -839,7 +839,7 @@
 else:
     class _AbstractBSFormParser(_AbstractSgmllibParser):
         bs_base_class = None
-        def __init__(self, entitydefs=None, encoding='latin-1'):
+        def __init__(self, entitydefs=None, encoding="latin-1"):
             _AbstractFormParser.__init__(self, entitydefs, encoding)
             self.bs_base_class.__init__(self)
         def handle_data(self, data):
@@ -884,7 +884,7 @@
     form_parser_class: class to instantiate and use to pass
     request_class: class to return from .click() method (default is
      urllib2.Request)
-    entitydefs: mapping like {'&': '&', ...} containing HTML entity
+    entitydefs: mapping like {"&": "&", ...} containing HTML entity
      definitions (a sensible default is used)
     encoding: character encoding used for encoding numeric character references
      when matching link text.  ClientForm does not attempt to find the encoding
@@ -1032,7 +1032,7 @@
         self.__dict__[name] = value
 
     def __str__(self):
-        return '<Label(id=%r, text=%r)>' % (self.id, self.text)
+        return "<Label(id=%r, text=%r)>" % (self.id, self.text)
 
 
 def _get_label(attrs):
@@ -3210,7 +3210,7 @@
             req = request_class(req_data[0], req_data[1])
             for key, val in req_data[2]:
                 add_hdr = req.add_header
-                if key.lower() == 'content-type':
+                if key.lower() == "content-type":
                     try:
                         add_hdr = req.add_unredirected_header
                     except AttributeError:


More information about the wwwsearch-commits mailing list