Fixes for changed API. Py2 comp.

Sat, 20 Apr 2013 20:29:37 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 20 Apr 2013 20:29:37 +0200
branch
Py2 comp.
changeset 2602
affc66a603c7
parent 2601
f415080106ba
child 2607
e5115553185a

Fixes for changed API.

DataViews/CodeMetrics.py file | annotate | diff | comparison | revisions
Graphics/PackageDiagramBuilder.py file | annotate | diff | comparison | revisions
Graphics/UMLClassDiagramBuilder.py file | annotate | diff | comparison | revisions
--- a/DataViews/CodeMetrics.py	Sat Apr 20 19:52:20 2013 +0200
+++ b/DataViews/CodeMetrics.py	Sat Apr 20 20:29:37 2013 +0200
@@ -18,6 +18,7 @@
 
 import os
 import io
+import sys
 import keyword
 import token
 import tokenize
@@ -67,7 +68,10 @@
         
         source = io.BytesIO(text.encode("utf-8"))
         try:
-            gen = tokenize.tokenize(source.readline)
+            if sys.version_info[0] == 2:
+                gen = tokenize.generate_tokens(source.readline)
+            else:
+                gen = tokenize.tokenize(source.readline)
             for toktype, toktext, start, end, line in gen:
                 (srow, scol) = start
                 (erow, ecol) = end
--- a/Graphics/PackageDiagramBuilder.py	Sat Apr 20 19:52:20 2013 +0200
+++ b/Graphics/PackageDiagramBuilder.py	Sat Apr 20 20:29:37 2013 +0200
@@ -11,7 +11,10 @@
 
 import glob
 import os.path
-import itertools
+try:  # Py3
+    from itertools import zip_longest
+except ImportError:
+    from itertools import izip_longest as zip_longest
 
 from PyQt4.QtGui import QProgressDialog, QApplication, QGraphicsTextItem
 
@@ -328,7 +331,7 @@
         # generations across height
         y = 10.0
         for currentWidth, currentHeight, generation in \
-                itertools.zip_longest(widths, heights, generations):
+                zip_longest(widths, heights, generations):
             x = 10.0
             # whiteSpace is the space between any two elements
             whiteSpace = (width - currentWidth - 20) / (len(generation) - 1.0 or 2.0)
--- a/Graphics/UMLClassDiagramBuilder.py	Sat Apr 20 19:52:20 2013 +0200
+++ b/Graphics/UMLClassDiagramBuilder.py	Sat Apr 20 20:29:37 2013 +0200
@@ -8,8 +8,10 @@
 """
 
 from __future__ import unicode_literals    # __IGNORE_WARNING__
-
-import itertools
+try:  # Py3
+    from itertools import zip_longest
+except ImportError:
+    from itertools import izip_longest as zip_longest
 
 from PyQt4.QtGui import QGraphicsTextItem
 
@@ -206,7 +208,7 @@
         # generations across height
         y = 10.0
         for currentWidth, currentHeight, generation in \
-                itertools.zip_longest(widths, heights, generations):
+                zip_longest(widths, heights, generations):
             x = 10.0
             # whiteSpace is the space between any two elements
             whiteSpace = (width - currentWidth - 20) / (len(generation) - 1.0 or 2.0)

eric ide

mercurial