tools/pythonpoint/pythonpoint.py
branchpy33
changeset 3721 0c93dd8ff567
parent 3617 ae5744e97c42
child 3723 99aa837b6703
--- a/tools/pythonpoint/pythonpoint.py	Fri Feb 15 15:54:16 2013 +0000
+++ b/tools/pythonpoint/pythonpoint.py	Tue Apr 30 14:20:22 2013 +0100
@@ -223,7 +223,7 @@
     to a list of items...
     """
 
-    itd = indicesToDelete = map(lambda s:s.outlineEntry == None, slides)
+    itd = indicesToDelete = [s.outlineEntry == None for s in slides]
 
     for i in range(len(itd)-1):
         if itd[i] == 1:
@@ -243,7 +243,7 @@
             slides[i].outlineEntry = curOutlineEntry
             slides[i].delete = 0
 
-    slides = filter(lambda s:s.delete == 0, slides)
+    slides = [s for s in slides if s.delete == 0]
 
     return slides
 
@@ -344,13 +344,13 @@
     def saveAsPresentation(self):
         """Write the PDF document, one slide per page."""
         if self.verbose:
-            print 'saving presentation...'
+            print('saving presentation...')
         pageSize = (self.pageWidth, self.pageHeight)
         if self.sourceFilename:
             filename = os.path.splitext(self.sourceFilename)[0] + '.pdf'
         if self.outDir: filename = os.path.join(self.outDir,os.path.basename(filename))
         if self.verbose:
-            print filename
+            print(filename)
         #canv = canvas.Canvas(filename, pagesize = pageSize)
         outfile = getStringIO()
         if self.notes:
@@ -371,7 +371,7 @@
             #need diagnostic output if something wrong with XML
             slideNo = slideNo + 1
             if self.verbose:
-                print 'doing slide %d, id = %s' % (slideNo, slide.id)
+                print('doing slide %d, id = %s' % (slideNo, slide.id))
             if self.notes:
                 #frame and shift the slide
                 #canv.scale(0.67, 0.67)
@@ -510,7 +510,7 @@
         self.content = []
 
     def drawOn(self, canv):
-        print self.content
+        print(self.content)
 
 
 class PPSlide:
@@ -669,7 +669,7 @@
         rawdata = string.strip(string.join(self.rawBlocks, ''))
         lines = string.split(rawdata, self.rowDelim)
         #clean up...
-        lines = map(string.strip, lines)
+        lines = list(map(string.strip, lines))
         self.data = []
         for line in lines:
             cells = string.split(line, self.fieldDelim)
@@ -1006,7 +1006,7 @@
     pdfcontent = pres.save()
 
     if verbose:
-        print 'saved presentation %s.pdf' % os.path.splitext(datafilename)[0]
+        print('saved presentation %s.pdf' % os.path.splitext(datafilename)[0])
     parser.close()
 
     return pdfcontent
@@ -1040,12 +1040,12 @@
                'outDir': None}
 
     args = sys.argv[1:]
-    args = filter(lambda x: x and x[0]=='-',args) + filter(lambda x: not x or x[0]!='-',args)
+    args = [x for x in args if x and x[0]=='-'] + [x for x in args if not x or x[0]!='-']
     try:
         shortOpts = 'hnvsx'
         longOpts = string.split('cols= outdir= handout help notes printout verbose silent nofx')
         optList, args = getopt.getopt(args, shortOpts, longOpts)
-    except getopt.error, msg:
+    except getopt.error as msg:
         options['help'] = 1
 
     if not args and os.path.isfile('pythonpoint.xml'):
@@ -1061,28 +1061,28 @@
         if o == 'cols': options['cols'] = int(v)
         elif o=='outdir': options['outDir'] = v
 
-    if filter(lambda ov: ov[0] == 'handout', optList):
+    if [ov for ov in optList if ov[0] == 'handout']:
         options['handout'] = 1
 
-    if filter(lambda ov: ov[0] == 'printout', optList):
+    if [ov for ov in optList if ov[0] == 'printout']:
         options['printout'] = 1
 
     if optList == [] and args == [] or \
-       filter(lambda ov: ov[0] in ('h', 'help'), optList):
+       [ov for ov in optList if ov[0] in ('h', 'help')]:
         options['help'] = 1
 
-    if filter(lambda ov: ov[0] in ('n', 'notes'), optList):
+    if [ov for ov in optList if ov[0] in ('n', 'notes')]:
         options['notes'] = 1
 
-    if filter(lambda ov: ov[0] in ('x', 'nofx'), optList):
+    if [ov for ov in optList if ov[0] in ('x', 'nofx')]:
         options['fx'] = 0
 
-    if filter(lambda ov: ov[0] in ('v', 'verbose'), optList):
+    if [ov for ov in optList if ov[0] in ('v', 'verbose')]:
         options['verbose'] = 1
 
     #takes priority over verbose.  Used by our test suite etc.
         #to ensure no output at all
-    if filter(lambda ov: ov[0] in ('s', 'silent'), optList):
+    if [ov for ov in optList if ov[0] in ('s', 'silent')]:
         options['silent'] = 1
         options['verbose'] = 0
 
@@ -1093,24 +1093,24 @@
     options, args = handleOptions()
 
     if options['help']:
-        print USAGE_MESSAGE
+        print(USAGE_MESSAGE)
         sys.exit(0)
 
     if options['verbose'] and options['notes']:
-        print 'speaker notes mode'
+        print('speaker notes mode')
 
     if options['verbose'] and options['handout']:
-        print 'handout mode'
+        print('handout mode')
 
     if options['verbose'] and options['printout']:
-        print 'printout mode'
+        print('printout mode')
 
     if not options['fx']:
-        print 'suppressing special effects'
+        print('suppressing special effects')
     for fileGlobs in args:
         files = glob.glob(fileGlobs)
         if not files:
-            print fileGlobs, "not found"
+            print(fileGlobs, "not found")
             return
         for datafile in files:
             if os.path.isfile(datafile):
@@ -1118,7 +1118,7 @@
                 notes, handout, printout, cols, verbose, fx = options['notes'], options['handout'], options['printout'],  options['cols'], options['verbose'], options['fx']
                 process(file, notes, handout, printout, cols, verbose, options['outDir'], fx=fx)
             else:
-                print 'Data file not found:', datafile
+                print('Data file not found:', datafile)
 
 if __name__ == '__main__':
     main()