rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
if cmd[0] == 'BACKGROUND': self._bkgrndcmds.append(cmd) if cmd[0] == 'ROWBACKGROUNDS': self._bkgrndcmds.append(cmd) if cmd[0] == 'COLBACKGROUNDS': | if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): | def _addCommand(self,cmd): if cmd[0] == 'BACKGROUND': self._bkgrndcmds.append(cmd) if cmd[0] == 'ROWBACKGROUNDS': self._bkgrndcmds.append(cmd) if cmd[0] == 'COLBACKGROUNDS': self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd)) | 928d797a32fecff3127515e56b53b05033ae789d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/928d797a32fecff3127515e56b53b05033ae789d/tables.py |
elif cmd == 'BACKGROUND': canv.setFillColor(colors.toColor(arg)) canv.rect(x0, y0, w, h, stroke=0,fill=1) | def _drawBkgrnd(self): nrows = self._nrows ncols = self._ncols for cmd, (sc, sr), (ec, er), arg in self._bkgrndcmds: if sc < 0: sc = sc + ncols if ec < 0: ec = ec + ncols if sr < 0: sr = sr + nrows if er < 0: er = er + nrows x0 = self._colpositions[sc] y0 = self._rowpositions[sr] x1 = self._colpositions[min(ec+1,ncols)] y1 = self._rowpositions[min(er+1,nrows)] w, h = x1-x0, y1-y0 canv = self.canv if callable(arg): apply(arg,(self,canv, x0, y0, w, h)) elif cmd == 'BACKGROUND': canv.setFillColor(colors.toColor(arg)) canv.rect(x0, y0, w, h, stroke=0,fill=1) elif cmd == 'ROWBACKGROUNDS': #Need a list of colors to cycle through. The arguments #might be already colours, or convertible to colors, or # None, or the string 'None'. #It's very common to alternate a pale shade with None. #print 'rowHeights=', self._rowHeights colorCycle = map(colors.toColorOrNone, arg) count = len(colorCycle) rowCount = er - sr for i in range(rowCount): color = colorCycle[i%count] h = self._rowHeights[sr + i] if color: canv.setFillColor(color) canv.rect(x0, y0, w, -h, stroke=0,fill=1) #print ' draw %0.0f, %0.0f, %0.0f, %0.0f' % (x0,y0,w,-h) y0 = y0 - h | 928d797a32fecff3127515e56b53b05033ae789d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/928d797a32fecff3127515e56b53b05033ae789d/tables.py |
|
else: canv.setFillColor(colors.toColor(arg)) canv.rect(x0, y0, w, h, stroke=0,fill=1) | def _drawBkgrnd(self): nrows = self._nrows ncols = self._ncols for cmd, (sc, sr), (ec, er), arg in self._bkgrndcmds: if sc < 0: sc = sc + ncols if ec < 0: ec = ec + ncols if sr < 0: sr = sr + nrows if er < 0: er = er + nrows x0 = self._colpositions[sc] y0 = self._rowpositions[sr] x1 = self._colpositions[min(ec+1,ncols)] y1 = self._rowpositions[min(er+1,nrows)] w, h = x1-x0, y1-y0 canv = self.canv if callable(arg): apply(arg,(self,canv, x0, y0, w, h)) elif cmd == 'BACKGROUND': canv.setFillColor(colors.toColor(arg)) canv.rect(x0, y0, w, h, stroke=0,fill=1) elif cmd == 'ROWBACKGROUNDS': #Need a list of colors to cycle through. The arguments #might be already colours, or convertible to colors, or # None, or the string 'None'. #It's very common to alternate a pale shade with None. #print 'rowHeights=', self._rowHeights colorCycle = map(colors.toColorOrNone, arg) count = len(colorCycle) rowCount = er - sr for i in range(rowCount): color = colorCycle[i%count] h = self._rowHeights[sr + i] if color: canv.setFillColor(color) canv.rect(x0, y0, w, -h, stroke=0,fill=1) #print ' draw %0.0f, %0.0f, %0.0f, %0.0f' % (x0,y0,w,-h) y0 = y0 - h | 928d797a32fecff3127515e56b53b05033ae789d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/928d797a32fecff3127515e56b53b05033ae789d/tables.py |
|
path = os.path.basename(sys.argv[0]) path = os.path.splitext(path)[0] + "-%s.log" % expl | path = "test_docstrings-%s.log" % expl | def _writeLogFile(self, objType): "Write log file for different kind of documentable objects." cwd = os.getcwd() | 9ee49bf3a9bf7d615f2b4127ec006150dfdbfc82 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/9ee49bf3a9bf7d615f2b4127ec006150dfdbfc82/test_docstrings.py |
lo = lo + ' bgCol= lineNum marcs help multiPage noOutline config= input= mode=' | lo = lo + ' bgCol= verbose lineNum marcs help multiPage noOutline config= input= mode=' | def updateWithContentsOfArgv(self, argv): "Update options as specified in a (command line) argument vector." # Specify accepted short option names (UNIX style). shortOpts = 'hv' | 7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771/py2pdf.py |
def main(cmdline): "Process command line as if it were sys.argv" # Create default options and initialize with argv # from the command line. options = Options() options.updateWithContentsOfArgv(cmdline[1:]) # Print help message if desired, then exit. if options.h or options.help: print __doc__ sys.exit() # Apply modest consistency checks and exit if needed. cmdStr = string.join(cmdline, ' ') find = string.find if find(cmdStr, 'paperSize') >= 0 and find(cmdStr, 'paperFormat') >= 0: details = "You can specify either paperSize or paperFormat, " details = detail + "but not both!" raise 'ValueError', details # Create PDF converter and pass options to it. if options.input: input = string.lower(options.input) if input == 'python': P = PythonPDFPrinter elif input == 'ascii': P = PDFPrinter else: details = "Input file type must be 'python' or 'ascii'." raise 'ValueError', details else: P = PythonPDFPrinter p = P(options) # Display options if needed. if options.v or options.verbose: pass # p.options.display() # Start working. verbose = options.v or options.verbose if options.stdout: if len(options.files) > 1 and verbose: print "Warning: will only convert first file on command line." f = options.files[0] p.process(f, sys.stdout) else: if verbose: print 'py2pdf: working on:' for f in options.files: try: if verbose: print ' %s' % f if f != '-': p.process(f) else: p.process(sys.stdin, sys.stdout) except IOError: if verbose: print '(IOError!)', if verbose: print print 'Done.' | 7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771/py2pdf.py |
||
noValOpts = 'landscape stdout lineNum marcs help multiPage noOutline' | noValOpts = 'h v verbose landscape stdout lineNum marcs help multiPage noOutline' | def process(*args, **kwargs): "Provides a way of using py2pdf from within other Python scripts." noValOpts = 'landscape stdout lineNum marcs help multiPage noOutline' noValOpts = string.split(noValOpts, ' ') line = string.join(args, ' ') for k, v in kwargs.items(): if len(k) == 1: line = line + ' -%s=%s' % (k, v) elif len(k) > 1: if k in noValOpts: line = line + ' --%s' % k else: line = line + ' --%s=%s' % (k, v) print line | 7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771/py2pdf.py |
line = string.join(args, ' ') | s = 'py2pdf.py' | def process(*args, **kwargs): "Provides a way of using py2pdf from within other Python scripts." noValOpts = 'landscape stdout lineNum marcs help multiPage noOutline' noValOpts = string.split(noValOpts, ' ') line = string.join(args, ' ') for k, v in kwargs.items(): if len(k) == 1: line = line + ' -%s=%s' % (k, v) elif len(k) > 1: if k in noValOpts: line = line + ' --%s' % k else: line = line + ' --%s=%s' % (k, v) print line | 7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771/py2pdf.py |
line = line + ' -%s=%s' % (k, v) | s = s + ' -%s' % k if k not in noValOpts: s = s + ' %s' % v | def process(*args, **kwargs): "Provides a way of using py2pdf from within other Python scripts." noValOpts = 'landscape stdout lineNum marcs help multiPage noOutline' noValOpts = string.split(noValOpts, ' ') line = string.join(args, ' ') for k, v in kwargs.items(): if len(k) == 1: line = line + ' -%s=%s' % (k, v) elif len(k) > 1: if k in noValOpts: line = line + ' --%s' % k else: line = line + ' --%s=%s' % (k, v) print line | 7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771/py2pdf.py |
if k in noValOpts: line = line + ' --%s' % k else: line = line + ' --%s=%s' % (k, v) print line | s = s + ' --%s' % k if k not in noValOpts: s = s + '=%s' % v s = s + ' ' + string.join(args, ' ') s = string.split(s, ' ') main(s) | def process(*args, **kwargs): "Provides a way of using py2pdf from within other Python scripts." noValOpts = 'landscape stdout lineNum marcs help multiPage noOutline' noValOpts = string.split(noValOpts, ' ') line = string.join(args, ' ') for k, v in kwargs.items(): if len(k) == 1: line = line + ' -%s=%s' % (k, v) elif len(k) > 1: if k in noValOpts: line = line + ' --%s' % k else: line = line + ' --%s=%s' % (k, v) print line | 7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7c4e5f9a7ac0d61c0fc6dc782c83bc5c447d3771/py2pdf.py |
if (h > self._aH and not trySplit): | if (not rl_config.allowTableBoundsErrors) and (h > self._aH and not trySplit): | def _add(self, flowable, canv, trySplit=0): """ Draws the flowable at the current position. Returns 1 if successful, 0 if it would not fit. Raises a LayoutError if the object is too wide, or if it is too high for a totally empty frame, to avoid infinite loops""" y = self._y p = self._y1p s = 0 if not self._atTop: s = flowable.getSpaceBefore() h = y - p - s if h>0: flowable.canv = canv #so they can use stringWidth etc w, h = flowable.wrap(self._aW, h) del flowable.canv else: return 0 | 47034ffcf00f5d611fece45d38b03759cbee8d56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/47034ffcf00f5d611fece45d38b03759cbee8d56/frames.py |
slf.contents.insert(i,n) | self.contents.insert(i,n) | def insert(self, i, n, name=None): 'Inserts sub-node n in contents at specified location' assert isValidChild(n), "Can only insert Shape or UserNode objects in a Group" if i<0: self.contents[i:i] =[n] else: slf.contents.insert(i,n) self._addNamedNode(name,n) | ed908168209f3cbb7c6144c0099f5d6ed8fd9f51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/ed908168209f3cbb7c6144c0099f5d6ed8fd9f51/shapes.py |
'fontname':'Times-Roman', | 'fontName':'Times-Roman', | def prepareCanvas(self, canvas): """You can ask a LineStyle to set up the canvas for drawing the lines.""" canvas.setLineWidth(1) #etc. etc. | c6f096615961f3cc92a6eae7567071585913489d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/c6f096615961f3cc92a6eae7567071585913489d/styles.py |
from string import letters as LETTERS, whitespace as WHITESPACE | from string import letters as LETTERS, whitespace as WHITESPACE, atoi | def Paragraph(text, style, bulletText=None, frags=None) | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
heightremaining = maxheight-leading | heightremaining = maxheight if leading: self.leading = leading | def format(self, maxwidth, maxheight, program, leading=0): "return program with line operations added if at least one line fits" # note: a generated formatted segment should not be formatted again startstate = self.__dict__.copy() #remainder = self.cleanProgram(program) remainder = program[:] #program1 = remainder[:] # debug only lineprogram = [] #if maxheight<TOOSMALLSPACE: # raise ValueError, "attempt to format inside too small a height! "+repr(maxheight) heightremaining = maxheight-leading room = 1 cursorcount = 0 # debug while remainder and room: #heightremaining>=self.leading and remainder: #print "getting line with statestack", len(self.textStateStack) #heightremaining = heightremaining - self.leading indent = self.indent rightIndent = self.rightIndent linewidth = maxwidth - indent - rightIndent beforelinestate = self.__dict__.copy() if linewidth<TOOSMALLSPACE: raise ValueError, "indents %s %s too wide for space %s" % (self.indent, self.rightIndent, \ maxwidth) try: (lineIsFull, line, cursor, currentLength, \ usedIndent, maxLength, justStrings) = self.fitLine(remainder, maxwidth) except: | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
textobject.setFont(self.fontName, self.fontSize) | def runOpCodes(self, program, canvas, textobject): "render the line(s)" | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
|
third element of the unnumberred list third element of the unnumberred list third element of the unnumberred list | third element of the unnumberred list & third element of the unnumberred list & third element of the unnumberred list &exist; --> ∃ | def translate(self, nodetuple, controller, context, overrides): thepara = ("para", {}, [nodetuple], None) return theParaMapper.translate(thepara, controller, context, overrides) | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
parsedpara = rparsexml.parsexmlSimple(testparagraph) | parsedpara = rparsexml.parsexmlSimple(testparagraph,entityReplacer=None) | def test2(canv): #print test_program; return from reportlab.lib.units import inch from reportlab.lib.styles import ParagraphStyle from reportlab.lib import rparsexml parsedpara = rparsexml.parsexmlSimple(testparagraph) S = ParagraphStyle("Normal", None) P = Para(S, parsedpara) (w, h) = P.wrap(5*inch, 10*inch) print "wrapped as", (h,w) canv.translate(1*inch, 1*inch) canv.rect(0,0,5*inch,10*inch, fill=0, stroke=1) P.canv = canv P.draw() canv.setStrokeColorRGB(1, 0, 0) #canv.translate(0, 3*inch) canv.rect(0,0,w,-h, fill=0, stroke=1) | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
greeks = { 'alpha':'a', 'beta':'b', 'chi':'c', 'Delta':'D', 'delta':'d', 'epsiv':'e', 'eta':'h', 'Gamma':'G', 'gamma':'g', 'iota':'i', 'kappa':'k', 'Lambda':'L', 'lambda':'l', 'mu':'m', 'nu':'n', 'Omega':'W', 'omega':'w', 'omicron':'x', 'Phi':'F', 'phi':'f', 'phiv':'j', 'Pi':'P', 'pi':'p', 'piv':'v', 'Psi':'Y', 'psi':'y', 'rho':'r', 'Sigma':'S', 'sigma':'s', 'sigmav':'V', 'tau':'t', 'Theta':'Q', 'theta':'q', 'thetav':'j', 'Xi':'X', 'xi':'x', 'zeta':'z', 'amp': '&', 'lt': '<', 'gt': '>', } def handleSpecialCharacters(engine, text, program=None, greeks=greeks): | def handleSpecialCharacters(engine, text, program=None): from paraparser import greeks, symenc | def test2(canv): #print test_program; return from reportlab.lib.units import inch from reportlab.lib.styles import ParagraphStyle from reportlab.lib import rparsexml parsedpara = rparsexml.parsexmlSimple(testparagraph) S = ParagraphStyle("Normal", None) P = Para(S, parsedpara) (w, h) = P.wrap(5*inch, 10*inch) print "wrapped as", (h,w) canv.translate(1*inch, 1*inch) canv.rect(0,0,5*inch,10*inch, fill=0, stroke=1) P.canv = canv P.draw() canv.setStrokeColorRGB(1, 0, 0) #canv.translate(0, 3*inch) canv.rect(0,0,w,-h, fill=0, stroke=1) | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
if greeks.has_key(name): | if name[0]==' try: if name[1] == 'x': n = atoi(name[2:], 16) else: n = atoi(name[1:]) except atoi_error: n = -1 if 0<=n<=255: fragment = chr(n)+fragment[semi+1:] elif symenc.has_key(n): fragment = fragment[semi+1:] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(symenc[n]) engine.shiftfont(program, face=f) if fragment and fragment[0] in WHITESPACE: program.append(" ") else: fragment = "&"+fragment elif standard.has_key(name): fragment = standard[name]+fragment[semi+1:] elif greeks.has_key(name): | def handleSpecialCharacters(engine, text, program=None, greeks=greeks): from string import whitespace # add space prefix if space here if text[0:1] in whitespace: program.append(" ") #print "handling", repr(text) # shortcut if 0 and "&" not in text: result = [] for x in text.split(): result.append(x+" ") if result: last = result[-1] if text[-1:] not in whitespace: result[-1] = last.strip() program.extend(result) return program if program is None: program = [] amptext = text.split("&") first = 1 lastfrag = amptext[-1] for fragment in amptext: if not first: # check for special chars semi = fragment.find(";") if semi>0: name = fragment[:semi] if greeks.has_key(name): fragment = fragment[semi+1:] greeksub = greeks[name] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(greeksub) engine.shiftfont(program, face=f) if fragment and fragment[0] in WHITESPACE: program.append(" ") # follow the greek with a space else: # add back the & fragment = "&"+fragment else: # add back the & fragment = "&"+fragment # add white separated components of fragment followed by space sfragment = fragment.split() for w in sfragment[:-1]: program.append(w+" ") # does the last one need a space? if sfragment and fragment: # reader 3 used to go nuts if you don't special case the last frag, but it's fixed? if fragment[-1] in WHITESPACE: # or fragment==lastfrag: program.append( sfragment[-1]+" " ) else: last = sfragment[-1].strip() if last: #print "last is", repr(last) program.append( last ) first = 0 #print "HANDLED", program return program | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
program.append(" ") | program.append(" ") | def handleSpecialCharacters(engine, text, program=None, greeks=greeks): from string import whitespace # add space prefix if space here if text[0:1] in whitespace: program.append(" ") #print "handling", repr(text) # shortcut if 0 and "&" not in text: result = [] for x in text.split(): result.append(x+" ") if result: last = result[-1] if text[-1:] not in whitespace: result[-1] = last.strip() program.extend(result) return program if program is None: program = [] amptext = text.split("&") first = 1 lastfrag = amptext[-1] for fragment in amptext: if not first: # check for special chars semi = fragment.find(";") if semi>0: name = fragment[:semi] if greeks.has_key(name): fragment = fragment[semi+1:] greeksub = greeks[name] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(greeksub) engine.shiftfont(program, face=f) if fragment and fragment[0] in WHITESPACE: program.append(" ") # follow the greek with a space else: # add back the & fragment = "&"+fragment else: # add back the & fragment = "&"+fragment # add white separated components of fragment followed by space sfragment = fragment.split() for w in sfragment[:-1]: program.append(w+" ") # does the last one need a space? if sfragment and fragment: # reader 3 used to go nuts if you don't special case the last frag, but it's fixed? if fragment[-1] in WHITESPACE: # or fragment==lastfrag: program.append( sfragment[-1]+" " ) else: last = sfragment[-1].strip() if last: #print "last is", repr(last) program.append( last ) first = 0 #print "HANDLED", program return program | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
parsedpara = rparsexml.parsexmlSimple(text) | parsedpara = rparsexml.parsexmlSimple(text,entityReplacer=None) | def Paragraph(text, style, bulletText=None, frags=None, context=None): """ Paragraph(text, style, bulletText=None) intended to be like a platypus Paragraph but better. """ # if there is no & or < in text then use the fast paragraph if "&" not in text and "<" not in text: return FastPara(style, simpletext=text) else: # use the fully featured one. from reportlab.lib import rparsexml parsedpara = rparsexml.parsexmlSimple(text) return Para(style, parsedText=parsedpara, bulletText=bulletText, state=None, context=context) | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
def Paragraph(text, style, bulletText=None, frags=None, context=None): """ Paragraph(text, style, bulletText=None) intended to be like a platypus Paragraph but better. """ # if there is no & or < in text then use the fast paragraph if "&" not in text and "<" not in text: return FastPara(style, simpletext=text) else: # use the fully featured one. from reportlab.lib import rparsexml parsedpara = rparsexml.parsexmlSimple(text) return Para(style, parsedText=parsedpara, bulletText=bulletText, state=None, context=context) | 22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/22c96d47bac7e0dd9cb4e4762c175c7e57ef3fe6/para.py |
||
if hasattr(self,'noImageCaching') and canvas.noImageCaching: | if hasattr(self,'noImageCaching') and self.noImageCaching \ or hasattr(canvas,'noImageCaching') and canvas.noImageCaching: | def drawInlineImage(self, canvas): #, image, x,y, width=None,height=None): """Draw an Image into the specified rectangle. If width and height are omitted, they are calculated from the image size. Also allow file names as well as images. This allows a caching mechanism""" | cdce40738635484ea7ce10b25149f798af92b729 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cdce40738635484ea7ce10b25149f798af92b729/pdfimages.py |
import string | from types import StringType, UnicodeType, InstanceType, TupleType, ListType, FloatType from string import letters as LETTERS, whitespace as WHITESPACE | def Paragraph(text, style, bulletText=None, frags=None) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
def __init__(self, program = None): from reportlab.lib.colors import black if program is None: program = [] self.lineOpHandlers = [] # for handling underlining and hyperlinking, etc self.program = program #self. self.indent = self.rightIndent = 0.0 self.baseindent = 0.0 # adjust this to add more indentation for bullets, eg self.fontName = "Helvetica" self.fontSize = 10 self.leading = 12 self.fontColor = black self.x = self.y = self.rise = 0.0 from reportlab.lib.enums import TA_LEFT self.alignment = TA_LEFT self.textStateStack = [] | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
||
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY | def format(self, maxwidth, maxheight, program, leading=0): "return program with line operations added if at least one line fits" # note: a generated formatted segment should not be formatted again startstate = self.__dict__.copy() #remainder = self.cleanProgram(program) remainder = program[:] #program1 = remainder[:] # debug only lineprogram = [] from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY #if maxheight<TOOSMALLSPACE: # raise ValueError, "attempt to format inside too small a height! "+repr(maxheight) heightremaining = maxheight-leading room = 1 cursorcount = 0 # debug while remainder and room: #heightremaining>=self.leading and remainder: #print "getting line with statestack", len(self.textStateStack) #heightremaining = heightremaining - self.leading indent = self.indent rightIndent = self.rightIndent linewidth = maxwidth - indent - rightIndent beforelinestate = self.__dict__.copy() if linewidth<TOOSMALLSPACE: raise ValueError, "indents %s %s too wide for space %s" % (self.indent, self.rightIndent, maxwidth) try: (lineIsFull, line, cursor, currentLength, usedIndent, maxLength, justStrings) = self.fitLine(remainder, maxwidth) except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
raise ValueError, "indents %s %s too wide for space %s" % (self.indent, self.rightIndent, maxwidth) | raise ValueError, "indents %s %s too wide for space %s" % (self.indent, self.rightIndent, \ maxwidth) | def format(self, maxwidth, maxheight, program, leading=0): "return program with line operations added if at least one line fits" # note: a generated formatted segment should not be formatted again startstate = self.__dict__.copy() #remainder = self.cleanProgram(program) remainder = program[:] #program1 = remainder[:] # debug only lineprogram = [] from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY #if maxheight<TOOSMALLSPACE: # raise ValueError, "attempt to format inside too small a height! "+repr(maxheight) heightremaining = maxheight-leading room = 1 cursorcount = 0 # debug while remainder and room: #heightremaining>=self.leading and remainder: #print "getting line with statestack", len(self.textStateStack) #heightremaining = heightremaining - self.leading indent = self.indent rightIndent = self.rightIndent linewidth = maxwidth - indent - rightIndent beforelinestate = self.__dict__.copy() if linewidth<TOOSMALLSPACE: raise ValueError, "indents %s %s too wide for space %s" % (self.indent, self.rightIndent, maxwidth) try: (lineIsFull, line, cursor, currentLength, usedIndent, maxLength, justStrings) = self.fitLine(remainder, maxwidth) except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
(lineIsFull, line, cursor, currentLength, usedIndent, maxLength, justStrings) = self.fitLine(remainder, maxwidth) | (lineIsFull, line, cursor, currentLength, \ usedIndent, maxLength, justStrings) = self.fitLine(remainder, maxwidth) | def format(self, maxwidth, maxheight, program, leading=0): "return program with line operations added if at least one line fits" # note: a generated formatted segment should not be formatted again startstate = self.__dict__.copy() #remainder = self.cleanProgram(program) remainder = program[:] #program1 = remainder[:] # debug only lineprogram = [] from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY #if maxheight<TOOSMALLSPACE: # raise ValueError, "attempt to format inside too small a height! "+repr(maxheight) heightremaining = maxheight-leading room = 1 cursorcount = 0 # debug while remainder and room: #heightremaining>=self.leading and remainder: #print "getting line with statestack", len(self.textStateStack) #heightremaining = heightremaining - self.leading indent = self.indent rightIndent = self.rightIndent linewidth = maxwidth - indent - rightIndent beforelinestate = self.__dict__.copy() if linewidth<TOOSMALLSPACE: raise ValueError, "indents %s %s too wide for space %s" % (self.indent, self.rightIndent, maxwidth) try: (lineIsFull, line, cursor, currentLength, usedIndent, maxLength, justStrings) = self.fitLine(remainder, maxwidth) except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import StringType, TupleType, InstanceType, FloatType | def fitLine(self, program, totalLength): "fit words (and other things) onto a line" # assuming word lengths and spaces have not been yet added # fit words onto a line up to maxlength, adding spaces and respecting extra space from types import StringType, TupleType, InstanceType, FloatType from reportlab.pdfbase.pdfmetrics import stringWidth usedIndent = self.indent maxLength = totalLength - usedIndent - self.rightIndent done = 0 line = [] cursor = 0 lineIsFull = 0 currentLength = 0 maxcursor = len(program) needspace = 0 first = 1 terminated = None fontName = self.fontName fontSize = self.fontSize spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") justStrings = 1 while not done and cursor<maxcursor: opcode = program[cursor] #if debug: print "opcode", cursor, opcode topcode = type(opcode) if topcode is StringType or topcode is InstanceType: lastneedspace = needspace needspace = 0 if topcode is InstanceType: justStrings = 0 width = opcode.width(self) needspace = 0 else: saveopcode = opcode opcode = opcode.strip() #string.strip(opcode) if opcode: width = stringWidth(opcode, fontName, fontSize) else: width = 0 if saveopcode and (width or currentLength): # ignore white space at margin needspace = (saveopcode[-1]==" ") else: needspace = 0 fullwidth = width if lastneedspace: #spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") fullwidth = width + spacewidth newlength = currentLength+fullwidth if newlength>maxLength and not first: # always do at least one thing # this word won't fit #if debug: # print "WORD", opcode, "wont fit, width", width, "fullwidth", fullwidth # print " currentLength", currentLength, "newlength", newlength, "maxLength", maxLength done = 1 lineIsFull = 1 else: # fit the word: add a space then the word if lastneedspace: line.append( spacewidth ) # expandable space: positive if opcode: line.append( opcode ) if abs(width)>TOOSMALLSPACE: line.append( -width ) # non expanding space: negative currentLength = newlength #print line #stop first = 0 elif topcode is FloatType: justStrings = 0 aopcode = abs(opcode) # negative means non expanding if aopcode>TOOSMALLSPACE: nextLength = currentLength+aopcode if nextLength>maxLength and not first: # always do at least one thing #if debug: print "EXPLICIT spacer won't fit", maxLength, nextLength, opcode done = 1 else: if aopcode>TOOSMALLSPACE: currentLength = nextLength line.append(opcode) first = 0 elif topcode is TupleType: justStrings = 0 indicator = opcode[0] #line.append(opcode) if indicator=="nextLine": # advance to nextLine #(i, endallmarks) = opcode line.append(opcode) cursor = cursor+1 # consume this element terminated = done = 1 #if debug: # print "nextLine encountered" elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) line.append(opcode) elif indicator=="face": # change font face (i, fontname) = opcode fontName = self.fontName = fontname spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading line.append(opcode) elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment if first: usedIndent = max(indent, usedIndent) maxLength = totalLength - usedIndent - self.rightIndent line.append(opcode) elif indicator=="push": self.pushTextState() line.append(opcode) elif indicator=="pop": try: self.popTextState() except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if topcode is StringType or topcode is InstanceType: | if topcode in (StringType, UnicodeType, InstanceType): | def fitLine(self, program, totalLength): "fit words (and other things) onto a line" # assuming word lengths and spaces have not been yet added # fit words onto a line up to maxlength, adding spaces and respecting extra space from types import StringType, TupleType, InstanceType, FloatType from reportlab.pdfbase.pdfmetrics import stringWidth usedIndent = self.indent maxLength = totalLength - usedIndent - self.rightIndent done = 0 line = [] cursor = 0 lineIsFull = 0 currentLength = 0 maxcursor = len(program) needspace = 0 first = 1 terminated = None fontName = self.fontName fontSize = self.fontSize spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") justStrings = 1 while not done and cursor<maxcursor: opcode = program[cursor] #if debug: print "opcode", cursor, opcode topcode = type(opcode) if topcode is StringType or topcode is InstanceType: lastneedspace = needspace needspace = 0 if topcode is InstanceType: justStrings = 0 width = opcode.width(self) needspace = 0 else: saveopcode = opcode opcode = opcode.strip() #string.strip(opcode) if opcode: width = stringWidth(opcode, fontName, fontSize) else: width = 0 if saveopcode and (width or currentLength): # ignore white space at margin needspace = (saveopcode[-1]==" ") else: needspace = 0 fullwidth = width if lastneedspace: #spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") fullwidth = width + spacewidth newlength = currentLength+fullwidth if newlength>maxLength and not first: # always do at least one thing # this word won't fit #if debug: # print "WORD", opcode, "wont fit, width", width, "fullwidth", fullwidth # print " currentLength", currentLength, "newlength", newlength, "maxLength", maxLength done = 1 lineIsFull = 1 else: # fit the word: add a space then the word if lastneedspace: line.append( spacewidth ) # expandable space: positive if opcode: line.append( opcode ) if abs(width)>TOOSMALLSPACE: line.append( -width ) # non expanding space: negative currentLength = newlength #print line #stop first = 0 elif topcode is FloatType: justStrings = 0 aopcode = abs(opcode) # negative means non expanding if aopcode>TOOSMALLSPACE: nextLength = currentLength+aopcode if nextLength>maxLength and not first: # always do at least one thing #if debug: print "EXPLICIT spacer won't fit", maxLength, nextLength, opcode done = 1 else: if aopcode>TOOSMALLSPACE: currentLength = nextLength line.append(opcode) first = 0 elif topcode is TupleType: justStrings = 0 indicator = opcode[0] #line.append(opcode) if indicator=="nextLine": # advance to nextLine #(i, endallmarks) = opcode line.append(opcode) cursor = cursor+1 # consume this element terminated = done = 1 #if debug: # print "nextLine encountered" elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) line.append(opcode) elif indicator=="face": # change font face (i, fontname) = opcode fontName = self.fontName = fontname spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading line.append(opcode) elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment if first: usedIndent = max(indent, usedIndent) maxLength = totalLength - usedIndent - self.rightIndent line.append(opcode) elif indicator=="push": self.pushTextState() line.append(opcode) elif indicator=="pop": try: self.popTextState() except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
opcode = opcode.strip() | opcode = opcode.strip() | def fitLine(self, program, totalLength): "fit words (and other things) onto a line" # assuming word lengths and spaces have not been yet added # fit words onto a line up to maxlength, adding spaces and respecting extra space from types import StringType, TupleType, InstanceType, FloatType from reportlab.pdfbase.pdfmetrics import stringWidth usedIndent = self.indent maxLength = totalLength - usedIndent - self.rightIndent done = 0 line = [] cursor = 0 lineIsFull = 0 currentLength = 0 maxcursor = len(program) needspace = 0 first = 1 terminated = None fontName = self.fontName fontSize = self.fontSize spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") justStrings = 1 while not done and cursor<maxcursor: opcode = program[cursor] #if debug: print "opcode", cursor, opcode topcode = type(opcode) if topcode is StringType or topcode is InstanceType: lastneedspace = needspace needspace = 0 if topcode is InstanceType: justStrings = 0 width = opcode.width(self) needspace = 0 else: saveopcode = opcode opcode = opcode.strip() #string.strip(opcode) if opcode: width = stringWidth(opcode, fontName, fontSize) else: width = 0 if saveopcode and (width or currentLength): # ignore white space at margin needspace = (saveopcode[-1]==" ") else: needspace = 0 fullwidth = width if lastneedspace: #spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") fullwidth = width + spacewidth newlength = currentLength+fullwidth if newlength>maxLength and not first: # always do at least one thing # this word won't fit #if debug: # print "WORD", opcode, "wont fit, width", width, "fullwidth", fullwidth # print " currentLength", currentLength, "newlength", newlength, "maxLength", maxLength done = 1 lineIsFull = 1 else: # fit the word: add a space then the word if lastneedspace: line.append( spacewidth ) # expandable space: positive if opcode: line.append( opcode ) if abs(width)>TOOSMALLSPACE: line.append( -width ) # non expanding space: negative currentLength = newlength #print line #stop first = 0 elif topcode is FloatType: justStrings = 0 aopcode = abs(opcode) # negative means non expanding if aopcode>TOOSMALLSPACE: nextLength = currentLength+aopcode if nextLength>maxLength and not first: # always do at least one thing #if debug: print "EXPLICIT spacer won't fit", maxLength, nextLength, opcode done = 1 else: if aopcode>TOOSMALLSPACE: currentLength = nextLength line.append(opcode) first = 0 elif topcode is TupleType: justStrings = 0 indicator = opcode[0] #line.append(opcode) if indicator=="nextLine": # advance to nextLine #(i, endallmarks) = opcode line.append(opcode) cursor = cursor+1 # consume this element terminated = done = 1 #if debug: # print "nextLine encountered" elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) line.append(opcode) elif indicator=="face": # change font face (i, fontname) = opcode fontName = self.fontName = fontname spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading line.append(opcode) elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment if first: usedIndent = max(indent, usedIndent) maxLength = totalLength - usedIndent - self.rightIndent line.append(opcode) elif indicator=="push": self.pushTextState() line.append(opcode) elif indicator=="pop": try: self.popTextState() except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if type(colorname) is StringType: | if type(colorname) in (StringType, UnicodeType): | def fitLine(self, program, totalLength): "fit words (and other things) onto a line" # assuming word lengths and spaces have not been yet added # fit words onto a line up to maxlength, adding spaces and respecting extra space from types import StringType, TupleType, InstanceType, FloatType from reportlab.pdfbase.pdfmetrics import stringWidth usedIndent = self.indent maxLength = totalLength - usedIndent - self.rightIndent done = 0 line = [] cursor = 0 lineIsFull = 0 currentLength = 0 maxcursor = len(program) needspace = 0 first = 1 terminated = None fontName = self.fontName fontSize = self.fontSize spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") justStrings = 1 while not done and cursor<maxcursor: opcode = program[cursor] #if debug: print "opcode", cursor, opcode topcode = type(opcode) if topcode is StringType or topcode is InstanceType: lastneedspace = needspace needspace = 0 if topcode is InstanceType: justStrings = 0 width = opcode.width(self) needspace = 0 else: saveopcode = opcode opcode = opcode.strip() #string.strip(opcode) if opcode: width = stringWidth(opcode, fontName, fontSize) else: width = 0 if saveopcode and (width or currentLength): # ignore white space at margin needspace = (saveopcode[-1]==" ") else: needspace = 0 fullwidth = width if lastneedspace: #spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") fullwidth = width + spacewidth newlength = currentLength+fullwidth if newlength>maxLength and not first: # always do at least one thing # this word won't fit #if debug: # print "WORD", opcode, "wont fit, width", width, "fullwidth", fullwidth # print " currentLength", currentLength, "newlength", newlength, "maxLength", maxLength done = 1 lineIsFull = 1 else: # fit the word: add a space then the word if lastneedspace: line.append( spacewidth ) # expandable space: positive if opcode: line.append( opcode ) if abs(width)>TOOSMALLSPACE: line.append( -width ) # non expanding space: negative currentLength = newlength #print line #stop first = 0 elif topcode is FloatType: justStrings = 0 aopcode = abs(opcode) # negative means non expanding if aopcode>TOOSMALLSPACE: nextLength = currentLength+aopcode if nextLength>maxLength and not first: # always do at least one thing #if debug: print "EXPLICIT spacer won't fit", maxLength, nextLength, opcode done = 1 else: if aopcode>TOOSMALLSPACE: currentLength = nextLength line.append(opcode) first = 0 elif topcode is TupleType: justStrings = 0 indicator = opcode[0] #line.append(opcode) if indicator=="nextLine": # advance to nextLine #(i, endallmarks) = opcode line.append(opcode) cursor = cursor+1 # consume this element terminated = done = 1 #if debug: # print "nextLine encountered" elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) line.append(opcode) elif indicator=="face": # change font face (i, fontname) = opcode fontName = self.fontName = fontname spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading line.append(opcode) elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment if first: usedIndent = max(indent, usedIndent) maxLength = totalLength - usedIndent - self.rightIndent line.append(opcode) elif indicator=="push": self.pushTextState() line.append(opcode) elif indicator=="pop": try: self.popTextState() except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if type(fontsize) is StringType: | if type(fontsize) in (StringType, UnicodeType): | def fitLine(self, program, totalLength): "fit words (and other things) onto a line" # assuming word lengths and spaces have not been yet added # fit words onto a line up to maxlength, adding spaces and respecting extra space from types import StringType, TupleType, InstanceType, FloatType from reportlab.pdfbase.pdfmetrics import stringWidth usedIndent = self.indent maxLength = totalLength - usedIndent - self.rightIndent done = 0 line = [] cursor = 0 lineIsFull = 0 currentLength = 0 maxcursor = len(program) needspace = 0 first = 1 terminated = None fontName = self.fontName fontSize = self.fontSize spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") justStrings = 1 while not done and cursor<maxcursor: opcode = program[cursor] #if debug: print "opcode", cursor, opcode topcode = type(opcode) if topcode is StringType or topcode is InstanceType: lastneedspace = needspace needspace = 0 if topcode is InstanceType: justStrings = 0 width = opcode.width(self) needspace = 0 else: saveopcode = opcode opcode = opcode.strip() #string.strip(opcode) if opcode: width = stringWidth(opcode, fontName, fontSize) else: width = 0 if saveopcode and (width or currentLength): # ignore white space at margin needspace = (saveopcode[-1]==" ") else: needspace = 0 fullwidth = width if lastneedspace: #spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") fullwidth = width + spacewidth newlength = currentLength+fullwidth if newlength>maxLength and not first: # always do at least one thing # this word won't fit #if debug: # print "WORD", opcode, "wont fit, width", width, "fullwidth", fullwidth # print " currentLength", currentLength, "newlength", newlength, "maxLength", maxLength done = 1 lineIsFull = 1 else: # fit the word: add a space then the word if lastneedspace: line.append( spacewidth ) # expandable space: positive if opcode: line.append( opcode ) if abs(width)>TOOSMALLSPACE: line.append( -width ) # non expanding space: negative currentLength = newlength #print line #stop first = 0 elif topcode is FloatType: justStrings = 0 aopcode = abs(opcode) # negative means non expanding if aopcode>TOOSMALLSPACE: nextLength = currentLength+aopcode if nextLength>maxLength and not first: # always do at least one thing #if debug: print "EXPLICIT spacer won't fit", maxLength, nextLength, opcode done = 1 else: if aopcode>TOOSMALLSPACE: currentLength = nextLength line.append(opcode) first = 0 elif topcode is TupleType: justStrings = 0 indicator = opcode[0] #line.append(opcode) if indicator=="nextLine": # advance to nextLine #(i, endallmarks) = opcode line.append(opcode) cursor = cursor+1 # consume this element terminated = done = 1 #if debug: # print "nextLine encountered" elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) line.append(opcode) elif indicator=="face": # change font face (i, fontname) = opcode fontName = self.fontName = fontname spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size spacewidth = stringWidth(" ", fontName, fontSize) #self.sizeOfWord(" ") line.append(opcode) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading line.append(opcode) elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment if first: usedIndent = max(indent, usedIndent) maxLength = totalLength - usedIndent - self.rightIndent line.append(opcode) elif indicator=="push": self.pushTextState() line.append(opcode) elif indicator=="pop": try: self.popTextState() except: | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import StringType, InstanceType | def insertShift(self, line, shift): # insert shift just before first visible element in line from types import StringType, InstanceType result = [] first = 1 for e in line: te = type(e) if first and (te is StringType or te is InstanceType): result.append(shift) first = 0 result.append(e) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if first and (te is StringType or te is InstanceType): | if first and (te in (StringType, UnicodeType, InstanceType)): | def insertShift(self, line, shift): # insert shift just before first visible element in line from types import StringType, InstanceType result = [] first = 1 for e in line: te = type(e) if first and (te is StringType or te is InstanceType): result.append(shift) first = 0 result.append(e) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import InstanceType, StringType, TupleType, FloatType | def justifyAlign(self, line, lineLength, maxLength): diff = maxLength-lineLength # count EXPANDABLE SPACES AFTER THE FIRST VISIBLE from types import InstanceType, StringType, TupleType, FloatType spacecount = 0 visible = 0 for e in line: te = type(e) if te is FloatType and e>TOOSMALLSPACE and visible: spacecount = spacecount+1 elif te is StringType or te is InstanceType: visible = 1 #if debug: print "diff is", diff, "wordcount", wordcount #; die if spacecount<1: return line shift = diff/float(spacecount) if shift<=TOOSMALLSPACE: #if debug: print "shift too small", shift return line first = 1 visible = 0 result = [] cursor = 0 nline = len(line) while cursor<nline: e = line[cursor] te = type(e) result.append(e) if (te is InstanceType or te is StringType): visible = 1 elif te is FloatType and e>TOOSMALLSPACE and visible: expanded = e+shift result[-1] = expanded cursor = cursor+1 return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
elif te is StringType or te is InstanceType: | elif te in (StringType, UnicodeType, InstanceType): | def justifyAlign(self, line, lineLength, maxLength): diff = maxLength-lineLength # count EXPANDABLE SPACES AFTER THE FIRST VISIBLE from types import InstanceType, StringType, TupleType, FloatType spacecount = 0 visible = 0 for e in line: te = type(e) if te is FloatType and e>TOOSMALLSPACE and visible: spacecount = spacecount+1 elif te is StringType or te is InstanceType: visible = 1 #if debug: print "diff is", diff, "wordcount", wordcount #; die if spacecount<1: return line shift = diff/float(spacecount) if shift<=TOOSMALLSPACE: #if debug: print "shift too small", shift return line first = 1 visible = 0 result = [] cursor = 0 nline = len(line) while cursor<nline: e = line[cursor] te = type(e) result.append(e) if (te is InstanceType or te is StringType): visible = 1 elif te is FloatType and e>TOOSMALLSPACE and visible: expanded = e+shift result[-1] = expanded cursor = cursor+1 return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if (te is InstanceType or te is StringType): | if (te in (StringType, UnicodeType, InstanceType)): | def justifyAlign(self, line, lineLength, maxLength): diff = maxLength-lineLength # count EXPANDABLE SPACES AFTER THE FIRST VISIBLE from types import InstanceType, StringType, TupleType, FloatType spacecount = 0 visible = 0 for e in line: te = type(e) if te is FloatType and e>TOOSMALLSPACE and visible: spacecount = spacecount+1 elif te is StringType or te is InstanceType: visible = 1 #if debug: print "diff is", diff, "wordcount", wordcount #; die if spacecount<1: return line shift = diff/float(spacecount) if shift<=TOOSMALLSPACE: #if debug: print "shift too small", shift return line first = 1 visible = 0 result = [] cursor = 0 nline = len(line) while cursor<nline: e = line[cursor] te = type(e) result.append(e) if (te is InstanceType or te is StringType): visible = 1 elif te is FloatType and e>TOOSMALLSPACE and visible: expanded = e+shift result[-1] = expanded cursor = cursor+1 return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
def shrinkWrap(self, line): # for non justified text, collapse adjacent text/shift's into single operations #return line # for testing result = [] index = 0 maxindex = len(line) from types import FloatType, StringType, InstanceType from string import join while index<maxindex: e = line[index] te = type(e) if te is StringType and index<maxindex-1: # collect strings and floats thestrings = [e] thefloats = 0.0 index = index+1 nexte = line[index] tnexte = type(nexte) while index<maxindex and (tnexte is FloatType or tnexte is StringType): # switch to expandable space if appropriate if tnexte is FloatType: if thefloats<0 and nexte>0: thefloats = -thefloats if nexte<0 and thefloats>0: nexte = -nexte thefloats = thefloats + nexte elif tnexte is StringType: thestrings.append(nexte) index = index+1 if index<maxindex: nexte = line[index] tnexte = type(nexte) # wrap up the result s = string.join(thestrings) result.append(s) result.append(float(thefloats)) # back up for unhandled element index = index-1 else: result.append(e) index = index+1 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
||
from types import FloatType, StringType, InstanceType from string import join | def shrinkWrap(self, line): # for non justified text, collapse adjacent text/shift's into single operations #return line # for testing result = [] index = 0 maxindex = len(line) from types import FloatType, StringType, InstanceType from string import join while index<maxindex: e = line[index] te = type(e) if te is StringType and index<maxindex-1: # collect strings and floats thestrings = [e] thefloats = 0.0 index = index+1 nexte = line[index] tnexte = type(nexte) while index<maxindex and (tnexte is FloatType or tnexte is StringType): # switch to expandable space if appropriate if tnexte is FloatType: if thefloats<0 and nexte>0: thefloats = -thefloats if nexte<0 and thefloats>0: nexte = -nexte thefloats = thefloats + nexte elif tnexte is StringType: thestrings.append(nexte) index = index+1 if index<maxindex: nexte = line[index] tnexte = type(nexte) # wrap up the result s = string.join(thestrings) result.append(s) result.append(float(thefloats)) # back up for unhandled element index = index-1 else: result.append(e) index = index+1 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if te is StringType and index<maxindex-1: | if te in (StringType, UnicodeType) and index<maxindex-1: | def shrinkWrap(self, line): # for non justified text, collapse adjacent text/shift's into single operations #return line # for testing result = [] index = 0 maxindex = len(line) from types import FloatType, StringType, InstanceType from string import join while index<maxindex: e = line[index] te = type(e) if te is StringType and index<maxindex-1: # collect strings and floats thestrings = [e] thefloats = 0.0 index = index+1 nexte = line[index] tnexte = type(nexte) while index<maxindex and (tnexte is FloatType or tnexte is StringType): # switch to expandable space if appropriate if tnexte is FloatType: if thefloats<0 and nexte>0: thefloats = -thefloats if nexte<0 and thefloats>0: nexte = -nexte thefloats = thefloats + nexte elif tnexte is StringType: thestrings.append(nexte) index = index+1 if index<maxindex: nexte = line[index] tnexte = type(nexte) # wrap up the result s = string.join(thestrings) result.append(s) result.append(float(thefloats)) # back up for unhandled element index = index-1 else: result.append(e) index = index+1 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
while index<maxindex and (tnexte is FloatType or tnexte is StringType): | while index<maxindex and (tnexte in (FloatType, StringType, UnicodeType)): | def shrinkWrap(self, line): # for non justified text, collapse adjacent text/shift's into single operations #return line # for testing result = [] index = 0 maxindex = len(line) from types import FloatType, StringType, InstanceType from string import join while index<maxindex: e = line[index] te = type(e) if te is StringType and index<maxindex-1: # collect strings and floats thestrings = [e] thefloats = 0.0 index = index+1 nexte = line[index] tnexte = type(nexte) while index<maxindex and (tnexte is FloatType or tnexte is StringType): # switch to expandable space if appropriate if tnexte is FloatType: if thefloats<0 and nexte>0: thefloats = -thefloats if nexte<0 and thefloats>0: nexte = -nexte thefloats = thefloats + nexte elif tnexte is StringType: thestrings.append(nexte) index = index+1 if index<maxindex: nexte = line[index] tnexte = type(nexte) # wrap up the result s = string.join(thestrings) result.append(s) result.append(float(thefloats)) # back up for unhandled element index = index-1 else: result.append(e) index = index+1 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
elif tnexte is StringType: | elif tnexte in (StringType, UnicodeType): | def shrinkWrap(self, line): # for non justified text, collapse adjacent text/shift's into single operations #return line # for testing result = [] index = 0 maxindex = len(line) from types import FloatType, StringType, InstanceType from string import join while index<maxindex: e = line[index] te = type(e) if te is StringType and index<maxindex-1: # collect strings and floats thestrings = [e] thefloats = 0.0 index = index+1 nexte = line[index] tnexte = type(nexte) while index<maxindex and (tnexte is FloatType or tnexte is StringType): # switch to expandable space if appropriate if tnexte is FloatType: if thefloats<0 and nexte>0: thefloats = -thefloats if nexte<0 and thefloats>0: nexte = -nexte thefloats = thefloats + nexte elif tnexte is StringType: thestrings.append(nexte) index = index+1 if index<maxindex: nexte = line[index] tnexte = type(nexte) # wrap up the result s = string.join(thestrings) result.append(s) result.append(float(thefloats)) # back up for unhandled element index = index-1 else: result.append(e) index = index+1 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
s = string.join(thestrings) | s = ' '.join(thestrings) | def shrinkWrap(self, line): # for non justified text, collapse adjacent text/shift's into single operations #return line # for testing result = [] index = 0 maxindex = len(line) from types import FloatType, StringType, InstanceType from string import join while index<maxindex: e = line[index] te = type(e) if te is StringType and index<maxindex-1: # collect strings and floats thestrings = [e] thefloats = 0.0 index = index+1 nexte = line[index] tnexte = type(nexte) while index<maxindex and (tnexte is FloatType or tnexte is StringType): # switch to expandable space if appropriate if tnexte is FloatType: if thefloats<0 and nexte>0: thefloats = -thefloats if nexte<0 and thefloats>0: nexte = -nexte thefloats = thefloats + nexte elif tnexte is StringType: thestrings.append(nexte) index = index+1 if index<maxindex: nexte = line[index] tnexte = type(nexte) # wrap up the result s = string.join(thestrings) result.append(s) result.append(float(thefloats)) # back up for unhandled element index = index-1 else: result.append(e) index = index+1 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import FloatType, TupleType, StringType, InstanceType | def cleanProgram(self, line): "collapse adjacent spacings" #return line # for debugging result = [] last = 0 from types import FloatType, TupleType, StringType, InstanceType for e in line: if type(e) is FloatType: # switch to expandable space if appropriate if last<0 and e>0: last = -last if e<0 and last>0: e = -e last = float(last)+e else: if abs(last)>TOOSMALLSPACE: result.append(last) result.append(e) last = 0 if last: result.append(last) # now go backwards and delete all floats occurring after all visible elements | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if tthis is StringType or tnext is StringType or this is InstanceType or tnext is InstanceType: | if tthis in (StringType, UnicodeType) or \ tnext in (StringType, UnicodeType) or \ this is InstanceType or tnext is InstanceType: | def cleanProgram(self, line): "collapse adjacent spacings" #return line # for debugging result = [] last = 0 from types import FloatType, TupleType, StringType, InstanceType for e in line: if type(e) is FloatType: # switch to expandable space if appropriate if last<0 and e>0: last = -last if e<0 and last>0: e = -e last = float(last)+e else: if abs(last)>TOOSMALLSPACE: result.append(last) result.append(e) last = 0 if last: result.append(last) # now go backwards and delete all floats occurring after all visible elements | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import StringType, TupleType, InstanceType, FloatType | def runOpCodes(self, program, canvas, textobject): "render the line(s)" #import types from types import StringType, TupleType, InstanceType, FloatType escape = canvas._escape code = textobject._code startstate = self.__dict__.copy() font = None size = None # be sure to set them before using them (done lazily below) #textobject.setFont(self.fontName, self.fontSize) textobject.setFillColor(self.fontColor) xstart = self.x thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for opcode in program: topcode = type(opcode) if topcode is StringType or topcode is InstanceType: if not indented: if abs(thislineindent)>TOOSMALLSPACE: #if debug: print "INDENTING", thislineindent #textobject.moveCursor(thislineindent, 0) code.append('%s Td' % fp_str(thislineindent, 0)) self.x = self.x + thislineindent for handler in self.lineOpHandlers: #handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line handler.start_at(self.x, self.y, self, canvas, textobject) # start underlining the next indented = 1 # lazily set font (don't do it again if not needed) if font!=self.fontName or size!=self.fontSize: font = self.fontName size = self.fontSize textobject.setFont(font, size) if topcode is StringType: #textobject.textOut(opcode) text = escape(opcode) code.append('(%s) Tj' % text) else: # drawable thing opcode.execute(self, textobject, canvas) elif topcode is FloatType: # use abs value (ignore expandable marking) opcode = abs(opcode) if opcode>TOOSMALLSPACE: #textobject.moveCursor(opcode, 0) code.append('%s Td' % fp_str(opcode, 0)) self.x = self.x + opcode elif topcode is TupleType: indicator = opcode[0] if indicator=="nextLine": # advance to nextLine (i, endallmarks) = opcode x = self.x y = self.y newy = self.y = self.y-self.leading newx = self.x = xstart thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for handler in self.lineOpHandlers: handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line #handler.start_at(newx, newy, self, canvas, textobject)) # start underlining the next textobject.setTextOrigin(newx, newy) elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) #if debug: # print color.red, color.green, color.blue # print dir(color) #print "color is", color #from reportlab.lib.colors import green #if color is green: print "color is green" if color!=oldcolor: textobject.setFillColor(color) elif indicator=="face": # change font face (i, fontname) = opcode self.fontName = fontname #textobject.setFont(self.fontName, self.fontSize) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size #(i, fontsize) = opcode self.fontSize = fontSize #textobject.setFont(self.fontName, self.fontSize) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment thislineindent = max(thislineindent, indent) elif indicator=="push": self.pushTextState() elif indicator=="pop": oldcolor = self.fontColor oldfont = self.fontName oldsize = self.fontSize self.popTextState() #if CAUSEERROR or oldfont!=self.fontName or oldsize!=self.fontSize: # textobject.setFont(self.fontName, self.fontSize) if oldcolor!=self.fontColor: textobject.setFillColor(self.fontColor) elif indicator=="wordSpacing": (i, ws) = opcode textobject.setWordSpace(ws) elif indicator=="bullet": (i, bullet, indent, font, size) = opcode if abs(self.x-xstart)>TOOSMALLSPACE: raise ValueError, "bullet not at beginning of line" bulletwidth = float(stringWidth(bullet, font, size)) spacewidth = float(stringWidth(" ", font, size)) bulletmin = indent+spacewidth+bulletwidth # decrease the line size to allow bullet as needed if bulletmin > thislineindent: #if debug: print "BULLET IS BIG", bullet, bulletmin, thislineindent thislineindent = bulletmin textobject.moveCursor(indent, 0) textobject.setFont(font, size) textobject.textOut(bullet) textobject.moveCursor(-indent, 0) #textobject.textOut("M") textobject.setFont(self.fontName, self.fontSize) elif indicator=="rightIndent": # increase the right indent (i, increment) = opcode self.rightIndent = self.rightIndent+increment elif indicator=="rise": (i, rise) = opcode newrise = self.rise = self.rise+rise textobject.setRise(newrise) elif indicator=="align": (i, alignment) = opcode self.alignment = alignment elif indicator=="lineOperation": (i, handler) = opcode handler.start_at(self.x, self.y, self, canvas, textobject) #self.lineOpHandlers.append(handler) #if debug: print "adding", handler, self.lineOpHandlers self.lineOpHandlers = self.lineOpHandlers + [handler] # fresh copy! elif indicator=="endLineOperation": (i, handler) = opcode handler.end_at(self.x, self.y, self, canvas, textobject) newh = self.lineOpHandlers = self.lineOpHandlers[:] # fresh copy #if debug: print "removing", handler, self.lineOpHandlers if handler in newh: self.lineOpHandlers.remove(handler) else: pass #print "WARNING: HANDLER", handler, "NOT IN", newh else: raise ValueError, "don't understand indicator "+repr(indicator) else: raise ValueError, "op must be string float or tuple "+repr(opcode) laststate = self.__dict__.copy() #self.resetState(startstate) self.__dict__.update(startstate) return laststate | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if topcode is StringType or topcode is InstanceType: | if topcode in (StringType, UnicodeType, InstanceType): | def runOpCodes(self, program, canvas, textobject): "render the line(s)" #import types from types import StringType, TupleType, InstanceType, FloatType escape = canvas._escape code = textobject._code startstate = self.__dict__.copy() font = None size = None # be sure to set them before using them (done lazily below) #textobject.setFont(self.fontName, self.fontSize) textobject.setFillColor(self.fontColor) xstart = self.x thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for opcode in program: topcode = type(opcode) if topcode is StringType or topcode is InstanceType: if not indented: if abs(thislineindent)>TOOSMALLSPACE: #if debug: print "INDENTING", thislineindent #textobject.moveCursor(thislineindent, 0) code.append('%s Td' % fp_str(thislineindent, 0)) self.x = self.x + thislineindent for handler in self.lineOpHandlers: #handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line handler.start_at(self.x, self.y, self, canvas, textobject) # start underlining the next indented = 1 # lazily set font (don't do it again if not needed) if font!=self.fontName or size!=self.fontSize: font = self.fontName size = self.fontSize textobject.setFont(font, size) if topcode is StringType: #textobject.textOut(opcode) text = escape(opcode) code.append('(%s) Tj' % text) else: # drawable thing opcode.execute(self, textobject, canvas) elif topcode is FloatType: # use abs value (ignore expandable marking) opcode = abs(opcode) if opcode>TOOSMALLSPACE: #textobject.moveCursor(opcode, 0) code.append('%s Td' % fp_str(opcode, 0)) self.x = self.x + opcode elif topcode is TupleType: indicator = opcode[0] if indicator=="nextLine": # advance to nextLine (i, endallmarks) = opcode x = self.x y = self.y newy = self.y = self.y-self.leading newx = self.x = xstart thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for handler in self.lineOpHandlers: handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line #handler.start_at(newx, newy, self, canvas, textobject)) # start underlining the next textobject.setTextOrigin(newx, newy) elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) #if debug: # print color.red, color.green, color.blue # print dir(color) #print "color is", color #from reportlab.lib.colors import green #if color is green: print "color is green" if color!=oldcolor: textobject.setFillColor(color) elif indicator=="face": # change font face (i, fontname) = opcode self.fontName = fontname #textobject.setFont(self.fontName, self.fontSize) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size #(i, fontsize) = opcode self.fontSize = fontSize #textobject.setFont(self.fontName, self.fontSize) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment thislineindent = max(thislineindent, indent) elif indicator=="push": self.pushTextState() elif indicator=="pop": oldcolor = self.fontColor oldfont = self.fontName oldsize = self.fontSize self.popTextState() #if CAUSEERROR or oldfont!=self.fontName or oldsize!=self.fontSize: # textobject.setFont(self.fontName, self.fontSize) if oldcolor!=self.fontColor: textobject.setFillColor(self.fontColor) elif indicator=="wordSpacing": (i, ws) = opcode textobject.setWordSpace(ws) elif indicator=="bullet": (i, bullet, indent, font, size) = opcode if abs(self.x-xstart)>TOOSMALLSPACE: raise ValueError, "bullet not at beginning of line" bulletwidth = float(stringWidth(bullet, font, size)) spacewidth = float(stringWidth(" ", font, size)) bulletmin = indent+spacewidth+bulletwidth # decrease the line size to allow bullet as needed if bulletmin > thislineindent: #if debug: print "BULLET IS BIG", bullet, bulletmin, thislineindent thislineindent = bulletmin textobject.moveCursor(indent, 0) textobject.setFont(font, size) textobject.textOut(bullet) textobject.moveCursor(-indent, 0) #textobject.textOut("M") textobject.setFont(self.fontName, self.fontSize) elif indicator=="rightIndent": # increase the right indent (i, increment) = opcode self.rightIndent = self.rightIndent+increment elif indicator=="rise": (i, rise) = opcode newrise = self.rise = self.rise+rise textobject.setRise(newrise) elif indicator=="align": (i, alignment) = opcode self.alignment = alignment elif indicator=="lineOperation": (i, handler) = opcode handler.start_at(self.x, self.y, self, canvas, textobject) #self.lineOpHandlers.append(handler) #if debug: print "adding", handler, self.lineOpHandlers self.lineOpHandlers = self.lineOpHandlers + [handler] # fresh copy! elif indicator=="endLineOperation": (i, handler) = opcode handler.end_at(self.x, self.y, self, canvas, textobject) newh = self.lineOpHandlers = self.lineOpHandlers[:] # fresh copy #if debug: print "removing", handler, self.lineOpHandlers if handler in newh: self.lineOpHandlers.remove(handler) else: pass #print "WARNING: HANDLER", handler, "NOT IN", newh else: raise ValueError, "don't understand indicator "+repr(indicator) else: raise ValueError, "op must be string float or tuple "+repr(opcode) laststate = self.__dict__.copy() #self.resetState(startstate) self.__dict__.update(startstate) return laststate | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if topcode is StringType: | if topcode in (StringType, UnicodeType): | def runOpCodes(self, program, canvas, textobject): "render the line(s)" #import types from types import StringType, TupleType, InstanceType, FloatType escape = canvas._escape code = textobject._code startstate = self.__dict__.copy() font = None size = None # be sure to set them before using them (done lazily below) #textobject.setFont(self.fontName, self.fontSize) textobject.setFillColor(self.fontColor) xstart = self.x thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for opcode in program: topcode = type(opcode) if topcode is StringType or topcode is InstanceType: if not indented: if abs(thislineindent)>TOOSMALLSPACE: #if debug: print "INDENTING", thislineindent #textobject.moveCursor(thislineindent, 0) code.append('%s Td' % fp_str(thislineindent, 0)) self.x = self.x + thislineindent for handler in self.lineOpHandlers: #handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line handler.start_at(self.x, self.y, self, canvas, textobject) # start underlining the next indented = 1 # lazily set font (don't do it again if not needed) if font!=self.fontName or size!=self.fontSize: font = self.fontName size = self.fontSize textobject.setFont(font, size) if topcode is StringType: #textobject.textOut(opcode) text = escape(opcode) code.append('(%s) Tj' % text) else: # drawable thing opcode.execute(self, textobject, canvas) elif topcode is FloatType: # use abs value (ignore expandable marking) opcode = abs(opcode) if opcode>TOOSMALLSPACE: #textobject.moveCursor(opcode, 0) code.append('%s Td' % fp_str(opcode, 0)) self.x = self.x + opcode elif topcode is TupleType: indicator = opcode[0] if indicator=="nextLine": # advance to nextLine (i, endallmarks) = opcode x = self.x y = self.y newy = self.y = self.y-self.leading newx = self.x = xstart thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for handler in self.lineOpHandlers: handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line #handler.start_at(newx, newy, self, canvas, textobject)) # start underlining the next textobject.setTextOrigin(newx, newy) elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) #if debug: # print color.red, color.green, color.blue # print dir(color) #print "color is", color #from reportlab.lib.colors import green #if color is green: print "color is green" if color!=oldcolor: textobject.setFillColor(color) elif indicator=="face": # change font face (i, fontname) = opcode self.fontName = fontname #textobject.setFont(self.fontName, self.fontSize) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size #(i, fontsize) = opcode self.fontSize = fontSize #textobject.setFont(self.fontName, self.fontSize) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment thislineindent = max(thislineindent, indent) elif indicator=="push": self.pushTextState() elif indicator=="pop": oldcolor = self.fontColor oldfont = self.fontName oldsize = self.fontSize self.popTextState() #if CAUSEERROR or oldfont!=self.fontName or oldsize!=self.fontSize: # textobject.setFont(self.fontName, self.fontSize) if oldcolor!=self.fontColor: textobject.setFillColor(self.fontColor) elif indicator=="wordSpacing": (i, ws) = opcode textobject.setWordSpace(ws) elif indicator=="bullet": (i, bullet, indent, font, size) = opcode if abs(self.x-xstart)>TOOSMALLSPACE: raise ValueError, "bullet not at beginning of line" bulletwidth = float(stringWidth(bullet, font, size)) spacewidth = float(stringWidth(" ", font, size)) bulletmin = indent+spacewidth+bulletwidth # decrease the line size to allow bullet as needed if bulletmin > thislineindent: #if debug: print "BULLET IS BIG", bullet, bulletmin, thislineindent thislineindent = bulletmin textobject.moveCursor(indent, 0) textobject.setFont(font, size) textobject.textOut(bullet) textobject.moveCursor(-indent, 0) #textobject.textOut("M") textobject.setFont(self.fontName, self.fontSize) elif indicator=="rightIndent": # increase the right indent (i, increment) = opcode self.rightIndent = self.rightIndent+increment elif indicator=="rise": (i, rise) = opcode newrise = self.rise = self.rise+rise textobject.setRise(newrise) elif indicator=="align": (i, alignment) = opcode self.alignment = alignment elif indicator=="lineOperation": (i, handler) = opcode handler.start_at(self.x, self.y, self, canvas, textobject) #self.lineOpHandlers.append(handler) #if debug: print "adding", handler, self.lineOpHandlers self.lineOpHandlers = self.lineOpHandlers + [handler] # fresh copy! elif indicator=="endLineOperation": (i, handler) = opcode handler.end_at(self.x, self.y, self, canvas, textobject) newh = self.lineOpHandlers = self.lineOpHandlers[:] # fresh copy #if debug: print "removing", handler, self.lineOpHandlers if handler in newh: self.lineOpHandlers.remove(handler) else: pass #print "WARNING: HANDLER", handler, "NOT IN", newh else: raise ValueError, "don't understand indicator "+repr(indicator) else: raise ValueError, "op must be string float or tuple "+repr(opcode) laststate = self.__dict__.copy() #self.resetState(startstate) self.__dict__.update(startstate) return laststate | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if type(colorname) is StringType: | if type(colorname) in (StringType, UnicodeType): | def runOpCodes(self, program, canvas, textobject): "render the line(s)" #import types from types import StringType, TupleType, InstanceType, FloatType escape = canvas._escape code = textobject._code startstate = self.__dict__.copy() font = None size = None # be sure to set them before using them (done lazily below) #textobject.setFont(self.fontName, self.fontSize) textobject.setFillColor(self.fontColor) xstart = self.x thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for opcode in program: topcode = type(opcode) if topcode is StringType or topcode is InstanceType: if not indented: if abs(thislineindent)>TOOSMALLSPACE: #if debug: print "INDENTING", thislineindent #textobject.moveCursor(thislineindent, 0) code.append('%s Td' % fp_str(thislineindent, 0)) self.x = self.x + thislineindent for handler in self.lineOpHandlers: #handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line handler.start_at(self.x, self.y, self, canvas, textobject) # start underlining the next indented = 1 # lazily set font (don't do it again if not needed) if font!=self.fontName or size!=self.fontSize: font = self.fontName size = self.fontSize textobject.setFont(font, size) if topcode is StringType: #textobject.textOut(opcode) text = escape(opcode) code.append('(%s) Tj' % text) else: # drawable thing opcode.execute(self, textobject, canvas) elif topcode is FloatType: # use abs value (ignore expandable marking) opcode = abs(opcode) if opcode>TOOSMALLSPACE: #textobject.moveCursor(opcode, 0) code.append('%s Td' % fp_str(opcode, 0)) self.x = self.x + opcode elif topcode is TupleType: indicator = opcode[0] if indicator=="nextLine": # advance to nextLine (i, endallmarks) = opcode x = self.x y = self.y newy = self.y = self.y-self.leading newx = self.x = xstart thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for handler in self.lineOpHandlers: handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line #handler.start_at(newx, newy, self, canvas, textobject)) # start underlining the next textobject.setTextOrigin(newx, newy) elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) #if debug: # print color.red, color.green, color.blue # print dir(color) #print "color is", color #from reportlab.lib.colors import green #if color is green: print "color is green" if color!=oldcolor: textobject.setFillColor(color) elif indicator=="face": # change font face (i, fontname) = opcode self.fontName = fontname #textobject.setFont(self.fontName, self.fontSize) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size #(i, fontsize) = opcode self.fontSize = fontSize #textobject.setFont(self.fontName, self.fontSize) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment thislineindent = max(thislineindent, indent) elif indicator=="push": self.pushTextState() elif indicator=="pop": oldcolor = self.fontColor oldfont = self.fontName oldsize = self.fontSize self.popTextState() #if CAUSEERROR or oldfont!=self.fontName or oldsize!=self.fontSize: # textobject.setFont(self.fontName, self.fontSize) if oldcolor!=self.fontColor: textobject.setFillColor(self.fontColor) elif indicator=="wordSpacing": (i, ws) = opcode textobject.setWordSpace(ws) elif indicator=="bullet": (i, bullet, indent, font, size) = opcode if abs(self.x-xstart)>TOOSMALLSPACE: raise ValueError, "bullet not at beginning of line" bulletwidth = float(stringWidth(bullet, font, size)) spacewidth = float(stringWidth(" ", font, size)) bulletmin = indent+spacewidth+bulletwidth # decrease the line size to allow bullet as needed if bulletmin > thislineindent: #if debug: print "BULLET IS BIG", bullet, bulletmin, thislineindent thislineindent = bulletmin textobject.moveCursor(indent, 0) textobject.setFont(font, size) textobject.textOut(bullet) textobject.moveCursor(-indent, 0) #textobject.textOut("M") textobject.setFont(self.fontName, self.fontSize) elif indicator=="rightIndent": # increase the right indent (i, increment) = opcode self.rightIndent = self.rightIndent+increment elif indicator=="rise": (i, rise) = opcode newrise = self.rise = self.rise+rise textobject.setRise(newrise) elif indicator=="align": (i, alignment) = opcode self.alignment = alignment elif indicator=="lineOperation": (i, handler) = opcode handler.start_at(self.x, self.y, self, canvas, textobject) #self.lineOpHandlers.append(handler) #if debug: print "adding", handler, self.lineOpHandlers self.lineOpHandlers = self.lineOpHandlers + [handler] # fresh copy! elif indicator=="endLineOperation": (i, handler) = opcode handler.end_at(self.x, self.y, self, canvas, textobject) newh = self.lineOpHandlers = self.lineOpHandlers[:] # fresh copy #if debug: print "removing", handler, self.lineOpHandlers if handler in newh: self.lineOpHandlers.remove(handler) else: pass #print "WARNING: HANDLER", handler, "NOT IN", newh else: raise ValueError, "don't understand indicator "+repr(indicator) else: raise ValueError, "op must be string float or tuple "+repr(opcode) laststate = self.__dict__.copy() #self.resetState(startstate) self.__dict__.update(startstate) return laststate | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if type(fontsize) is StringType: | if type(fontsize) in (StringType, UnicodeType): | def runOpCodes(self, program, canvas, textobject): "render the line(s)" #import types from types import StringType, TupleType, InstanceType, FloatType escape = canvas._escape code = textobject._code startstate = self.__dict__.copy() font = None size = None # be sure to set them before using them (done lazily below) #textobject.setFont(self.fontName, self.fontSize) textobject.setFillColor(self.fontColor) xstart = self.x thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for opcode in program: topcode = type(opcode) if topcode is StringType or topcode is InstanceType: if not indented: if abs(thislineindent)>TOOSMALLSPACE: #if debug: print "INDENTING", thislineindent #textobject.moveCursor(thislineindent, 0) code.append('%s Td' % fp_str(thislineindent, 0)) self.x = self.x + thislineindent for handler in self.lineOpHandlers: #handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line handler.start_at(self.x, self.y, self, canvas, textobject) # start underlining the next indented = 1 # lazily set font (don't do it again if not needed) if font!=self.fontName or size!=self.fontSize: font = self.fontName size = self.fontSize textobject.setFont(font, size) if topcode is StringType: #textobject.textOut(opcode) text = escape(opcode) code.append('(%s) Tj' % text) else: # drawable thing opcode.execute(self, textobject, canvas) elif topcode is FloatType: # use abs value (ignore expandable marking) opcode = abs(opcode) if opcode>TOOSMALLSPACE: #textobject.moveCursor(opcode, 0) code.append('%s Td' % fp_str(opcode, 0)) self.x = self.x + opcode elif topcode is TupleType: indicator = opcode[0] if indicator=="nextLine": # advance to nextLine (i, endallmarks) = opcode x = self.x y = self.y newy = self.y = self.y-self.leading newx = self.x = xstart thislineindent = self.indent thislinerightIndent = self.rightIndent indented = 0 for handler in self.lineOpHandlers: handler.end_at(x, y, self, canvas, textobject) # finish, eg, underlining this line #handler.start_at(newx, newy, self, canvas, textobject)) # start underlining the next textobject.setTextOrigin(newx, newy) elif indicator=="color": # change fill color oldcolor = self.fontColor (i, colorname) = opcode #print "opcode", opcode if type(colorname) is StringType: color = self.fontColor = getattr(colors, colorname) else: color = self.fontColor = colorname # assume its something sensible :) #if debug: # print color.red, color.green, color.blue # print dir(color) #print "color is", color #from reportlab.lib.colors import green #if color is green: print "color is green" if color!=oldcolor: textobject.setFillColor(color) elif indicator=="face": # change font face (i, fontname) = opcode self.fontName = fontname #textobject.setFont(self.fontName, self.fontSize) elif indicator=="size": # change font size (i, fontsize) = opcode size = abs(float(fontsize)) if type(fontsize) is StringType: if fontsize[:1]=="+": fontSize = self.fontSize = self.fontSize + size elif fontsize[:1]=="-": fontSize = self.fontSize = self.fontSize - size else: fontSize = self.fontSize = size else: fontSize = self.fontSize = size #(i, fontsize) = opcode self.fontSize = fontSize #textobject.setFont(self.fontName, self.fontSize) elif indicator=="leading": # change font leading (i, leading) = opcode self.leading = leading elif indicator=="indent": # increase the indent (i, increment) = opcode indent = self.indent = self.indent + increment thislineindent = max(thislineindent, indent) elif indicator=="push": self.pushTextState() elif indicator=="pop": oldcolor = self.fontColor oldfont = self.fontName oldsize = self.fontSize self.popTextState() #if CAUSEERROR or oldfont!=self.fontName or oldsize!=self.fontSize: # textobject.setFont(self.fontName, self.fontSize) if oldcolor!=self.fontColor: textobject.setFillColor(self.fontColor) elif indicator=="wordSpacing": (i, ws) = opcode textobject.setWordSpace(ws) elif indicator=="bullet": (i, bullet, indent, font, size) = opcode if abs(self.x-xstart)>TOOSMALLSPACE: raise ValueError, "bullet not at beginning of line" bulletwidth = float(stringWidth(bullet, font, size)) spacewidth = float(stringWidth(" ", font, size)) bulletmin = indent+spacewidth+bulletwidth # decrease the line size to allow bullet as needed if bulletmin > thislineindent: #if debug: print "BULLET IS BIG", bullet, bulletmin, thislineindent thislineindent = bulletmin textobject.moveCursor(indent, 0) textobject.setFont(font, size) textobject.textOut(bullet) textobject.moveCursor(-indent, 0) #textobject.textOut("M") textobject.setFont(self.fontName, self.fontSize) elif indicator=="rightIndent": # increase the right indent (i, increment) = opcode self.rightIndent = self.rightIndent+increment elif indicator=="rise": (i, rise) = opcode newrise = self.rise = self.rise+rise textobject.setRise(newrise) elif indicator=="align": (i, alignment) = opcode self.alignment = alignment elif indicator=="lineOperation": (i, handler) = opcode handler.start_at(self.x, self.y, self, canvas, textobject) #self.lineOpHandlers.append(handler) #if debug: print "adding", handler, self.lineOpHandlers self.lineOpHandlers = self.lineOpHandlers + [handler] # fresh copy! elif indicator=="endLineOperation": (i, handler) = opcode handler.end_at(self.x, self.y, self, canvas, textobject) newh = self.lineOpHandlers = self.lineOpHandlers[:] # fresh copy #if debug: print "removing", handler, self.lineOpHandlers if handler in newh: self.lineOpHandlers.remove(handler) else: pass #print "WARNING: HANDLER", handler, "NOT IN", newh else: raise ValueError, "don't understand indicator "+repr(indicator) else: raise ValueError, "op must be string float or tuple "+repr(opcode) laststate = self.__dict__.copy() #self.resetState(startstate) self.__dict__.update(startstate) return laststate | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import StringType | def stringLine(line, length): "simple case: line with just strings and spacings which can be ignored" strings = [] from types import StringType for x in line: if type(x) is StringType: strings.append(x) text = string.join(strings) result = [text, float(length)] nextlinemark = ("nextLine", 0) if line and line[-1]==nextlinemark: result.append( nextlinemark ) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if type(x) is StringType: | if type(x) in (StringType, UnicodeType): | def stringLine(line, length): "simple case: line with just strings and spacings which can be ignored" strings = [] from types import StringType for x in line: if type(x) is StringType: strings.append(x) text = string.join(strings) result = [text, float(length)] nextlinemark = ("nextLine", 0) if line and line[-1]==nextlinemark: result.append( nextlinemark ) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
text = string.join(strings) | text = ' '.join(strings) | def stringLine(line, length): "simple case: line with just strings and spacings which can be ignored" strings = [] from types import StringType for x in line: if type(x) is StringType: strings.append(x) text = string.join(strings) result = [text, float(length)] nextlinemark = ("nextLine", 0) if line and line[-1]==nextlinemark: result.append( nextlinemark ) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import StringType | def simpleJustifyAlign(line, currentLength, maxLength): "simple justification with only strings" strings = [] from types import StringType for x in line[:-1]: if type(x) is StringType: strings.append(x) nspaces = len(strings)-1 slack = maxLength-currentLength text = string.join(strings) if nspaces>0 and slack>0: wordspacing = slack/float(nspaces) result = [("wordSpacing", wordspacing), text, maxLength, ("wordSpacing", 0)] else: result = [text, currentLength, ("nextLine", 0)] nextlinemark = ("nextLine", 0) if line and line[-1]==nextlinemark: result.append( nextlinemark ) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if type(x) is StringType: | if type(x) in (StringType, UnicodeType): | def simpleJustifyAlign(line, currentLength, maxLength): "simple justification with only strings" strings = [] from types import StringType for x in line[:-1]: if type(x) is StringType: strings.append(x) nspaces = len(strings)-1 slack = maxLength-currentLength text = string.join(strings) if nspaces>0 and slack>0: wordspacing = slack/float(nspaces) result = [("wordSpacing", wordspacing), text, maxLength, ("wordSpacing", 0)] else: result = [text, currentLength, ("nextLine", 0)] nextlinemark = ("nextLine", 0) if line and line[-1]==nextlinemark: result.append( nextlinemark ) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
text = string.join(strings) | text = ' '.join(strings) | def simpleJustifyAlign(line, currentLength, maxLength): "simple justification with only strings" strings = [] from types import StringType for x in line[:-1]: if type(x) is StringType: strings.append(x) nspaces = len(strings)-1 slack = maxLength-currentLength text = string.join(strings) if nspaces>0 and slack>0: wordspacing = slack/float(nspaces) result = [("wordSpacing", wordspacing), text, maxLength, ("wordSpacing", 0)] else: result = [text, currentLength, ("nextLine", 0)] nextlinemark = ("nextLine", 0) if line and line[-1]==nextlinemark: result.append( nextlinemark ) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if string.upper(text) in ("Y", "YES", "TRUE", "1"): | if text.upper() in ("Y", "YES", "TRUE", "1"): | def readBool(text): if string.upper(text) in ("Y", "YES", "TRUE", "1"): return 1 elif string.upper(text) in ("N", "NO", "FALSE", "0"): return 0 else: raise RMLError, "true/false attribute has illegal value '%s'" % text | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
elif string.upper(text) in ("N", "NO", "FALSE", "0"): | elif text.upper() in ("N", "NO", "FALSE", "0"): | def readBool(text): if string.upper(text) in ("Y", "YES", "TRUE", "1"): return 1 elif string.upper(text) in ("N", "NO", "FALSE", "0"): return 0 else: raise RMLError, "true/false attribute has illegal value '%s'" % text | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY up = string.upper(text) | up = text.upper() | def readAlignment(text): from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY up = string.upper(text) if up == 'LEFT': return TA_LEFT elif up == 'RIGHT': return TA_RIGHT elif up in ['CENTER', 'CENTRE']: return TA_CENTER elif up == 'JUSTIFY': return TA_JUSTIFY | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
text = string.strip(text) | text = text.strip() | def readLength(text): """Read a dimension measurement: accept "3in", "5cm", "72 pt" and so on.""" text = string.strip(text) try: return float(text) except ValueError: text = string.lower(text) numberText, units = text[:-2],text[-2:] numberText = string.strip(numberText) try: number = float(numberText) except ValueError: raise ValueError, "invalid length attribute '%s'" % text try: multiplier = { 'in':72, 'cm':28.3464566929, #72/2.54; is this accurate? 'mm':2.83464566929, 'pt':1 }[units] except KeyError: raise RMLError, "invalid length attribute '%s'" % text return number * multiplier | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
text = string.lower(text) | text = text.lower() | def readLength(text): """Read a dimension measurement: accept "3in", "5cm", "72 pt" and so on.""" text = string.strip(text) try: return float(text) except ValueError: text = string.lower(text) numberText, units = text[:-2],text[-2:] numberText = string.strip(numberText) try: number = float(numberText) except ValueError: raise ValueError, "invalid length attribute '%s'" % text try: multiplier = { 'in':72, 'cm':28.3464566929, #72/2.54; is this accurate? 'mm':2.83464566929, 'pt':1 }[units] except KeyError: raise RMLError, "invalid length attribute '%s'" % text return number * multiplier | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
numberText = string.strip(numberText) | numberText = numberText.strip() | def readLength(text): """Read a dimension measurement: accept "3in", "5cm", "72 pt" and so on.""" text = string.strip(text) try: return float(text) except ValueError: text = string.lower(text) numberText, units = text[:-2],text[-2:] numberText = string.strip(numberText) try: number = float(numberText) except ValueError: raise ValueError, "invalid length attribute '%s'" % text try: multiplier = { 'in':72, 'cm':28.3464566929, #72/2.54; is this accurate? 'mm':2.83464566929, 'pt':1 }[units] except KeyError: raise RMLError, "invalid length attribute '%s'" % text return number * multiplier | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from string import split, strip s = strip(s) | s = s.strip() | def lengthSequence(s, converter=readLength): """from "(2, 1)" or "2,1" return [2,1], for example""" from string import split, strip s = strip(s) if s[:1]=="(" and s[-1:]==")": s = s[1:-1] sl = split(s, ",") sl = map(strip, sl) sl = map(converter, sl) return sl | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
sl = split(s, ",") sl = map(strip, sl) sl = map(converter, sl) | sl = s.split(',') sl = [s.strip() for s in sl] sl = [converter(s) for s in sl] | def lengthSequence(s, converter=readLength): """from "(2, 1)" or "2,1" return [2,1], for example""" from string import split, strip s = strip(s) if s[:1]=="(" and s[-1:]==")": s = s[1:-1] sl = split(s, ",") sl = map(strip, sl) sl = map(converter, sl) return sl | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if text[0] in string.letters: | if text[0] in LETTERS: | def readColor(text): """Read color names or tuples, RGB or CMYK, and return a Color object.""" if not text: return None from reportlab.lib import colors if text[0] in string.letters: return colors.__dict__[text] tup = lengthSequence(text) msg = "Color tuple must have 3 (or 4) elements for RGB (or CMYC)." assert 3 <= len(tup) <= 4, msg msg = "Color tuple must have all elements <= 1.0." for i in range(len(tup)): assert tup[i] <= 1.0, msg if len(tup) == 3: colClass = colors.Color elif len(tup) == 4: colClass = colors.CMYKColor return apply(colClass, tup) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
"li.defaultStyle": "Definition" | "ul.defaultStyle": "UnorderedList", "ol.defaultStyle": "OrderedList", "li.defaultStyle": "Definition", | def addAttributes(self, dictionary): for key in dictionary.keys(): value = dictionary[key] if value is not None: if hasattr(StyleAttributeConverters, key): converter = getattr(StyleAttributeConverters, key)[0] value = converter(value) setattr(self, key, value) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
words = string.split(simpletext) | words = simpletext.split() | def wrap(self, availableWidth, availableHeight): simpletext = self.simpletext self.availableWidth = availableWidth style = self.style text = self.simpletext rightIndent = style.rightIndent leftIndent = style.leftIndent leading = style.leading font = style.fontName size = style.fontSize firstindent = style.firstLineIndent #textcolor = style.textColor words = string.split(simpletext) lines = [] from reportlab.pdfbase.pdfmetrics import stringWidth spacewidth = stringWidth(" ", font, size) currentline = [] currentlength = 0 firstmaxlength = availableWidth - rightIndent - firstindent maxlength = availableWidth - rightIndent - leftIndent if maxlength<spacewidth: return (spacewidth+rightIndent+firstindent, availableHeight) # need something wider than this! if availableHeight<leading: return (availableWidth, leading) # need something longer if self.lines is None: heightused = 0 cursor = 0 nwords = len(words) done = 0 #heightused = leading # ??? while cursor<nwords and not done: thismaxlength = maxlength if not lines: thismaxlength = firstmaxlength thisword = words[cursor] thiswordsize = stringWidth(thisword, font, size) if currentlength: thiswordsize = thiswordsize+spacewidth nextlength = currentlength + thiswordsize if not currentlength or nextlength<maxlength: # add the word cursor = cursor+1 currentlength = nextlength currentline.append(thisword) #print "currentline", currentline else: # emit the line lines.append( (string.join(currentline), currentlength, len(currentline)) ) currentline = [] currentlength = 0 heightused = heightused+leading if heightused+leading>availableHeight: done = 1 if currentlength and not done: lines.append( (string.join(currentline), currentlength, len(currentline) )) heightused = heightused+leading self.lines = lines self.height = heightused remainder = self.remainder = string.join(words[cursor:]) #print "lines", lines #print "remainder is", remainder else: remainder = None heightused = self.height lines = self.lines if remainder: result = (availableWidth, availableHeight+leading) # need to split else: result = (availableWidth, heightused) #if debug: print "wrap is", (availableWidth, availableHeight), result, len(lines) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
lines.append( (string.join(currentline), currentlength, len(currentline)) ) | lines.append( (' '.join(currentline), currentlength, len(currentline)) ) | def wrap(self, availableWidth, availableHeight): simpletext = self.simpletext self.availableWidth = availableWidth style = self.style text = self.simpletext rightIndent = style.rightIndent leftIndent = style.leftIndent leading = style.leading font = style.fontName size = style.fontSize firstindent = style.firstLineIndent #textcolor = style.textColor words = string.split(simpletext) lines = [] from reportlab.pdfbase.pdfmetrics import stringWidth spacewidth = stringWidth(" ", font, size) currentline = [] currentlength = 0 firstmaxlength = availableWidth - rightIndent - firstindent maxlength = availableWidth - rightIndent - leftIndent if maxlength<spacewidth: return (spacewidth+rightIndent+firstindent, availableHeight) # need something wider than this! if availableHeight<leading: return (availableWidth, leading) # need something longer if self.lines is None: heightused = 0 cursor = 0 nwords = len(words) done = 0 #heightused = leading # ??? while cursor<nwords and not done: thismaxlength = maxlength if not lines: thismaxlength = firstmaxlength thisword = words[cursor] thiswordsize = stringWidth(thisword, font, size) if currentlength: thiswordsize = thiswordsize+spacewidth nextlength = currentlength + thiswordsize if not currentlength or nextlength<maxlength: # add the word cursor = cursor+1 currentlength = nextlength currentline.append(thisword) #print "currentline", currentline else: # emit the line lines.append( (string.join(currentline), currentlength, len(currentline)) ) currentline = [] currentlength = 0 heightused = heightused+leading if heightused+leading>availableHeight: done = 1 if currentlength and not done: lines.append( (string.join(currentline), currentlength, len(currentline) )) heightused = heightused+leading self.lines = lines self.height = heightused remainder = self.remainder = string.join(words[cursor:]) #print "lines", lines #print "remainder is", remainder else: remainder = None heightused = self.height lines = self.lines if remainder: result = (availableWidth, availableHeight+leading) # need to split else: result = (availableWidth, heightused) #if debug: print "wrap is", (availableWidth, availableHeight), result, len(lines) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
lines.append( (string.join(currentline), currentlength, len(currentline) )) | lines.append( (' '.join(currentline), currentlength, len(currentline) )) | def wrap(self, availableWidth, availableHeight): simpletext = self.simpletext self.availableWidth = availableWidth style = self.style text = self.simpletext rightIndent = style.rightIndent leftIndent = style.leftIndent leading = style.leading font = style.fontName size = style.fontSize firstindent = style.firstLineIndent #textcolor = style.textColor words = string.split(simpletext) lines = [] from reportlab.pdfbase.pdfmetrics import stringWidth spacewidth = stringWidth(" ", font, size) currentline = [] currentlength = 0 firstmaxlength = availableWidth - rightIndent - firstindent maxlength = availableWidth - rightIndent - leftIndent if maxlength<spacewidth: return (spacewidth+rightIndent+firstindent, availableHeight) # need something wider than this! if availableHeight<leading: return (availableWidth, leading) # need something longer if self.lines is None: heightused = 0 cursor = 0 nwords = len(words) done = 0 #heightused = leading # ??? while cursor<nwords and not done: thismaxlength = maxlength if not lines: thismaxlength = firstmaxlength thisword = words[cursor] thiswordsize = stringWidth(thisword, font, size) if currentlength: thiswordsize = thiswordsize+spacewidth nextlength = currentlength + thiswordsize if not currentlength or nextlength<maxlength: # add the word cursor = cursor+1 currentlength = nextlength currentline.append(thisword) #print "currentline", currentline else: # emit the line lines.append( (string.join(currentline), currentlength, len(currentline)) ) currentline = [] currentlength = 0 heightused = heightused+leading if heightused+leading>availableHeight: done = 1 if currentlength and not done: lines.append( (string.join(currentline), currentlength, len(currentline) )) heightused = heightused+leading self.lines = lines self.height = heightused remainder = self.remainder = string.join(words[cursor:]) #print "lines", lines #print "remainder is", remainder else: remainder = None heightused = self.height lines = self.lines if remainder: result = (availableWidth, availableHeight+leading) # need to split else: result = (availableWidth, heightused) #if debug: print "wrap is", (availableWidth, availableHeight), result, len(lines) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
remainder = self.remainder = string.join(words[cursor:]) | remainder = self.remainder = ' '.join(words[cursor:]) | def wrap(self, availableWidth, availableHeight): simpletext = self.simpletext self.availableWidth = availableWidth style = self.style text = self.simpletext rightIndent = style.rightIndent leftIndent = style.leftIndent leading = style.leading font = style.fontName size = style.fontSize firstindent = style.firstLineIndent #textcolor = style.textColor words = string.split(simpletext) lines = [] from reportlab.pdfbase.pdfmetrics import stringWidth spacewidth = stringWidth(" ", font, size) currentline = [] currentlength = 0 firstmaxlength = availableWidth - rightIndent - firstindent maxlength = availableWidth - rightIndent - leftIndent if maxlength<spacewidth: return (spacewidth+rightIndent+firstindent, availableHeight) # need something wider than this! if availableHeight<leading: return (availableWidth, leading) # need something longer if self.lines is None: heightused = 0 cursor = 0 nwords = len(words) done = 0 #heightused = leading # ??? while cursor<nwords and not done: thismaxlength = maxlength if not lines: thismaxlength = firstmaxlength thisword = words[cursor] thiswordsize = stringWidth(thisword, font, size) if currentlength: thiswordsize = thiswordsize+spacewidth nextlength = currentlength + thiswordsize if not currentlength or nextlength<maxlength: # add the word cursor = cursor+1 currentlength = nextlength currentline.append(thisword) #print "currentline", currentline else: # emit the line lines.append( (string.join(currentline), currentlength, len(currentline)) ) currentline = [] currentlength = 0 heightused = heightused+leading if heightused+leading>availableHeight: done = 1 if currentlength and not done: lines.append( (string.join(currentline), currentlength, len(currentline) )) heightused = heightused+leading self.lines = lines self.height = heightused remainder = self.remainder = string.join(words[cursor:]) #print "lines", lines #print "remainder is", remainder else: remainder = None heightused = self.height lines = self.lines if remainder: result = (availableWidth, availableHeight+leading) # need to split else: result = (availableWidth, heightused) #if debug: print "wrap is", (availableWidth, availableHeight), result, len(lines) return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY | def draw(self): from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY style = self.style lines = self.lines rightIndent = style.rightIndent leftIndent = style.leftIndent leading = style.leading font = style.fontName size = style.fontSize alignment = style.alignment firstindent = style.firstLineIndent c = self.canv escape = c._escape #if debug: # print "FAST", id(self), "page number", c.getPageNumber() height = self.height #if debug: # c.rect(0,0,-1, height-size, fill=1, stroke=1) c.translate(0, height-size) textobject = c.beginText() code = textobject._code #textobject.setTextOrigin(0,firstindent) textobject.setFont(font, size) if style.textColor: textobject.setFillColor(style.textColor) first = 1 y = 0 basicWidth = self.availableWidth - rightIndent count = 0 nlines = len(lines) while count<nlines: (text, length, nwords) = lines[count] count = count+1 thisindent = leftIndent if first: thisindent = firstindent if alignment==TA_LEFT: x = thisindent elif alignment==TA_CENTER: extra = basicWidth - length x = thisindent + extra/2.0 elif alignment==TA_RIGHT: extra = basicWidth - length x = thisindent + extra elif alignment==TA_JUSTIFY: x = thisindent if count<nlines and nwords>1: # patch from [email protected], 9 Nov 2002, no extraspace on last line textobject.setWordSpace((basicWidth-length)/(nwords-1.0)) else: textobject.setWordSpace(0.0) textobject.setTextOrigin(x,y) text = escape(text) code.append('(%s) Tj' % text) #textobject.textOut(text) y = y-leading c.drawText(textobject) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if context is None: context = defaultContext() self.context = context | self.context = buildContext(context) | def __init__(self, style, parsedText=None, bulletText=None, state=None, context=None, baseindent=0): #print id(self), "para", parsedText self.baseindent = baseindent if context is None: context = defaultContext() self.context = context self.parsedText = parsedText self.bulletText = bulletText self.style1 = style # make sure Flowable doesn't use this unless wanted! call it style1 NOT style #self.spaceBefore = self.spaceAfter = 0 self.program = [] # program before layout self.formattedProgram = [] # after layout self.remainder = None # follow on paragraph if any self.state = state # initial formatting state (for completions) if not state: self.spaceBefore = style.spaceBefore self.spaceAfter = style.spaceAfter #self.spaceBefore = "invalid value" #if hasattr(self, "spaceBefore") and debug: # print "spaceBefore is", self.spaceBefore, self.parsedText self.bold = 0 self.italic = 0 self.face = "times" self.size = 10 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
self.face = "times" self.size = 10 | self.face = style.fontName self.size = style.fontSize | def __init__(self, style, parsedText=None, bulletText=None, state=None, context=None, baseindent=0): #print id(self), "para", parsedText self.baseindent = baseindent if context is None: context = defaultContext() self.context = context self.parsedText = parsedText self.bulletText = bulletText self.style1 = style # make sure Flowable doesn't use this unless wanted! call it style1 NOT style #self.spaceBefore = self.spaceAfter = 0 self.program = [] # program before layout self.formattedProgram = [] # after layout self.remainder = None # follow on paragraph if any self.state = state # initial formatting state (for completions) if not state: self.spaceBefore = style.spaceBefore self.spaceAfter = style.spaceAfter #self.spaceBefore = "invalid value" #if hasattr(self, "spaceBefore") and debug: # print "spaceBefore is", self.spaceBefore, self.parsedText self.bold = 0 self.italic = 0 self.face = "times" self.size = 10 | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
(formattedProgram, remainder, laststate, heightused) = p.format(availableWidth, availableHeight, program, leading) | (formattedProgram, remainder, \ laststate, heightused) = p.format(availableWidth, availableHeight, program, leading) | def wrap(self, availableWidth, availableHeight): if debug: print "WRAPPING", id(self), availableWidth, availableHeight print " ", self.formattedProgram print " ", self.program self.availableHeight = availableHeight self.myengine = p = paragraphEngine() p.baseindent = self.baseindent # for shifting bullets as needed parsedText = self.parsedText formattedProgram = self.formattedProgram state = self.state if state: leading = state["leading"] else: leading = self.style1.leading program = self.program self.cansplit = 1 # until proven otherwise if state: p.resetState(state) p.x = 0 p.y = 0 needatleast = state["leading"] else: needatleast = self.style1.leading if availableHeight<=needatleast: self.cansplit = 0 #if debug: # print "CANNOT COMPILE, NEED AT LEAST", needatleast, 'AVAILABLE', availableHeight return (availableHeight+1, availableWidth) # cannot split if parsedText is None and program is None: raise ValueError, "need parsedText for formatting" if not program: self.program = program = self.compileProgram(parsedText) if not self.formattedProgram: (formattedProgram, remainder, laststate, heightused) = p.format(availableWidth, availableHeight, program, leading) self.formattedProgram = formattedProgram self.height = heightused self.laststate = laststate self.remainderProgram = remainder else: heightused = self.height remainder = None # too big if there is a remainder if remainder: # lie about the height: it must be split anyway #if debug: # print "I need to split", self.formattedProgram # print "heightused", heightused, "available", availableHeight, "remainder", len(remainder) height = availableHeight + 1 #print "laststate is", laststate #print "saving remainder", remainder self.remainder = Para(self.style1, parsedText=None, bulletText=None, state=laststate) self.remainder.program = remainder self.remainder.spaceAfter = self.spaceAfter self.spaceAfter = 0 else: self.remainder = None # no extra height = heightused if height>availableHeight: height = availableHeight-0.1 #if debug: # print "giving height", height, "of", availableHeight, self.parsedText result = (availableWidth, height) if debug: (w, h) = result if abs(availableHeight-h)<0.2: print "exact match???" + repr(availableHeight, h) print "wrap is", (availableWidth, availableHeight), result return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
self.remainder = Para(self.style1, parsedText=None, bulletText=None, state=laststate) | self.remainder = Para(self.style1, parsedText=None, bulletText=None, \ state=laststate, context=self.context) | def wrap(self, availableWidth, availableHeight): if debug: print "WRAPPING", id(self), availableWidth, availableHeight print " ", self.formattedProgram print " ", self.program self.availableHeight = availableHeight self.myengine = p = paragraphEngine() p.baseindent = self.baseindent # for shifting bullets as needed parsedText = self.parsedText formattedProgram = self.formattedProgram state = self.state if state: leading = state["leading"] else: leading = self.style1.leading program = self.program self.cansplit = 1 # until proven otherwise if state: p.resetState(state) p.x = 0 p.y = 0 needatleast = state["leading"] else: needatleast = self.style1.leading if availableHeight<=needatleast: self.cansplit = 0 #if debug: # print "CANNOT COMPILE, NEED AT LEAST", needatleast, 'AVAILABLE', availableHeight return (availableHeight+1, availableWidth) # cannot split if parsedText is None and program is None: raise ValueError, "need parsedText for formatting" if not program: self.program = program = self.compileProgram(parsedText) if not self.formattedProgram: (formattedProgram, remainder, laststate, heightused) = p.format(availableWidth, availableHeight, program, leading) self.formattedProgram = formattedProgram self.height = heightused self.laststate = laststate self.remainderProgram = remainder else: heightused = self.height remainder = None # too big if there is a remainder if remainder: # lie about the height: it must be split anyway #if debug: # print "I need to split", self.formattedProgram # print "heightused", heightused, "available", availableHeight, "remainder", len(remainder) height = availableHeight + 1 #print "laststate is", laststate #print "saving remainder", remainder self.remainder = Para(self.style1, parsedText=None, bulletText=None, state=laststate) self.remainder.program = remainder self.remainder.spaceAfter = self.spaceAfter self.spaceAfter = 0 else: self.remainder = None # no extra height = heightused if height>availableHeight: height = availableHeight-0.1 #if debug: # print "giving height", height, "of", availableHeight, self.parsedText result = (availableWidth, height) if debug: (w, h) = result if abs(availableHeight-h)<0.2: print "exact match???" + repr(availableHeight, h) print "wrap is", (availableWidth, availableHeight), result return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import StringType, InstanceType | def compileProgram(self, parsedText, program=None): style = self.style1 # standard parameters #program = self.program if program is None: program = [] a = program.append fn = style.fontName # add style information if there was no initial state a( ("face", fn ) ) from reportlab.lib.fonts import ps2tt (self.face, self.bold, self.italic) = ps2tt(fn) a( ("size", style.fontSize ) ) self.size = style.fontSize a( ("align", style.alignment ) ) a( ("indent", style.leftIndent ) ) if style.firstLineIndent: a( ("indent", style.firstLineIndent ) ) # must be undone later a( ("rightIndent", style.rightIndent ) ) a( ("leading", style.leading) ) if style.textColor: a( ("color", style.textColor) ) #a( ("nextLine", 0) ) # clear for next line if self.bulletText: self.do_bullet(self.bulletText, program) self.compileComponent(parsedText, program) # now look for a place where to insert the unindent after the first line if style.firstLineIndent: count = 0 from types import StringType, InstanceType for x in program: count = count+1 tx = type(x) if tx is StringType or tx is InstanceType: break program.insert( count, ("indent", -style.firstLineIndent ) ) # defaults to end if no visibles #print "="*8, id(self), "program is" #for x in program: # print x | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if tx is StringType or tx is InstanceType: | if tx in (StringType, UnicodeType, InstanceType): | def compileProgram(self, parsedText, program=None): style = self.style1 # standard parameters #program = self.program if program is None: program = [] a = program.append fn = style.fontName # add style information if there was no initial state a( ("face", fn ) ) from reportlab.lib.fonts import ps2tt (self.face, self.bold, self.italic) = ps2tt(fn) a( ("size", style.fontSize ) ) self.size = style.fontSize a( ("align", style.alignment ) ) a( ("indent", style.leftIndent ) ) if style.firstLineIndent: a( ("indent", style.firstLineIndent ) ) # must be undone later a( ("rightIndent", style.rightIndent ) ) a( ("leading", style.leading) ) if style.textColor: a( ("color", style.textColor) ) #a( ("nextLine", 0) ) # clear for next line if self.bulletText: self.do_bullet(self.bulletText, program) self.compileComponent(parsedText, program) # now look for a place where to insert the unindent after the first line if style.firstLineIndent: count = 0 from types import StringType, InstanceType for x in program: count = count+1 tx = type(x) if tx is StringType or tx is InstanceType: break program.insert( count, ("indent", -style.firstLineIndent ) ) # defaults to end if no visibles #print "="*8, id(self), "program is" #for x in program: # print x | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
def compileProgram(self, parsedText, program=None): style = self.style1 # standard parameters #program = self.program if program is None: program = [] a = program.append fn = style.fontName # add style information if there was no initial state a( ("face", fn ) ) from reportlab.lib.fonts import ps2tt (self.face, self.bold, self.italic) = ps2tt(fn) a( ("size", style.fontSize ) ) self.size = style.fontSize a( ("align", style.alignment ) ) a( ("indent", style.leftIndent ) ) if style.firstLineIndent: a( ("indent", style.firstLineIndent ) ) # must be undone later a( ("rightIndent", style.rightIndent ) ) a( ("leading", style.leading) ) if style.textColor: a( ("color", style.textColor) ) #a( ("nextLine", 0) ) # clear for next line if self.bulletText: self.do_bullet(self.bulletText, program) self.compileComponent(parsedText, program) # now look for a place where to insert the unindent after the first line if style.firstLineIndent: count = 0 from types import StringType, InstanceType for x in program: count = count+1 tx = type(x) if tx is StringType or tx is InstanceType: break program.insert( count, ("indent", -style.firstLineIndent ) ) # defaults to end if no visibles #print "="*8, id(self), "program is" #for x in program: # print x | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
||
if ttext is types.StringType: | if ttext in (StringType, UnicodeType): | def compileComponent(self, parsedText, program): import types ttext = type(parsedText) #program = self.program if ttext is types.StringType: # handle special characters here... # short cut if parsedText: stext = parsedText.strip() #string.strip(parsedText) if not stext: program.append(" ") # contract whitespace to single space else: handleSpecialCharacters(self, parsedText, program) elif ttext is types.ListType: for e in parsedText: self.compileComponent(e, program) elif ttext is types.TupleType: (tagname, attdict, content, extra) = parsedText if not attdict: attdict = {} compilername = "compile_"+tagname compiler = getattr(self, compilername, None) if compiler is not None: compiler(attdict, content, extra, program) else: # just pass the tag through if debug: L = [ "<" + tagname ] a = L.append if not attdict: attdict = {} for (k, v) in attdict.items(): a(" %s=%s" % (k,v)) if content: a(">") a(str(content)) a("</%s>" % tagname) else: a("/>") t = string.join(L, "") handleSpecialCharacters(self, t, program) else: raise ValueError, "don't know how to handle tag " + repr(tagname) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
stext = parsedText.strip() | stext = parsedText.strip() | def compileComponent(self, parsedText, program): import types ttext = type(parsedText) #program = self.program if ttext is types.StringType: # handle special characters here... # short cut if parsedText: stext = parsedText.strip() #string.strip(parsedText) if not stext: program.append(" ") # contract whitespace to single space else: handleSpecialCharacters(self, parsedText, program) elif ttext is types.ListType: for e in parsedText: self.compileComponent(e, program) elif ttext is types.TupleType: (tagname, attdict, content, extra) = parsedText if not attdict: attdict = {} compilername = "compile_"+tagname compiler = getattr(self, compilername, None) if compiler is not None: compiler(attdict, content, extra, program) else: # just pass the tag through if debug: L = [ "<" + tagname ] a = L.append if not attdict: attdict = {} for (k, v) in attdict.items(): a(" %s=%s" % (k,v)) if content: a(">") a(str(content)) a("</%s>" % tagname) else: a("/>") t = string.join(L, "") handleSpecialCharacters(self, t, program) else: raise ValueError, "don't know how to handle tag " + repr(tagname) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
elif ttext is types.ListType: | elif ttext is ListType: | def compileComponent(self, parsedText, program): import types ttext = type(parsedText) #program = self.program if ttext is types.StringType: # handle special characters here... # short cut if parsedText: stext = parsedText.strip() #string.strip(parsedText) if not stext: program.append(" ") # contract whitespace to single space else: handleSpecialCharacters(self, parsedText, program) elif ttext is types.ListType: for e in parsedText: self.compileComponent(e, program) elif ttext is types.TupleType: (tagname, attdict, content, extra) = parsedText if not attdict: attdict = {} compilername = "compile_"+tagname compiler = getattr(self, compilername, None) if compiler is not None: compiler(attdict, content, extra, program) else: # just pass the tag through if debug: L = [ "<" + tagname ] a = L.append if not attdict: attdict = {} for (k, v) in attdict.items(): a(" %s=%s" % (k,v)) if content: a(">") a(str(content)) a("</%s>" % tagname) else: a("/>") t = string.join(L, "") handleSpecialCharacters(self, t, program) else: raise ValueError, "don't know how to handle tag " + repr(tagname) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
elif ttext is types.TupleType: | elif ttext is TupleType: | def compileComponent(self, parsedText, program): import types ttext = type(parsedText) #program = self.program if ttext is types.StringType: # handle special characters here... # short cut if parsedText: stext = parsedText.strip() #string.strip(parsedText) if not stext: program.append(" ") # contract whitespace to single space else: handleSpecialCharacters(self, parsedText, program) elif ttext is types.ListType: for e in parsedText: self.compileComponent(e, program) elif ttext is types.TupleType: (tagname, attdict, content, extra) = parsedText if not attdict: attdict = {} compilername = "compile_"+tagname compiler = getattr(self, compilername, None) if compiler is not None: compiler(attdict, content, extra, program) else: # just pass the tag through if debug: L = [ "<" + tagname ] a = L.append if not attdict: attdict = {} for (k, v) in attdict.items(): a(" %s=%s" % (k,v)) if content: a(">") a(str(content)) a("</%s>" % tagname) else: a("/>") t = string.join(L, "") handleSpecialCharacters(self, t, program) else: raise ValueError, "don't know how to handle tag " + repr(tagname) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
t = string.join(L, "") | t = ''.join(L) | def compileComponent(self, parsedText, program): import types ttext = type(parsedText) #program = self.program if ttext is types.StringType: # handle special characters here... # short cut if parsedText: stext = parsedText.strip() #string.strip(parsedText) if not stext: program.append(" ") # contract whitespace to single space else: handleSpecialCharacters(self, parsedText, program) elif ttext is types.ListType: for e in parsedText: self.compileComponent(e, program) elif ttext is types.TupleType: (tagname, attdict, content, extra) = parsedText if not attdict: attdict = {} compilername = "compile_"+tagname compiler = getattr(self, compilername, None) if compiler is not None: compiler(attdict, content, extra, program) else: # just pass the tag through if debug: L = [ "<" + tagname ] a = L.append if not attdict: attdict = {} for (k, v) in attdict.items(): a(" %s=%s" % (k,v)) if content: a(">") a(str(content)) a("</%s>" % tagname) else: a("/>") t = string.join(L, "") handleSpecialCharacters(self, t, program) else: raise ValueError, "don't know how to handle tag " + repr(tagname) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
import types | def compile_ul(self, attdict, content, extra, program, tagname="ul"): # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker(tagname, atts, self.context) # now do each element as a separate paragraph import types for e in content: te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="li": raise ValueError, "don't expect %s inside list" % repr(tagname) newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts) self.compile_para(newatts, content1, extra, program) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if te is types.StringType: if e.strip(): | if te in (StringType, UnicodeType): if e.strip(): | def compile_ul(self, attdict, content, extra, program, tagname="ul"): # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker(tagname, atts, self.context) # now do each element as a separate paragraph import types for e in content: te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="li": raise ValueError, "don't expect %s inside list" % repr(tagname) newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts) self.compile_para(newatts, content1, extra, program) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
elif te is types.TupleType: | elif te is TupleType: | def compile_ul(self, attdict, content, extra, program, tagname="ul"): # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker(tagname, atts, self.context) # now do each element as a separate paragraph import types for e in content: te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="li": raise ValueError, "don't expect %s inside list" % repr(tagname) newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts) self.compile_para(newatts, content1, extra, program) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
import types | def compile_dl(self, attdict, content, extra, program): # by transformation #print "compile", tagname, attdict atts = attdict.copy() # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker("dl", atts, self.context) # now do each element as a separate paragraph import types contentcopy = list(content) # copy for destruction bullet = "" while contentcopy: e = contentcopy[0] del contentcopy[0] te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif not contentcopy: break # done at ending whitespace else: continue # ignore intermediate whitespace elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="dd" and tagname!="dt": raise ValueError, "don't expect %s here inside list, expect 'dd' or 'dt'" % repr(tagname) if tagname=="dt": if bullet: raise ValueError, "dt will not be displayed unless followed by a dd: "+repr(bullet) if content1: if len(content1)!=1: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) bullet = content1[0] if type(bullet) is not types.StringType: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) elif tagname=="dd": newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts, bl=bullet) self.compile_para(newatts, content1, extra, program) bullet = "" # don't use this bullet again if bullet: raise ValueError, "dt will not be displayed unless followed by a dd"+repr(bullet) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if te is types.StringType: if e.strip(): | if te in (StringType, UnicodeType): if e.strip(): | def compile_dl(self, attdict, content, extra, program): # by transformation #print "compile", tagname, attdict atts = attdict.copy() # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker("dl", atts, self.context) # now do each element as a separate paragraph import types contentcopy = list(content) # copy for destruction bullet = "" while contentcopy: e = contentcopy[0] del contentcopy[0] te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif not contentcopy: break # done at ending whitespace else: continue # ignore intermediate whitespace elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="dd" and tagname!="dt": raise ValueError, "don't expect %s here inside list, expect 'dd' or 'dt'" % repr(tagname) if tagname=="dt": if bullet: raise ValueError, "dt will not be displayed unless followed by a dd: "+repr(bullet) if content1: if len(content1)!=1: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) bullet = content1[0] if type(bullet) is not types.StringType: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) elif tagname=="dd": newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts, bl=bullet) self.compile_para(newatts, content1, extra, program) bullet = "" # don't use this bullet again if bullet: raise ValueError, "dt will not be displayed unless followed by a dd"+repr(bullet) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
elif te is types.TupleType: | elif te is TupleType: | def compile_dl(self, attdict, content, extra, program): # by transformation #print "compile", tagname, attdict atts = attdict.copy() # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker("dl", atts, self.context) # now do each element as a separate paragraph import types contentcopy = list(content) # copy for destruction bullet = "" while contentcopy: e = contentcopy[0] del contentcopy[0] te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif not contentcopy: break # done at ending whitespace else: continue # ignore intermediate whitespace elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="dd" and tagname!="dt": raise ValueError, "don't expect %s here inside list, expect 'dd' or 'dt'" % repr(tagname) if tagname=="dt": if bullet: raise ValueError, "dt will not be displayed unless followed by a dd: "+repr(bullet) if content1: if len(content1)!=1: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) bullet = content1[0] if type(bullet) is not types.StringType: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) elif tagname=="dd": newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts, bl=bullet) self.compile_para(newatts, content1, extra, program) bullet = "" # don't use this bullet again if bullet: raise ValueError, "dt will not be displayed unless followed by a dd"+repr(bullet) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
raise ValueError, "don't expect %s here inside list, expect 'dd' or 'dt'" % repr(tagname) | raise ValueError, "don't expect %s here inside list, expect 'dd' or 'dt'" % \ repr(tagname) | def compile_dl(self, attdict, content, extra, program): # by transformation #print "compile", tagname, attdict atts = attdict.copy() # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker("dl", atts, self.context) # now do each element as a separate paragraph import types contentcopy = list(content) # copy for destruction bullet = "" while contentcopy: e = contentcopy[0] del contentcopy[0] te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif not contentcopy: break # done at ending whitespace else: continue # ignore intermediate whitespace elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="dd" and tagname!="dt": raise ValueError, "don't expect %s here inside list, expect 'dd' or 'dt'" % repr(tagname) if tagname=="dt": if bullet: raise ValueError, "dt will not be displayed unless followed by a dd: "+repr(bullet) if content1: if len(content1)!=1: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) bullet = content1[0] if type(bullet) is not types.StringType: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) elif tagname=="dd": newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts, bl=bullet) self.compile_para(newatts, content1, extra, program) bullet = "" # don't use this bullet again if bullet: raise ValueError, "dt will not be displayed unless followed by a dd"+repr(bullet) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
if len(content1)!=1: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) bullet = content1[0] if type(bullet) is not types.StringType: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) | self.compile_para(attdict1, content1, extra, program) | def compile_dl(self, attdict, content, extra, program): # by transformation #print "compile", tagname, attdict atts = attdict.copy() # by transformation #print "compile", tagname, attdict atts = attdict.copy() bulletmaker = bulletMaker("dl", atts, self.context) # now do each element as a separate paragraph import types contentcopy = list(content) # copy for destruction bullet = "" while contentcopy: e = contentcopy[0] del contentcopy[0] te = type(e) if te is types.StringType: if e.strip(): #string.strip(e): raise ValueError, "don't expect CDATA between list elements" elif not contentcopy: break # done at ending whitespace else: continue # ignore intermediate whitespace elif te is types.TupleType: (tagname, attdict1, content1, extra) = e if tagname!="dd" and tagname!="dt": raise ValueError, "don't expect %s here inside list, expect 'dd' or 'dt'" % repr(tagname) if tagname=="dt": if bullet: raise ValueError, "dt will not be displayed unless followed by a dd: "+repr(bullet) if content1: if len(content1)!=1: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) bullet = content1[0] if type(bullet) is not types.StringType: raise ValueError, "only simple strings supported in dd content currently: "+repr(content1) elif tagname=="dd": newatts = atts.copy() if attdict1: newatts.update(attdict1) bulletmaker.makeBullet(newatts, bl=bullet) self.compile_para(newatts, content1, extra, program) bullet = "" # don't use this bullet again if bullet: raise ValueError, "dt will not be displayed unless followed by a dd"+repr(bullet) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
from types import StringType | def compile_bullet(self, attdict, content, extra, program): from types import StringType ### eventually should allow things like images and graphics in bullets too XXXX if len(content)!=1 or type(content[0]) is not StringType: raise ValueError, "content for bullet must be a single string" text = content[0] self.do_bullet(text, program) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
|
if len(content)!=1 or type(content[0]) is not StringType: | if len(content)!=1 or type(content[0]) not in (StringType, UnicodeType): | def compile_bullet(self, attdict, content, extra, program): from types import StringType ### eventually should allow things like images and graphics in bullets too XXXX if len(content)!=1 or type(content[0]) is not StringType: raise ValueError, "content for bullet must be a single string" text = content[0] self.do_bullet(text, program) | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
thepara = Para(newstyle, content, context=context, bulletText=bulletText) | thepara = Para(newstyle, content, context=context, bulletText=bulletText) | def compile_para(self, attdict, content, extra, program, stylename = "para.defaultStyle"): context = self.context stylename = attdict.get("style", stylename) style = context[stylename] newstyle = SimpleStyle(name="rml2pdf internal embedded style", parent=style) newstyle.addAttributes(attdict) bulletText = attdict.get("bulletText", None) mystyle = self.style1 #newstyle.bulletIndent = mystyle.leftIndent+newstyle.bulletIndent #print "attdict", attdict #print "leftindent, baseindent", mystyle.leftIndent #print "bulletIndent", newstyle.bulletIndent thepara = Para(newstyle, content, context=context, bulletText=bulletText) # possible ref loop on context, break later # now compile it and add it to the program mybaseindent = self.baseindent self.baseindent = thepara.baseindent = mystyle.leftIndent + self.baseindent thepara.linearize(program=program) #print "program so far" #for x in program: # print x program.append( ("nextLine", 0) ) self.baseindent = mybaseindent | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
def compile_para(self, attdict, content, extra, program, stylename = "para.defaultStyle"): context = self.context stylename = attdict.get("style", stylename) style = context[stylename] newstyle = SimpleStyle(name="rml2pdf internal embedded style", parent=style) newstyle.addAttributes(attdict) bulletText = attdict.get("bulletText", None) mystyle = self.style1 #newstyle.bulletIndent = mystyle.leftIndent+newstyle.bulletIndent #print "attdict", attdict #print "leftindent, baseindent", mystyle.leftIndent #print "bulletIndent", newstyle.bulletIndent thepara = Para(newstyle, content, context=context, bulletText=bulletText) # possible ref loop on context, break later # now compile it and add it to the program mybaseindent = self.baseindent self.baseindent = thepara.baseindent = mystyle.leftIndent + self.baseindent thepara.linearize(program=program) #print "program so far" #for x in program: # print x program.append( ("nextLine", 0) ) self.baseindent = mybaseindent | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
||
def compile_para(self, attdict, content, extra, program, stylename = "para.defaultStyle"): context = self.context stylename = attdict.get("style", stylename) style = context[stylename] newstyle = SimpleStyle(name="rml2pdf internal embedded style", parent=style) newstyle.addAttributes(attdict) bulletText = attdict.get("bulletText", None) mystyle = self.style1 #newstyle.bulletIndent = mystyle.leftIndent+newstyle.bulletIndent #print "attdict", attdict #print "leftindent, baseindent", mystyle.leftIndent #print "bulletIndent", newstyle.bulletIndent thepara = Para(newstyle, content, context=context, bulletText=bulletText) # possible ref loop on context, break later # now compile it and add it to the program mybaseindent = self.baseindent self.baseindent = thepara.baseindent = mystyle.leftIndent + self.baseindent thepara.linearize(program=program) #print "program so far" #for x in program: # print x program.append( ("nextLine", 0) ) self.baseindent = mybaseindent | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
||
if type(text) is types.StringType and "&" not in text: | if type(text) in (StringType, UnicodeType) and "&" not in text: | def translate(self, nodetuple, controller, context, overrides): (tagname, attdict, content, extra) = nodetuple stylename = tagname+".defaultStyle" stylename = attdict.get("style", stylename) style = context[stylename] mystyle = SimpleStyle(name="rml2pdf internal style", parent=style) mystyle.addAttributes(attdict) bulletText = attdict.get("bulletText", None) # can we use the fast implementation? import types result = None if not bulletText and len(content)==1: text = content[0] if type(text) is types.StringType and "&" not in text: result = FastPara(mystyle, text) if result is None: result = Para(mystyle, content, context=context, bulletText=bulletText) # possible ref loop on context, break later return result | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
semi = string.find(fragment, ";") | semi = fragment.find(";") | def handleSpecialCharacters(engine, text, program=None, greeks=greeks): from string import whitespace # add space prefix if space here if text[0:1] in whitespace: program.append(" ") #print "handling", repr(text) # shortcut if 0 and "&" not in text: result = [] for x in text.split(): result.append(x+" ") if result: last = result[-1] if text[-1:] not in whitespace: result[-1] = last.strip() program.extend(result) return program if program is None: program = [] amptext = text.split("&") first = 1 lastfrag = amptext[-1] for fragment in amptext: if not first: # check for special chars semi = string.find(fragment, ";") if semi>0: name = fragment[:semi] if greeks.has_key(name): fragment = fragment[semi+1:] greeksub = greeks[name] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(greeksub) engine.shiftfont(program, face=f) if fragment and fragment[0] in string.whitespace: program.append(" ") # follow the greek with a space else: # add back the & fragment = "&"+fragment else: # add back the & fragment = "&"+fragment # add white separated components of fragment followed by space sfragment = fragment.split() for w in sfragment[:-1]: program.append(w+" ") # does the last one need a space? if sfragment and fragment: # reader 3 used to go nuts if you don't special case the last frag, but it's fixed? if fragment[-1] in string.whitespace: # or fragment==lastfrag: program.append( sfragment[-1]+" " ) else: last = sfragment[-1].strip() #string.strip(sfragment[-1]) if last: #print "last is", repr(last) program.append( last ) first = 0 #print "HANDLED", program return program | a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a9fe2a25d7fcc8f510447cdecc4f6473c43d80f7/para.py |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.