tools/pythonpoint/pythonpoint.py
branchpy33
changeset 3794 398ea04239b5
parent 3723 99aa837b6703
child 3944 96735eb0192b
equal deleted inserted replaced
3793:cc3f9cc828f7 3794:398ea04239b5
    69 - fix bug with partially hidden graphics (TODO)
    69 - fix bug with partially hidden graphics (TODO)
    70 - save in combined presentation/handout mode (TODO)
    70 - save in combined presentation/handout mode (TODO)
    71 - add pyRXP support (TODO)
    71 - add pyRXP support (TODO)
    72 """
    72 """
    73 __version__='''$Id$'''
    73 __version__='''$Id$'''
    74 import os, sys, imp, string, pprint, getopt, glob
    74 import os, sys, imp, pprint, getopt, glob
    75 
    75 
    76 from reportlab import rl_config
    76 from reportlab import rl_config
    77 from reportlab.lib import styles
    77 from reportlab.lib import styles
    78 from reportlab.lib import colors
    78 from reportlab.lib import colors
    79 from reportlab.lib.units import cm
    79 from reportlab.lib.units import cm
   664 
   664 
   665         return t
   665         return t
   666 
   666 
   667     def parseData(self):
   667     def parseData(self):
   668         """Try to make sense of the table data!"""
   668         """Try to make sense of the table data!"""
   669         rawdata = string.strip(string.join(self.rawBlocks, ''))
   669         rawdata = ''.join(self.rawBlocks).strip()
   670         lines = string.split(rawdata, self.rowDelim)
   670         lines = rawdata.split(self.rowDelim)
   671         #clean up...
   671         #clean up...
   672         lines = list(map(string.strip, lines))
   672         lines = [line.strip() for line in lines]
   673         self.data = []
   673         self.data = []
   674         for line in lines:
   674         for line in lines:
   675             cells = string.split(line, self.fieldDelim)
   675             cells = line.split(self.fieldDelim)
   676             self.data.append(cells)
   676             self.data.append(cells)
   677 
   677 
   678         #get the width list if not given
   678         #get the width list if not given
   679         if not self.widths:
   679         if not self.widths:
   680             self.widths = [None] * len(self.data[0])
   680             self.widths = [None] * len(self.data[0])
   870     def normalizeText(self):
   870     def normalizeText(self):
   871         """It contains literal XML text typed over several lines.
   871         """It contains literal XML text typed over several lines.
   872         We want to throw away
   872         We want to throw away
   873         tabs, newlines and so on, and only accept embedded string
   873         tabs, newlines and so on, and only accept embedded string
   874         like '\n'"""
   874         like '\n'"""
   875         lines = string.split(self.text, '\n')
   875         lines = self.text.split('\n')
   876         newtext = []
   876         newtext = []
   877         for line in lines:
   877         for line in lines:
   878             newtext.append(string.strip(line))
   878             newtext.append(line.strip())
   879         #accept all the '\n' as newlines
   879         #accept all the '\n' as newlines
   880 
   880 
   881         self.text = newtext
   881         self.text = newtext
   882 
   882 
   883     def drawOn(self, canv):
   883     def drawOn(self, canv):
   897         else:
   897         else:
   898             drawText = self.text
   898             drawText = self.text
   899 
   899 
   900         if self.color is None:
   900         if self.color is None:
   901             return
   901             return
   902         lines = string.split(string.strip(drawText), '\\n')
   902         lines = drawText.strip().split('\\n')
   903         canv.saveState()
   903         canv.saveState()
   904 
   904 
   905         canv.setFont(self.font, self.size)
   905         canv.setFont(self.font, self.size)
   906 
   906 
   907         r,g,b = checkColor(self.color)
   907         r,g,b = checkColor(self.color)
  1041 
  1041 
  1042     args = sys.argv[1:]
  1042     args = sys.argv[1:]
  1043     args = [x for x in args if x and x[0]=='-'] + [x for x in args if not x or x[0]!='-']
  1043     args = [x for x in args if x and x[0]=='-'] + [x for x in args if not x or x[0]!='-']
  1044     try:
  1044     try:
  1045         shortOpts = 'hnvsx'
  1045         shortOpts = 'hnvsx'
  1046         longOpts = string.split('cols= outdir= handout help notes printout verbose silent nofx')
  1046         longOpts = 'cols= outdir= handout help notes printout verbose silent nofx'.split()
  1047         optList, args = getopt.getopt(args, shortOpts, longOpts)
  1047         optList, args = getopt.getopt(args, shortOpts, longOpts)
  1048     except getopt.error as msg:
  1048     except getopt.error as msg:
  1049         options['help'] = 1
  1049         options['help'] = 1
  1050 
  1050 
  1051     if not args and os.path.isfile('pythonpoint.xml'):
  1051     if not args and os.path.isfile('pythonpoint.xml'):