Commits

Senthil Kumaran  committed 116814b

running 2to3 on pending files.

  • Participants
  • Parent commits a0d5093

Comments (0)

Files changed (4)

File urwid/curses_display.py

         if not self.has_color:
             return
 
-        for fg in xrange(8):
-            for bg in xrange(8):
+        for fg in range(8):
+            for bg in range(8):
                 # leave out white on black
                 if fg == curses.COLOR_WHITE and \
                    bg == curses.COLOR_BLACK:
 
         self.s.attrset(attr)
 
-    def draw_screen(self, (cols, rows), r ):
+    def draw_screen(self, xxx_todo_changeme, r ):
         """Paint screen with rendered canvas."""
+        (cols, rows) = xxx_todo_changeme
         assert self._started
 
         assert r.rows() == rows, "canvas size and passed size don't match"
 class _test:
     def __init__(self):
         self.ui = Screen()
-        self.l = _curses_colours.keys()
+        self.l = list(_curses_colours.keys())
         self.l.sort()
         for c in self.l:
             self.ui.register_palette( [
             t = ""
             a = []
             for k in keys:
-                if type(k) == unicode: k = k.encode("utf-8")
+                if type(k) == str: k = k.encode("utf-8")
                 t += "'"+k + "' "
                 a += [(None,1), ('yellow on dark blue',len(k)),
                     (None,2)]

File urwid/html_fragment.py

         self.colors = 16
         self.bright_is_bold = False # ignored
         self.has_underline = True # ignored
-        self.register_palette_entry(None, 
+        self.register_palette_entry(None,
             _default_foreground, _default_background)
 
     def set_terminal_properties(self, colors=None, bright_is_bold=None,
         has_underline=None):
-        
+
         if colors is None:
             colors = self.colors
         if bright_is_bold is None:
 
     def start(self):
         pass
-    
+
     def stop(self):
         pass
-    
+
     def set_input_timeouts(self, *args):
         pass
 
         """Call fn."""
         return fn()
 
-    def draw_screen(self, (cols, rows), r ):
-        """Create an html fragment from the render object. 
+    def draw_screen(self, xxx_todo_changeme, r ):
+        """Create an html fragment from the render object.
         Append it to HtmlGenerator.fragments list.
         """
-        # collect output in l
+        (cols, rows) = xxx_todo_changeme
         l = []
-        
+
         assert r.rows() == rows
-    
+
         if r.cursor is not None:
             cx, cy = r.cursor
         else:
             cx = cy = None
-        
+
         y = -1
         for row in r.content():
             y += 1
             col = 0
-            
+
             for a, cs, run in row:
                 run = run.translate(_trans_table)
                 if isinstance(a, AttrSpec):
                     l.append(html_span(run, aspec))
 
             l.append("\n")
-                        
+
         # add the fragment to the list
         self.fragments.append( "<pre>%s</pre>" % "".join(l) )
-            
+
     def clear(self):
         """
         Force the screen to be completely repainted on the next
         (does nothing for html_fragment)
         """
         pass
-            
+
     def get_cols_rows(self):
         """Return the next screen size in HtmlGenerator.sizes."""
         if not self.sizes:
-            raise HtmlGeneratorSimulationError, "Ran out of screen sizes to return!"
+            raise HtmlGeneratorSimulationError("Ran out of screen sizes to return!")
         return self.sizes.pop(0)
 
     def get_input(self, raw_keys=False):
     def html_span(fg, bg, s):
         if not s: return ""
         return ('<span style="color:%s;'
-            'background:%s%s">%s</span>' % 
+            'background:%s%s">%s</span>' %
             (fg, bg, extra, html_escape(s)))
-    
+
     if cursor >= 0:
         c_off, _ign = util.calc_text_pos(s, 0, len(s), cursor)
         c2_off = util.move_next_char(s, c_off, len(s))
 
 def screenshot_init( sizes, keys ):
     """
-    Replace curses_display.Screen and raw_display.Screen class with 
+    Replace curses_display.Screen and raw_display.Screen class with
     HtmlGenerator.
-    
-    Call this function before executing an application that uses 
+
+    Call this function before executing an application that uses
     curses_display.Screen to have that code use HtmlGenerator instead.
-    
+
     sizes -- list of ( columns, rows ) tuples to be returned by each call
              to HtmlGenerator.get_cols_rows()
     keys -- list of lists of keys to be returned by each call to
             HtmlGenerator.get_input()
-    
+
     Lists of keys may include "window resize" to force the application to
     call get_cols_rows and read a new screen size.
 
             assert type(row) == int
             assert row>0 and col>0
     except (AssertionError, ValueError):
-        raise Exception, "sizes must be in the form [ (col1,row1), (col2,row2), ...]"
-    
+        raise Exception("sizes must be in the form [ (col1,row1), (col2,row2), ...]")
+
     try:
         for l in keys:
             assert type(l) == list
             for k in l:
                 assert type(k) == str
     except (AssertionError, ValueError):
-        raise Exception, "keys must be in the form [ [keyA1, keyA2, ..], [keyB1, ..], ...]"
-    
-    import curses_display
+        raise Exception("keys must be in the form [ [keyA1, keyA2, ..], [keyB1, ..], ...]")
+
+    from . import curses_display
     curses_display.Screen = HtmlGenerator
-    import raw_display
+    from . import raw_display
     raw_display.Screen = HtmlGenerator
-    
+
     HtmlGenerator.sizes = sizes
     HtmlGenerator.keys = keys
 
     l = HtmlGenerator.fragments
     HtmlGenerator.fragments = []
     return l
-
-    

File urwid/lcd_display.py

 # Urwid web site: http://excess.org/urwid/
 
 
-from display_common import BaseScreen
+from .display_common import BaseScreen
 
 import time
 
     def run_wrapper(self,fn):
         return fn()
 
-    def draw_screen(self, (cols, rows), r ):
+    def draw_screen(self, xxx_todo_changeme, r ):
+        (cols, rows) = xxx_todo_changeme
         pass
 
     def clear(self):
 
 
 class CF635Screen(CFLCDScreen):
-    u"""
+    """
     Crystal Fontz 635 display
 
     20x4 character display + cursor
     DISPLAY_SIZE = (20, 4)
 
     CGROM = (
-        u"①②③④⑤⑥⑦⑧①②③④⑤⑥⑦⑧"
-        u"►◄⇑⇓«»↖↗↙↘▲▼↲^ˇ█"
-        u" !\"#¤%&'()*+,-./"
-        u"0123456789:;<=>?"
-        u"¡ABCDEFGHIJKLMNO"
-        u"PQRSTUVWXYZÄÖÑܧ"
-        u"¿abcdefghijklmno"
-        u"pqrstuvwxyzäöñüà"
-        u"⁰¹²³⁴⁵⁶⁷⁸⁹½¼±≥≤μ"
-        u"♪♫⑴♥♦⑵⌜⌟“”()αɛδ∞"
-        u"@£$¥èéùìòÇᴾØøʳÅå"
-        u"⌂¢ΦτλΩπΨΣθΞ♈ÆæßÉ"
-        u"ΓΛΠϒ_ÈÊêçğŞşİι~◊"
-        u"▇▆▄▃▁ƒ▉▋▌▍▏⑶◽▪↑→"
-        u"↓←ÁÍÓÚÝáíóúýÔôŮů"
-        u"ČĔŘŠŽčĕřšž[\]{|}")
+        "①②③④⑤⑥⑦⑧①②③④⑤⑥⑦⑧"
+        "►◄⇑⇓«»↖↗↙↘▲▼↲^ˇ█"
+        " !\"#¤%&'()*+,-./"
+        "0123456789:;<=>?"
+        "¡ABCDEFGHIJKLMNO"
+        "PQRSTUVWXYZÄÖÑܧ"
+        "¿abcdefghijklmno"
+        "pqrstuvwxyzäöñüà"
+        "⁰¹²³⁴⁵⁶⁷⁸⁹½¼±≥≤μ"
+        "♪♫⑴♥♦⑵⌜⌟“”()αɛδ∞"
+        "@£$¥èéùìòÇᴾØøʳÅå"
+        "⌂¢ΦτλΩπΨΣθΞ♈ÆæßÉ"
+        "ΓΛΠϒ_ÈÊêçğŞşİι~◊"
+        "▇▆▄▃▁ƒ▉▋▌▍▏⑶◽▪↑→"
+        "↓←ÁÍÓÚÝáíóúýÔôŮů"
+        "ČĔŘŠŽčĕřšž[\]{|}")
 
     cursor_style = CFLCDScreen.CURSOR_INVERTING_BLINKING_BLOCK
 

File urwid/tests.py

 
 
     def test1(self):
-        self.ctest("no conversion", u"hello", "hello", [(None,5)])
-        self.ctest("only special", u"£££££", "}}}}}", [("0",5)])
-        self.ctest("mix left", u"££abc", "}}abc", [("0",2),(None,3)])
-        self.ctest("mix right", u"abc££", "abc}}", [(None,3),("0",2)])
-        self.ctest("mix inner", u"a££bc", "a}}bc",
+        self.ctest("no conversion", "hello", "hello", [(None,5)])
+        self.ctest("only special", "£££££", "}}}}}", [("0",5)])
+        self.ctest("mix left", "££abc", "}}abc", [("0",2),(None,3)])
+        self.ctest("mix right", "abc££", "abc}}", [(None,3),("0",2)])
+        self.ctest("mix inner", "a££bc", "a}}bc",
             [(None,1),("0",2),(None,2)] )
-        self.ctest("mix well", u"£a£b£", "}a}b}",
+        self.ctest("mix well", "£a£b£", "}a}b}",
             [("0",1),(None,1),("0",1),(None,1),("0",1)] )
 
 
     def test_bad_tuple(self):
         try:
             urwid.decompose_tagmarkup((1,2,3))
-        except urwid.TagMarkupException, e:
+        except urwid.TagMarkupException as e:
             pass
         else:
             assert 0, "should have thrown exception!"
     def test_bad_type(self):
         try:
             urwid.decompose_tagmarkup(5)
-        except urwid.TagMarkupException, e:
+        except urwid.TagMarkupException as e:
             pass
         else:
             assert 0, "should have thrown exception!"
         self.t = urwid.Text("I walk the\ncity in the night")
 
     def test1_wrap(self):
-        expected = [B(t) for t in "I walk the","city in   ","the night "]
+        expected = [B(t) for t in ("I walk the","city in   ","the night ")]
         got = self.t.render((10,))._text
         assert got == expected, "got: %r expected: %r" % (got, expected)
 
     def test2_left(self):
         self.t.set_align_mode('left')
-        expected = [B(t) for t in "I walk the        ","city in the night "]
+        expected = [B(t) for t in ("I walk the        ","city in the night ")]
         got = self.t.render((18,))._text
         assert got == expected, "got: %r expected: %r" % (got, expected)
 
     def test3_right(self):
         self.t.set_align_mode('right')
-        expected = [B(t) for t in "        I walk the"," city in the night"]
+        expected = [B(t) for t in ("        I walk the"," city in the night")]
         got = self.t.render((18,))._text
         assert got == expected, "got: %r expected: %r" % (got, expected)
 
     def test4_center(self):
         self.t.set_align_mode('center')
-        expected = [B(t) for t in "    I walk the    "," city in the night"]
+        expected = [B(t) for t in ("    I walk the    "," city in the night")]
         got = self.t.render((18,))._text
         assert got == expected, "got: %r expected: %r" % (got, expected)
 
     def petest(self, desc, align, width):
         try:
             urwid.Padding(None, align, width)
-        except urwid.PaddingError, e:
+        except urwid.PaddingError as e:
             return
         assert 0, "%s expected error!" % desc
 
     def fetest(self, desc, valign, height):
         try:
             urwid.Filler(None, valign, height)
-        except urwid.FillerError, e:
+        except urwid.FillerError as e:
             return
         assert 0, "%s expected error!" % desc