Browse code

Apply 2to3.

Jose Fonseca authored on 16/10/2015 23:26:44
Showing 4 changed files

  • sample.py index 8fc6583..882ed32 100755
  • setup.py index b7c6720..b660e9f 100755
  • test.py index 34b02f3..235158a 100755
  • xdot.py index 8a218f2..ec9c608 100755
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env python
1
+#!/usr/bin/env python3
2 2
 #
3 3
 # Copyright 2008 Jose Fonseca
4 4
 #
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env python
1
+#!/usr/bin/env python3
2 2
 #
3 3
 # The purpose of this script is to enable uploading xdot.py to the Python
4 4
 # Package Index, which can be easily done by doing:
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env python
1
+#!/usr/bin/env python3
2 2
 #
3 3
 # Copyright 2015 Jose Fonseca
4 4
 #
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env python
1
+#!/usr/bin/env python3
2 2
 #
3 3
 # Copyright 2008-2015 Jose Fonseca
4 4
 #
... ...
@@ -158,7 +158,7 @@ class TextShape(Shape):
158 158
             if self.pen.subscript:
159 159
                 markup = '<sub><small>' + markup + '</small></sub>'
160 160
 
161
-            success, attrs, text, accel_char = Pango.parse_markup(markup, -1, u'\x00')
161
+            success, attrs, text, accel_char = Pango.parse_markup(markup, -1, '\x00')
162 162
             assert success
163 163
             layout.set_attributes(attrs)
164 164
 
... ...
@@ -335,7 +335,7 @@ class BezierShape(Shape):
335 335
     def draw(self, cr, highlight=False):
336 336
         x0, y0 = self.points[0]
337 337
         cr.move_to(x0, y0)
338
-        for i in xrange(1, len(self.points), 3):
338
+        for i in range(1, len(self.points), 3):
339 339
             x1, y1 = self.points[i]
340 340
             x2, y2 = self.points[i + 1]
341 341
             x3, y3 = self.points[i + 2]
... ...
@@ -560,7 +560,7 @@ class XDotAttrParser:
560 560
         self.pen = Pen()
561 561
         self.shapes = []
562 562
 
563
-    def __nonzero__(self):
563
+    def __bool__(self):
564 564
         return self.pos < len(self.buf)
565 565
 
566 566
     def read_code(self):
... ...
@@ -888,7 +888,7 @@ class Lexer:
888 888
         self.col = 1
889 889
         self.filename = filename
890 890
 
891
-    def next(self):
891
+    def __next__(self):
892 892
         while True:
893 893
             # save state
894 894
             pos = self.pos
... ...
@@ -937,7 +937,7 @@ class Parser:
937 937
 
938 938
     def __init__(self, lexer):
939 939
         self.lexer = lexer
940
-        self.lookahead = self.lexer.next()
940
+        self.lookahead = next(self.lexer)
941 941
 
942 942
     def match(self, type):
943 943
         if self.lookahead.type != type:
... ...
@@ -953,7 +953,7 @@ class Parser:
953 953
 
954 954
     def consume(self):
955 955
         token = self.lookahead
956
-        self.lookahead = self.lexer.next()
956
+        self.lookahead = next(self.lexer)
957 957
         return token
958 958
 
959 959
 
... ...
@@ -1589,8 +1589,6 @@ class DotWidget(Gtk.DrawingArea):
1589 1589
 
1590 1590
     def set_dotcode(self, dotcode, filename=None):
1591 1591
         self.openfilename = None
1592
-        if isinstance(dotcode, unicode):
1593
-            dotcode = dotcode.encode('utf8')
1594 1592
         xdotcode = self.run_filter(dotcode)
1595 1593
         if xdotcode is None:
1596 1594
             return False
... ...
@@ -1861,7 +1859,7 @@ class DotWidget(Gtk.DrawingArea):
1861 1859
             if event.button == 1:
1862 1860
                 url = self.get_url(x, y)
1863 1861
                 if url is not None:
1864
-                    self.emit('clicked', unicode(url.url), event)
1862
+                    self.emit('clicked', url.url, event)
1865 1863
                 else:
1866 1864
                     jump = self.get_jump(x, y)
1867 1865
                     if jump is not None: