xpahos  committed b4ea4ff

2to32 fixes

  • Participants
  • Parent commits b492a4c
  • Branches trunk

Comments (0)

Files changed (6)

File webhelpers/

         return _country_codes
-        text_directly_from_iso_website = u"""
+        text_directly_from_iso_website = """

File webhelpers/

                 args = tuple()
                 args = self.default_factory,
-            return type(self), args, None, None, self.items()
+            return type(self), args, None, None, list(self.items())
         def copy(self):
             return self.__copy__()
         def __copy__(self):
         def __deepcopy__(self, memo):
             import copy
             return type(self)(self.default_factory,
-                              copy.deepcopy(self.items()))
+                              copy.deepcopy(list(self.items())))
         def __repr__(self):
             return 'defaultdict(%s, %s)' % (self.default_factory,
         If ``max_items`` is provided, return no more than that many items.
-        data = [(x[1], x[0]) for x in self.result.iteritems()]
-        data.sort(key=lambda x: (sys.maxint - x[0], x[1]))
+        data = [(x[1], x[0]) for x in self.result.items()]
+        data.sort(key=lambda x: (sys.maxsize - x[0], x[1]))
         if max_items:
             return data[:max_items]
     def get_sorted_items(self):
         """Return the result as a list of ``(item, count)`` pairs sorted by item.
-        data = self.result.items()
+        data = list(self.result.items())
         return data
             raise KeyError("key %r is not in original mapping" % k)
     r1 = {}
     r2 = {}
-    for k, v in dic.items():
+    for k, v in list(dic.items()):
         if k in keys:
             r1[k] = v
         elif default is not NotGiven:
             yield key, default
     if other_keys:
-        for key, value in d.iteritems():
+        for key, value in d.items():
             yield key, value
 def get_many(d, required=None, optional=None, one_of=None):

File webhelpers/html/

     def __init__(self, itemlist, columns=None, column_labels=None, *args, **kw):
         if columns is None:
-            columns = range(len(itemlist[0]))
+            columns = list(range(len(itemlist[0])))
         elif isinstance(columns, int):
-            columns = range(columns)
+            columns = list(range(columns))
         # The superclass requires the ``columns`` elements to be strings.
         super_columns = [str(x) for x in columns]
         # The superclass requires ``column_labels`` to be a dict.
         super_labels = column_labels
         if isinstance(column_labels, (list, tuple)):
-            super_labels = dict(zip(super_columns, column_labels))
+            super_labels = dict(list(zip(super_columns, column_labels)))
         Grid.__init__(self, itemlist, super_columns, super_labels, *args, **kw)
     def default_column_format(self, column_number, i, record, column_name):

File webhelpers/html/

 import optparse
 import os
-import urllib
+import urllib.request, urllib.parse, urllib.error
 from webhelpers.html import *
 from webhelpers.html.grid import *
 def url(urlpath, **params):
     # This should be a helper and I think it's defined somewhere but I
     # can't think of where.
-    return urlpath + "?" + urllib.urlencode(params)
+    return urlpath + "?" + urllib.parse.urlencode(params)
 def write_file(dir, filename, content):
-    print "... writing '%s'" % filename
+    print("... writing '%s'" % filename)
     path = os.path.join(dir, filename)
     f = open(path, "w")
     dir = args[0]
     if not os.path.exists(dir):
-    print "Putting output in directory '%s'" % dir
+    print("Putting output in directory '%s'" % dir)
     write_file(dir, "demo.css", STYLESHEET)
     for class_ in demos:
         d = class_()

File webhelpers/html/

         prog = os.path.basename(sys.argv[0])
         sys.exit("usage: %s <HTML_FILE" % prog)
     html =
-    print(render(html))
+    print((render(html)))
 if __name__ == "__main__":  main()

File webhelpers/pylonslib/

 import re
 import os
 import logging
-import StringIO
+import io
 import warnings
 from webhelpers.html.tags import javascript_link as __javascript_link
         return sources
     names = list()
-    js_buffer = StringIO.StringIO()
+    js_buffer = io.StringIO()
     base = os.path.commonprefix([os.path.dirname(s) for s in sources])
     for source in sources:
             def do_css_CSSStyleDeclaration(self, style, separator=None):
                     color = style.getPropertyValue('color')
-                    if color and color is not u'':
+                    if color and color is not '':
                         color = self.change_colors(color)
                         style.setProperty('color', color)