Fix a bunch of undefined names. Mostly typos or missing imports.
authorMatthew Duggan <mgithub@guarana.org>
Fri, 20 Jun 2014 11:24:17 +0900
changeset 4116 cf49463fc067
parent 4115 f1913fcae595
child 4117 66499c4a5e9a
Fix a bunch of undefined names. Mostly typos or missing imports.
src/reportlab/graphics/barcode/usps4s.py
src/reportlab/graphics/charts/areas.py
src/reportlab/graphics/charts/utils.py
src/reportlab/lib/pdfencrypt.py
src/reportlab/pdfbase/cidfonts.py
src/reportlab/pdfbase/pdfdoc.py
src/reportlab/platypus/para.py
src/reportlab/platypus/paraparser.py
src/reportlab/platypus/xpreformatted.py
--- a/src/reportlab/graphics/barcode/usps4s.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/graphics/barcode/usps4s.py	Fri Jun 20 11:24:17 2014 +0900
@@ -53,12 +53,12 @@
 
     def tracking(self,tracking):
         self._init()
-        self._tracking = value
+        self._tracking = tracking
     tracking = property(lambda self: self._tracking,tracking)
 
     def routing(self,routing):
         self._init()
-        self._routing = value
+        self._routing = routing
     routing = property(lambda self: self._routing,routing)
 
     def widthSize(self,value):
--- a/src/reportlab/graphics/charts/areas.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/graphics/charts/areas.py	Fri Jun 20 11:24:17 2014 +0900
@@ -9,6 +9,7 @@
 from reportlab.graphics.widgetbase import Widget
 from reportlab.graphics.shapes import Rect, Group, Line, Polygon
 from reportlab.lib.attrmap import AttrMap, AttrMapValue
+from reportlab.lib.colors import grey
 
 class PlotArea(Widget):
     "Abstract base class representing a chart's plot area, pretty unusable by itself."
--- a/src/reportlab/graphics/charts/utils.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/graphics/charts/utils.py	Fri Jun 20 11:24:17 2014 +0900
@@ -7,7 +7,7 @@
 from time import mktime, gmtime, strftime
 from math import log10, pi, floor, sin, cos, sqrt, hypot
 import weakref
-from reportlab.graphics.shapes import transformPoint, transformPoints, inverse, Ellipse, Group, String, Path
+from reportlab.graphics.shapes import transformPoint, transformPoints, inverse, Ellipse, Group, String, Path, numericXShift
 from reportlab.lib.utils import flatten
 from reportlab.pdfbase.pdfmetrics import stringWidth
 
--- a/src/reportlab/lib/pdfencrypt.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/lib/pdfencrypt.py	Fri Jun 20 11:24:17 2014 +0900
@@ -591,7 +591,7 @@
             print("wrote output file '%s'(%s bytes)\n  owner password is '%s'\n  user password is '%s'" % (SAVEFILE, filesize, OWNER, USER))
 
         if len(argv)>0:
-            raise valueError("\nUnrecognised arguments : %s\nknown arguments are:\n%s" % (str(argv)[1:-1], known_modes))
+            raise ValueError("\nUnrecognised arguments : %s\nknown arguments are:\n%s" % (str(argv)[1:-1], known_modes))
     else:
         print(usage)
 
--- a/src/reportlab/pdfbase/cidfonts.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/pdfbase/cidfonts.py	Fri Jun 20 11:24:17 2014 +0900
@@ -449,7 +449,7 @@
     import os
     files = os.listdir(cmapdir)
     for file in files:
-        if os.path.isfile(cmapdir + os.sep + self.name + '.fastmap'):
+        if os.path.isfile(cmapdir + os.sep + file + '.fastmap'):
             continue
         try:
             enc = CIDEncoding(file)
--- a/src/reportlab/pdfbase/pdfdoc.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/pdfbase/pdfdoc.py	Fri Jun 20 11:24:17 2014 +0900
@@ -24,6 +24,7 @@
 
 from sys import platform
 from sys import version_info
+from sys import stderr
 
 if platform[:4] == 'java' and version_info[:2] == (2, 1):
     # workaround for list()-bug in Jython 2.1 (should be fixed in 2.2)
@@ -601,7 +602,7 @@
                     try:
                         s.decode('pdfdoc')
                     except:
-                        sys.stderr.write('Error in %s' % (repr(s),))
+                        stderr.write('Error in %s' % (repr(s),))
                         raise
         elif isUnicode(s):
             if enc is 'auto':
@@ -1419,7 +1420,7 @@
                 return tuple(L)
             return L
         # bug contributed by Benjamin Dumke <reportlab@benjamin-dumke.de>
-        raise TypeError("in outline, destination name must be string: got a %s"%Ot)
+        raise TypeError("in outline, destination name must be string: got a %s"%type(object))
 
     def prepare(self, document, canvas):
         """prepare all data structures required for save operation (create related objects)"""
@@ -1484,7 +1485,7 @@
                 eltobj.Count = count(subsections, closedict)
                 (eltobj.First, eltobj.Last) = self.maketree(document, subsections, eltref)
             else:
-                raise ValueError("destination tree elt should be dict or tuple, got %s" % te)
+                raise ValueError("destination tree elt should be dict or tuple, got %s" % type(elt))
             try:
                 [(Title, Dest)] = list(leafdict.items())
             except:
--- a/src/reportlab/platypus/para.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/platypus/para.py	Fri Jun 20 11:24:17 2014 +0900
@@ -634,7 +634,7 @@
                    hasattr(this,'width') or hasattr(next,'width'):
                     doswap = 0
                 # only swap two tuples if the second one is an end operation and the first is something else
-                elif isintance(this,tuple):
+                elif isinstance(this,tuple):
                     thisindicator = this[0]
                     if isinstance(next,tuple):
                         nextindicator = next[0]
@@ -868,7 +868,7 @@
     elif text.upper() in ("N", "NO", "FALSE", "0"):
         return 0
     else:
-        raise RMLError("true/false attribute has illegal value '%s'" % text)
+        raise ValueError("true/false attribute has illegal value '%s'" % text)
 
 def readAlignment(text):
     up = text.upper()
@@ -903,7 +903,7 @@
                 'pt':1
                 }[units]
         except KeyError:
-            raise RMLError("invalid length attribute '%s'" % text)
+            raise ValueError("invalid length attribute '%s'" % text)
 
         return number * multiplier
 
--- a/src/reportlab/platypus/paraparser.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/platypus/paraparser.py	Fri Jun 20 11:24:17 2014 +0900
@@ -752,7 +752,7 @@
             try:
                 v = unicodedata.lookup(attr['name'])
             except KeyError:
-                self._syntax_error('<unichar/> invalid name attribute\n"%s"' % ascii(name))
+                self._syntax_error('<unichar/> invalid name attribute\n"%s"' % ascii(attr['name']))
                 v = '\0'
         elif 'code' in attr:
             try:
--- a/src/reportlab/platypus/xpreformatted.py	Thu Jun 19 11:44:03 2014 +0100
+++ b/src/reportlab/platypus/xpreformatted.py	Fri Jun 20 11:24:17 2014 +0900
@@ -247,6 +247,7 @@
         return fontifiedCode
 
 if __name__=='__main__':    #NORUNTESTS
+    import sys
     def dumpXPreformattedLines(P):
         print('\n############dumpXPreforemattedLines(%s)' % str(P))
         lines = P.blPara.lines