reportlab: fix 2to3 warnings
authorrgbecker
Tue, 09 Feb 2010 11:23:58 +0000
changeset 3328 4d7f836cd947
parent 3327 512eb20b0c3d
child 3329 8cc1a69c83ce
reportlab: fix 2to3 warnings
setup.py
src/reportlab/graphics/barcode/widgets.py
src/reportlab/graphics/charts/legends.py
src/reportlab/graphics/charts/linecharts.py
src/reportlab/graphics/charts/lineplots.py
src/reportlab/graphics/charts/spider.py
src/reportlab/lib/logger.py
src/reportlab/lib/pdfencrypt.py
src/reportlab/lib/testutils.py
src/reportlab/lib/textsplit.py
src/reportlab/lib/utils.py
src/reportlab/pdfbase/cidfonts.py
tools/docco/rltemplate.py
--- a/setup.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/setup.py	Tue Feb 09 11:23:58 2010 +0000
@@ -238,7 +238,7 @@
         xitmsg = "Finished download of standard T1 font curves"
     except:
         xitmsg = "Failed to download standard T1 font curves"
-    map(reportlab_files.remove,[x for x in reportlab_files if not os.path.isfile(pjoin(rl_dir,x))])
+    reportlab_files = [x for x in reportlab_files if os.path.isfile(pjoin(rl_dir,x))]
     infoline(xitmsg)
 
 def main():
--- a/src/reportlab/graphics/barcode/widgets.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/graphics/barcode/widgets.py	Tue Feb 09 11:23:58 2010 +0000
@@ -300,7 +300,8 @@
     os.chdir(os.path.dirname(sys.argv[0]))
     if not os.path.isdir('out'):
         os.mkdir('out')
-    map(os.remove,glob.glob(os.path.join('out','*')))
+    for x in glob.glob(os.path.join('out','*')):
+        os.remove(x)
     html = ['<html><head></head><body>']
     a = html.append
     for C in (BarcodeI2of5,
--- a/src/reportlab/graphics/charts/legends.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/graphics/charts/legends.py	Tue Feb 09 11:23:58 2010 +0000
@@ -481,7 +481,7 @@
                 g.add(c)
                 if scallout: scallout(self,g,thisx,y0,i,(col,name),c)
 
-            map(g.add,S)
+            for s in S: g.add(s)
             if self.colEndCallout and (i%columnMaximum==lim or i==(n-1)):
                 if alignment == "left":
                     xt = thisx
--- a/src/reportlab/graphics/charts/linecharts.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/graphics/charts/linecharts.py	Tue Feb 09 11:23:58 2010 +0000
@@ -503,7 +503,7 @@
 
         F.sort()
         g = Group()
-        map(lambda x,a=g.add: a(x[-1]),F.value())
+        for v in F.value(): g.add(v[-1])
         return g
 
 class VerticalLineChart(LineChart):
--- a/src/reportlab/graphics/charts/lineplots.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/graphics/charts/lineplots.py	Tue Feb 09 11:23:58 2010 +0000
@@ -528,6 +528,7 @@
         F.sort()
         g = Group()
         map(lambda x,a=g.add: a(x[-1]),F.value())
+        for v in F.value(): g.add(v[-1])
         return g
 
 _monthlyIndexData = [[(19971202, 100.0),
--- a/src/reportlab/graphics/charts/spider.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/graphics/charts/spider.py	Tue Feb 09 11:23:58 2010 +0000
@@ -343,7 +343,7 @@
                 STRANDS.append(strand)
             rowIdx += 1
 
-        map(g.add,STRANDAREAS+STRANDS+syms+S+labs)
+        for s in (STRANDAREAS+STRANDS+syms+S+labs): g.add(s)
         return g
 
 def sample1():
--- a/src/reportlab/lib/logger.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/lib/logger.py	Tue Feb 09 11:23:58 2010 +0000
@@ -35,7 +35,7 @@
     def write(self,text):
         '''write text to all the destinations'''
         if text[-1]!='\n': text=text+'\n'
-        map(lambda fp,t=text: fp.write(t),self._fps)
+        for fp in self._fps: fp.write(text)
 
     def __call__(self,text):
         self.write(text)
--- a/src/reportlab/lib/pdfencrypt.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/lib/pdfencrypt.py	Tue Feb 09 11:23:58 2010 +0000
@@ -506,14 +506,14 @@
             print usage
             return
         if len(argv)<2:
-            raise "Must include a filename and one or more arguments!"
+            raise ValueError("Must include a filename and one or more arguments!")
         if argv[0] not in known_modes:
             infile = argv[0]
             argv = argv[1:]
             if not os.path.isfile(infile):
-                raise "Can't open input file '%s'!" % infile
+                raise ValueError("Can't open input file '%s'!" % infile)
         else:
-            raise "First argument must be name of the PDF input file!"
+            raise ValueError("First argument must be name of the PDF input file!")
 
         # meaningful name at this stage
         STRENGTH = 40
--- a/src/reportlab/lib/testutils.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/lib/testutils.py	Tue Feb 09 11:23:58 2010 +0000
@@ -43,7 +43,7 @@
             os.makedirs(_OUTDIR)
         except:
             pass
-        map(sys.argv.remove,D)
+        for d in D: sys.argv.remove(d)
     else:
         assert name=='__main__',"setOutDir should only be called in the main script"
         scriptDir=os.path.dirname(sys.argv[0])
--- a/src/reportlab/lib/textsplit.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/lib/textsplit.py	Tue Feb 09 11:23:58 2010 +0000
@@ -199,5 +199,6 @@
             ).replace('\0', '').encode(encoding)
 
 if __name__=='__main__':
-    import doctest, textsplit
+    import doctest
+    import textsplit
     doctest.testmod(textsplit)
--- a/src/reportlab/lib/utils.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/lib/utils.py	Tue Feb 09 11:23:58 2010 +0000
@@ -46,9 +46,9 @@
     from UserDict import UserDict as _UserDict
 
 class CIDict(_UserDict):
-    def __init__(self,*a,**kw):
-        map(self.update, a)
-        self.update(kw)
+    def __init__(self,*args,**kwds):
+        for a in args: self.update(a)
+        self.update(kwds)
 
     def update(self,D):
         for k,v in D.items(): self[k] = v
--- a/src/reportlab/pdfbase/cidfonts.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/src/reportlab/pdfbase/cidfonts.py	Tue Feb 09 11:23:58 2010 +0000
@@ -510,7 +510,8 @@
 ##    print 'constructed all encodings in %0.2f seconds' % (finished - started)
 
 if __name__=='__main__':
-    import doctest, cidfonts
+    import doctest
+    import cidfonts
     doctest.testmod(cidfonts)
     #test()
 
--- a/tools/docco/rltemplate.py	Mon Feb 08 22:28:42 2010 +0000
+++ b/tools/docco/rltemplate.py	Tue Feb 09 11:23:58 2010 +0000
@@ -119,7 +119,8 @@
         self.canv.showOutline()
         self.title = "(Document Title Goes Here)"
         self.chapter = "(No chapter yet)"
-        map(self.seq.reset, ('section', 'chapter'))
+        self.seq.reset('section')
+        self.seq.reset('chapter')
 
     def afterFlowable(self, flowable):
         """Detect Level 1 and 2 headings, build outline,
@@ -143,4 +144,4 @@
                 key = 'ch%ss%s' % (self.seq.thisf("chapter"), self.seq.nextf("section"))
                 self.canv.bookmarkPage(key)
                 self.canv.addOutlineEntry(txt, key, 1, 0)
-                self.notify('TOCEntry', (1, txt, self.page, key))
\ No newline at end of file
+                self.notify('TOCEntry', (1, txt, self.page, key))