Commits

xpahos committed b4ea4ff

2to32 fixes

Comments (0)

Files changed (6)

webhelpers/constants.py

         return _country_codes
     else:
         
-        text_directly_from_iso_website = u"""
+        text_directly_from_iso_website = """
 A   	  
 AFGHANISTAN 	AF
 ÅLAND ISLANDS 	AX

webhelpers/containers.py

                 args = tuple()
             else:
                 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,
                                             dict.__repr__(self))
 
         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]
         else:
     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())
         data.sort()
         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
         else:
         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):

webhelpers/html/grid.py

     """
     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):

webhelpers/html/grid_demo.py

 
 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")
     f.write(content)
     dir = args[0]
     if not os.path.exists(dir):
         os.makedirs(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_()

webhelpers/html/render.py

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

webhelpers/pylonslib/minify.py

 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):
                 try:
                     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)
                 except:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.