bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
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
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 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
5,400
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
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 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
5,401
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
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
5,402
def Paragraph(text, style, bulletText=None, frags=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)
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)
5,403
def Paragraph(text, style, bulletText=None, frags=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)
def Paragraph(text, style, bulletText=None, frags=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)
5,404
def link(self, rect, canvas): destinationname = self.url if not self.defined: [x, y, x1, y1] = rect canvas.bookmarkHorizontal(destinationname, x,y1) # use the upper y self.defined = 1
def link(self, rect, canvas): destinationname = self.url if not self.defined: [x, y, x1, y1] = rect canvas.bookmarkHorizontal(destinationname, x, y1) # use the upper y self.defined = 1
5,405
def splitspace(text): # split on spacing but include spaces at element ends stext = string.split(text) result = [] for e in stext: result.append(e+" ") return result
def splitspace(text): # split on spacing but include spaces at element ends stext = text.split() result = [] for e in stext: result.append(e+" ") return result
5,406
def findT1File(fontName,ext='.pfb'): from reportlab.rl_config import T1SearchPath assert T1SearchPath!=[], "No Type-1 font search path" if sys.platform in ('linux2',) and ext=='.pfb': ext = '' n = _findFNR(fontName)+ext for d in T1SearchPath: f = os.path.join(d,n) if os.path.isfile(f): return f return None
def _searchT1Dirs(n): from reportlab.rl_config import T1SearchPath assert T1SearchPath!=[], "No Type-1 font search path" if sys.platform in ('linux2',) and ext=='.pfb': ext = '' n = _findFNR(fontName)+ext for d in T1SearchPath: f = os.path.join(d,n) if os.path.isfile(f): return f return None
5,407
def findT1File(fontName,ext='.pfb'): from reportlab.rl_config import T1SearchPath assert T1SearchPath!=[], "No Type-1 font search path" if sys.platform in ('linux2',) and ext=='.pfb': ext = '' n = _findFNR(fontName)+ext for d in T1SearchPath: f = os.path.join(d,n) if os.path.isfile(f): return f return None
def findT1File(fontName,ext='.pfb'): from reportlab.rl_config import T1SearchPath assert T1SearchPath!=[], "No Type-1 font search path" for d in T1SearchPath: f = os.path.join(d,n) if os.path.isfile(f): return f return None
5,408
def __getitem__(self,x): y = string.lower(x) if y[-8:]=='encoding': y = y[:-8] y = self._XMap[y] return self.data[y]
def __getitem__(self,x): y = string.lower(x) if y[-8:]=='encoding': y = y[:-8] y = self._XMap[y] return self.data[y]
5,409
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,410
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,411
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,412
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,413
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,414
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,415
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,416
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
5,417
def _getStepsAndLabels(self,xVals): if self.dailyFreq: xEOM = [] pm = 0 px = xVals[0] for x in xVals: m = x.month() if pm!=m: if pm: xEOM.append(px) pm = m px = x px = xVals[-1] if xEOM[-1]!=x: xEOM.append(px) steps, labels = self._xAxisTicker(xEOM) else: steps, labels = self._xAxisTicker(xVals) return setps, labels
def _getStepsAndLabels(self,xVals): if self.dailyFreq: xEOM = [] pm = 0 px = xVals[0] for x in xVals: m = x.month() if pm!=m: if pm: xEOM.append(px) pm = m px = x px = xVals[-1] if xEOM[-1]!=x: xEOM.append(px) steps, labels = self._xAxisTicker(xEOM) else: steps, labels = self._xAxisTicker(xVals) return setps, labels
5,418
def _add_3d_bar(x1, x2, y1, y2, xoff, yoff, G=G,strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor): G.add(Polygon((x1,y1,x1+xoff, y1+yoff,x2+xoff, y2+yoff,x2,y2), strokeWidth=strokeWidth, strokeColor=strokeColor, fillColor=fillColor))
def _add_3d_bar(x1, x2, y1, y2, xoff, yoff, G=G,strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor): G.add(Polygon((x1,y1,x1+xoff, y1+yoff,x2+xoff, y2+yoff,x2,y2), strokeWidth=strokeWidth, strokeColor=strokeColor, fillColor=fillColor))
5,419
def _add_3d_bar(x1, x2, y1, y2, xoff, yoff, G=G,strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor): G.add(Polygon((x1,y1,x1+xoff, y1+yoff,x2+xoff, y2+yoff,x2,y2), strokeWidth=strokeWidth, strokeColor=strokeColor, fillColor=fillColor))
def _add_3d_bar(x1, x2, y1, y2, xoff, yoff, G=G,strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor): G.add(Polygon((x1,y1,x1+xoff, y1+yoff,x2+xoff, y2+yoff,x2,y2), strokeWidth=strokeWidth, strokeColor=strokeColor, fillColor=fillColor))
5,420
def F(x,i, slope=slope, y0=y0, x0=x0): return float((x-x0)*slope[i]+y0[i])
def F(x,i, slope=slope, y0=y0, x0=x0): return float((x-x0)*slope[i]+y0[i])
5,421
def _drawBegin(self,org,length): '''Position and configure value axis, return crossing value''' self.valueAxis.setPosition(self.x, self.y, length) self._getConfigureData() self.valueAxis.configure(self._configureData)
def _drawBegin(self,org,length): '''Position and configure value axis, return crossing value''' vA = self.valueAxis vA.setPosition(self.x, self.y, length) self._getConfigureData() self.valueAxis.configure(self._configureData)
5,422
def _drawBegin(self,org,length): '''Position and configure value axis, return crossing value''' self.valueAxis.setPosition(self.x, self.y, length) self._getConfigureData() self.valueAxis.configure(self._configureData)
def _drawBegin(self,org,length): '''Position and configure value axis, return crossing value''' self.valueAxis.setPosition(self.x, self.y, length) self._getConfigureData() self.valueAxis.configure(self._configureData)
5,423
def _drawBegin(self,org,length): '''Position and configure value axis, return crossing value''' self.valueAxis.setPosition(self.x, self.y, length) self._getConfigureData() self.valueAxis.configure(self._configureData)
def_drawBegin(self,org,length):'''Positionandconfigurevalueaxis,returncrossingvalue'''self.valueAxis.setPosition(self.x,self.y,length)self._getConfigureData()self.valueAxis.configure(self._configureData)
5,424
def draw(self): cA, vA = self.categoryAxis, self.valueAxis if vA: ovAjA, vA.joinAxis = vA.joinAxis, cA if cA: ocAjA, cA.joinAxis = cA.joinAxis, vA try: if self._flipXY: cA.setPosition(self._drawBegin(self.x,self.width), self.y, self.height) else: cA.setPosition(self.x, self._drawBegin(self.y,self.height), self.width) return self._drawFinish() finally: if vA: vA.joinAxis = ovAjA if cA: cA.joinAxis = ocAjA
def draw(self): cA, vA = self.categoryAxis, self.valueAxis if vA: ovAjA, vA.joinAxis = vA.joinAxis, cA if cA: ocAjA, cA.joinAxis = cA.joinAxis, vA try: if self._flipXY: cA.setPosition(self._drawBegin(self.x,self.width), self.y, self.height) else: cA.setPosition(self.x, self._drawBegin(self.y,self.height), self.width) return self._drawFinish() finally: if vA: vA.joinAxis = ovAjA if cA: cA.joinAxis = ocAjA
5,425
def _setFont(gs,fontName,fontSize): try: gs.setFont(fontName,fontSize) except _renderPM.Error, errMsg: if errMsg.args[0]!="Can't find font!": raise #here's where we try to add a font to the canvas try: f = getFont(fontName) _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector,open_and_read) except: s1, s2 = map(str,sys.exc_info()[:2]) raise RenderPMError, "Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2) gs.setFont(fontName,fontSize)
def _setFont(gs,fontName,fontSize): try: gs.setFont(fontName,fontSize) except _renderPM.Error, errMsg: if errMsg.args[0]!="Can't find font!": raise #here's where we try to add a font to the canvas try: f = getFont(fontName) if _renderPM._version<='0.98': _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector) else: _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector,open_and_read) except: s1, s2 = map(str,sys.exc_info()[:2]) raise RenderPMError, "Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2) gs.setFont(fontName,fontSize)
5,426
def randomText(theme=STARTUP, sentences=5): #this may or may not be appropriate in your company if theme.lower()=='chomsky': return chomsky(sentences) from random import randint, choice RANDOMWORDS = theme #sentences = 5 output = "" for sentenceno in range(randint(1,sentences)): output = output + 'Blah' for wordno in range(randint(10,25)): if randint(0,4)==0: word = choice(RANDOMWORDS) else: word = 'blah' output = output + ' ' +word output = output+'. ' return output
def randomText(theme=STARTUP, sentences=5): #this may or may not be appropriate in your company if type(theme)==type(''): if theme.lower()=='chomsky': return chomsky(sentences) elif theme.upper() in ('STARTUP','COMPUTERS','BLAH','BUZZWORD','STARTREK','PRINTING','PYTHON'): theme = globals()[theme] else: raise ValueError('Unknown theme "%s"' % theme) from random import randint, choice RANDOMWORDS = theme #sentences = 5 output = "" for sentenceno in range(randint(1,sentences)): output = output + 'Blah' for wordno in range(randint(10,25)): if randint(0,4)==0: word = choice(RANDOMWORDS) else: word = 'blah' output = output + ' ' +word output = output+'. ' return output
5,427
def moveCursor(self, dx, dy): """Moves to a point dx, dy away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" if self._code and self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) if dx<>0 or dy<>0: self._code.append('%s Td' % fp_str(dx, -dy))
def moveCursor(self, dx, dy): """Moves to a point dx, dy away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" if self._code and self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) if dx<>0 or dy<>0: self._code.append('%s Td' % fp_str(dx, -dy))
5,428
def setXPos(self, dx): """Moves to a point dx away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" if self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) if dx<>0: self._code.append('%s 0 Td' % fp_str(dx))
def setXPos(self, dx): """Moves to a point dx away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" if self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) if dx<>0: self._code.append('%s 0 Td' % fp_str(dx))
5,429
def _AsciiBase85Encode(input): """This is a compact encoding used for binary data within a PDF file. Four bytes of binary data become five bytes of ASCII. This is the default method used for encoding images.""" outstream = cStringIO.StringIO() # special rules apply if not a multiple of four bytes. whole_word_count, remainder_size = divmod(len(input), 4) cut = 4 * whole_word_count body, lastbit = input[0:cut], input[cut:] for i in range(whole_word_count): offset = i*4 b1 = ord(body[offset]) b2 = ord(body[offset+1]) b3 = ord(body[offset+2]) b4 = ord(body[offset+3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 if num == 0: #special case outstream.write('z') else: #solve for five base-85 numbers temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) assert ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 == num, 'dodgy code!' outstream.write(chr(c1+33)) outstream.write(chr(c2+33)) outstream.write(chr(c3+33)) outstream.write(chr(c4+33)) outstream.write(chr(c5+33)) # now we do the final bit at the end. I repeated this separately as # the loop above is the time-critical part of a script, whereas this # happens only once at the end. #encode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 4: lastbit = lastbit + '\000' b1 = ord(lastbit[0]) b2 = ord(lastbit[1]) b3 = ord(lastbit[2]) b4 = ord(lastbit[3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 #solve for c1..c5 temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) #print 'encoding: %d %d %d %d -> %d -> %d %d %d %d %d' % ( # b1,b2,b3,b4,num,c1,c2,c3,c4,c5) lastword = chr(c1+33) + chr(c2+33) + chr(c3+33) + chr(c4+33) + chr(c5+33) #write out most of the bytes. outstream.write(lastword[0:remainder_size + 1]) #terminator code for ascii 85 outstream.write('~>') outstream.reset() return outstream.read()
def _AsciiBase85Encode(input): """This is a compact encoding used for binary data within a PDF file. Four bytes of binary data become five bytes of ASCII. This is the default method used for encoding images.""" outstream = cStringIO.StringIO() # special rules apply if not a multiple of four bytes. whole_word_count, remainder_size = divmod(len(input), 4) cut = 4 * whole_word_count body, lastbit = input[0:cut], input[cut:] for i in range(whole_word_count): offset = i*4 b1 = ord(body[offset]) b2 = ord(body[offset+1]) b3 = ord(body[offset+2]) b4 = ord(body[offset+3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 if num == 0: #special case outstream.write('z') else: #solve for five base-85 numbers temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) assert ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 == num, 'dodgy code!' outstream.write(chr(c1+33)) outstream.write(chr(c2+33)) outstream.write(chr(c3+33)) outstream.write(chr(c4+33)) outstream.write(chr(c5+33)) # now we do the final bit at the end. I repeated this separately as # the loop above is the time-critical part of a script, whereas this # happens only once at the end. #encode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 4: lastbit = lastbit + '\000' b1 = ord(lastbit[0]) b2 = ord(lastbit[1]) b3 = ord(lastbit[2]) b4 = ord(lastbit[3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 #solve for c1..c5 temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) #print 'encoding: %d %d %d %d -> %d -> %d %d %d %d %d' % ( # b1,b2,b3,b4,num,c1,c2,c3,c4,c5) lastword = chr(c1+33) + chr(c2+33) + chr(c3+33) + chr(c4+33) + chr(c5+33) #write out most of the bytes. outstream.write(lastword[0:remainder_size + 1]) #terminator code for ascii 85 outstream.write('~>') outstream.reset() return outstream.read()
5,430
def _AsciiBase85Encode(input): """This is a compact encoding used for binary data within a PDF file. Four bytes of binary data become five bytes of ASCII. This is the default method used for encoding images.""" outstream = cStringIO.StringIO() # special rules apply if not a multiple of four bytes. whole_word_count, remainder_size = divmod(len(input), 4) cut = 4 * whole_word_count body, lastbit = input[0:cut], input[cut:] for i in range(whole_word_count): offset = i*4 b1 = ord(body[offset]) b2 = ord(body[offset+1]) b3 = ord(body[offset+2]) b4 = ord(body[offset+3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 if num == 0: #special case outstream.write('z') else: #solve for five base-85 numbers temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) assert ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 == num, 'dodgy code!' outstream.write(chr(c1+33)) outstream.write(chr(c2+33)) outstream.write(chr(c3+33)) outstream.write(chr(c4+33)) outstream.write(chr(c5+33)) # now we do the final bit at the end. I repeated this separately as # the loop above is the time-critical part of a script, whereas this # happens only once at the end. #encode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 4: lastbit = lastbit + '\000' b1 = ord(lastbit[0]) b2 = ord(lastbit[1]) b3 = ord(lastbit[2]) b4 = ord(lastbit[3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 #solve for c1..c5 temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) #print 'encoding: %d %d %d %d -> %d -> %d %d %d %d %d' % ( # b1,b2,b3,b4,num,c1,c2,c3,c4,c5) lastword = chr(c1+33) + chr(c2+33) + chr(c3+33) + chr(c4+33) + chr(c5+33) #write out most of the bytes. outstream.write(lastword[0:remainder_size + 1]) #terminator code for ascii 85 outstream.write('~>') outstream.reset() return outstream.read()
def _AsciiBase85Encode(input): """This is a compact encoding used for binary data within a PDF file. Four bytes of binary data become five bytes of ASCII. This is the default method used for encoding images.""" outstream = cStringIO.StringIO() # special rules apply if not a multiple of four bytes. whole_word_count, remainder_size = divmod(len(input), 4) cut = 4 * whole_word_count body, lastbit = input[0:cut], input[cut:] for i in range(whole_word_count): offset = i*4 b1 = ord(body[offset]) b2 = ord(body[offset+1]) b3 = ord(body[offset+2]) b4 = ord(body[offset+3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 if num == 0: #special case outstream.write('z') else: #solve for five base-85 numbers temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) assert ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 == num, 'dodgy code!' outstream.write(chr(c1+33)) outstream.write(chr(c2+33)) outstream.write(chr(c3+33)) outstream.write(chr(c4+33)) outstream.write(chr(c5+33)) # now we do the final bit at the end. I repeated this separately as # the loop above is the time-critical part of a script, whereas this # happens only once at the end. #encode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 4: lastbit = lastbit + '\000' b1 = ord(lastbit[0]) b2 = ord(lastbit[1]) b3 = ord(lastbit[2]) b4 = ord(lastbit[3]) num = 16777216L * b1 + 65536 * b2 + 256 * b3 + b4 #solve for c1..c5 temp, c5 = divmod(num, 85) temp, c4 = divmod(temp, 85) temp, c3 = divmod(temp, 85) c1, c2 = divmod(temp, 85) #print 'encoding: %d %d %d %d -> %d -> %d %d %d %d %d' % ( # b1,b2,b3,b4,num,c1,c2,c3,c4,c5) lastword = chr(c1+33) + chr(c2+33) + chr(c3+33) + chr(c4+33) + chr(c5+33) #write out most of the bytes. outstream.write(lastword[0:remainder_size + 1]) #terminator code for ascii 85 outstream.write('~>') outstream.reset() return outstream.read()
5,431
def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream' stripped = stripped[:-2] #chop off terminator #may have 'z' in it which complicates matters - expand them stripped = string.replace(stripped,'z','!!!!!') # special rules apply if not a multiple of five bytes. whole_word_count, remainder_size = divmod(len(stripped), 5) #print '%d words, %d leftover' % (whole_word_count, remainder_size) assert remainder_size <> 1, 'invalid Ascii 85 stream!' cut = 5 * whole_word_count body, lastbit = stripped[0:cut], stripped[cut:] for i in range(whole_word_count): offset = i*5 c1 = ord(body[offset]) - 33 c2 = ord(body[offset+1]) - 33 c3 = ord(body[offset+2]) - 33 c4 = ord(body[offset+3]) - 33 c5 = ord(body[offset+4]) - 33 num = ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' outstream.write(chr(b1)) outstream.write(chr(b2)) outstream.write(chr(b3)) outstream.write(chr(b4)) #decode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 5: lastbit = lastbit + '!' c1 = ord(lastbit[0]) - 33 c2 = ord(lastbit[1]) - 33 c3 = ord(lastbit[2]) - 33 c4 = ord(lastbit[3]) - 33 c5 = ord(lastbit[4]) - 33 num = ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' #print 'decoding: %d %d %d %d %d -> %d -> %d %d %d %d' % ( # c1,c2,c3,c4,c5,num,b1,b2,b3,b4) #the last character needs 1 adding; the encoding loses #data by rounding the number to x bytes, and when #divided repeatedly we get one less if remainder_size == 2: lastword = chr(b1+1) elif remainder_size == 3: lastword = chr(b1) + chr(b2+1) elif remainder_size == 4: lastword = chr(b1) + chr(b2) + chr(b3+1) outstream.write(lastword) #terminator code for ascii 85 outstream.reset() return outstream.read()
def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream' stripped = stripped[:-2] #chop off terminator #may have 'z' in it which complicates matters - expand them stripped = string.replace(stripped,'z','!!!!!') # special rules apply if not a multiple of five bytes. whole_word_count, remainder_size = divmod(len(stripped), 5) #print '%d words, %d leftover' % (whole_word_count, remainder_size) assert remainder_size <> 1, 'invalid Ascii 85 stream!' cut = 5 * whole_word_count body, lastbit = stripped[0:cut], stripped[cut:] for i in range(whole_word_count): offset = i*5 c1 = ord(body[offset]) - 33 c2 = ord(body[offset+1]) - 33 c3 = ord(body[offset+2]) - 33 c4 = ord(body[offset+3]) - 33 c5 = ord(body[offset+4]) - 33 num = ((85L**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' outstream.write(chr(b1)) outstream.write(chr(b2)) outstream.write(chr(b3)) outstream.write(chr(b4)) #decode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 5: lastbit = lastbit + '!' c1 = ord(lastbit[0]) - 33 c2 = ord(lastbit[1]) - 33 c3 = ord(lastbit[2]) - 33 c4 = ord(lastbit[3]) - 33 c5 = ord(lastbit[4]) - 33 num = ((85L**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' #print 'decoding: %d %d %d %d %d -> %d -> %d %d %d %d' % ( # c1,c2,c3,c4,c5,num,b1,b2,b3,b4) #the last character needs 1 adding; the encoding loses #data by rounding the number to x bytes, and when #divided repeatedly we get one less if remainder_size == 2: lastword = chr(b1+1) elif remainder_size == 3: lastword = chr(b1) + chr(b2+1) elif remainder_size == 4: lastword = chr(b1) + chr(b2) + chr(b3+1) outstream.write(lastword) #terminator code for ascii 85 outstream.reset() return outstream.read()
5,432
def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream' stripped = stripped[:-2] #chop off terminator #may have 'z' in it which complicates matters - expand them stripped = string.replace(stripped,'z','!!!!!') # special rules apply if not a multiple of five bytes. whole_word_count, remainder_size = divmod(len(stripped), 5) #print '%d words, %d leftover' % (whole_word_count, remainder_size) assert remainder_size <> 1, 'invalid Ascii 85 stream!' cut = 5 * whole_word_count body, lastbit = stripped[0:cut], stripped[cut:] for i in range(whole_word_count): offset = i*5 c1 = ord(body[offset]) - 33 c2 = ord(body[offset+1]) - 33 c3 = ord(body[offset+2]) - 33 c4 = ord(body[offset+3]) - 33 c5 = ord(body[offset+4]) - 33 num = ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' outstream.write(chr(b1)) outstream.write(chr(b2)) outstream.write(chr(b3)) outstream.write(chr(b4)) #decode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 5: lastbit = lastbit + '!' c1 = ord(lastbit[0]) - 33 c2 = ord(lastbit[1]) - 33 c3 = ord(lastbit[2]) - 33 c4 = ord(lastbit[3]) - 33 c5 = ord(lastbit[4]) - 33 num = ((85**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' #print 'decoding: %d %d %d %d %d -> %d -> %d %d %d %d' % ( # c1,c2,c3,c4,c5,num,b1,b2,b3,b4) #the last character needs 1 adding; the encoding loses #data by rounding the number to x bytes, and when #divided repeatedly we get one less if remainder_size == 2: lastword = chr(b1+1) elif remainder_size == 3: lastword = chr(b1) + chr(b2+1) elif remainder_size == 4: lastword = chr(b1) + chr(b2) + chr(b3+1) outstream.write(lastword) #terminator code for ascii 85 outstream.reset() return outstream.read()
def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream' stripped = stripped[:-2] #chop off terminator #may have 'z' in it which complicates matters - expand them stripped = string.replace(stripped,'z','!!!!!') # special rules apply if not a multiple of five bytes. whole_word_count, remainder_size = divmod(len(stripped), 5) #print '%d words, %d leftover' % (whole_word_count, remainder_size) assert remainder_size <> 1, 'invalid Ascii 85 stream!' cut = 5 * whole_word_count body, lastbit = stripped[0:cut], stripped[cut:] for i in range(whole_word_count): offset = i*5 c1 = ord(body[offset]) - 33 c2 = ord(body[offset+1]) - 33 c3 = ord(body[offset+2]) - 33 c4 = ord(body[offset+3]) - 33 c5 = ord(body[offset+4]) - 33 num = ((85L**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' outstream.write(chr(b1)) outstream.write(chr(b2)) outstream.write(chr(b3)) outstream.write(chr(b4)) #decode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 5: lastbit = lastbit + '!' c1 = ord(lastbit[0]) - 33 c2 = ord(lastbit[1]) - 33 c3 = ord(lastbit[2]) - 33 c4 = ord(lastbit[3]) - 33 c5 = ord(lastbit[4]) - 33 num = ((85L**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' #print 'decoding: %d %d %d %d %d -> %d -> %d %d %d %d' % ( # c1,c2,c3,c4,c5,num,b1,b2,b3,b4) #the last character needs 1 adding; the encoding loses #data by rounding the number to x bytes, and when #divided repeatedly we get one less if remainder_size == 2: lastword = chr(b1+1) elif remainder_size == 3: lastword = chr(b1) + chr(b2+1) elif remainder_size == 4: lastword = chr(b1) + chr(b2) + chr(b3+1) outstream.write(lastword) #terminator code for ascii 85 outstream.reset() return outstream.read()
5,433
def _calculateMaxWidth(self, colorNamePairs): "Calculate the maximum width of some given strings." M = [] a = M.append for t in self._getTexts(colorNamePairs): m = [stringWidth(s, self.fontName, self.fontSize) for s in t.split('\n')] M.append(m and max(m) or 0) return self.variColumn and [max(M[r:r+3]) for r in range(0,len(M),self.columnMaximum)] or max(M)
def _calculateMaxWidth(self, colorNamePairs): "Calculate the maximum width of some given strings." M = [] a = M.append for t in self._getTexts(colorNamePairs): m = [stringWidth(s, self.fontName, self.fontSize) for s in t.split('\n')] M.append(m and max(m) or 0) return self.variColumn and [max(M[r:r+3]) for r in range(0,len(M),self.columnMaximum)] or max(M)
5,434
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
5,435
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
5,436
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
5,437
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
5,438
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
def bookmarkPage(self, key, fitType="Fit", left=None, top=None, bottom=None, right=None, zoom=None ): """ This creates a bookmark to the current page which can be referred to with the given key elsewhere.
5,439
def bookmarkHorizontalAbsolute(self, key, yhorizontal): """Bind a bookmark (destination) to the current page at a horizontal position. Note that the yhorizontal of the book mark is with respect to the default user space (where the origin is at the lower left corner of the page) and completely ignores any transform (translation, scale, skew, rotation, etcetera) in effect for the current graphics state. The programmer is responsible for making sure the bookmark matches an appropriate item on the page.""" #This method should probably be deprecated since it is just a sub-set of bookmarkPage return self.bookmarkPage(key,fitType="FitH",top=yhorizontal)
def bookmarkHorizontalAbsolute(self, key, yhorizontal): """Bind a bookmark (destination) to the current page at a horizontal position. Note that the yhorizontal of the book mark is with respect to the default user space (where the origin is at the lower left corner of the page) and completely ignores any transform (translation, scale, skew, rotation, etcetera) in effect for the current graphics state. The programmer is responsible for making sure the bookmark matches an appropriate item on the page.""" #This method should probably be deprecated since it is just a sub-set of bookmarkPage return self.bookmarkPage(key,fitType="FitH",top=yhorizontal)
5,440
def setPageRotation(self, rot): """Instruct display device that this page is to be rotated""" assert rot % 90.0 == 0.0, "Rotation must be a multiple of 90 degrees" self._pageRotation = rot
defsetPageRotation(self,rot):"""Instructdisplaydevicethatthispageistoberotated"""assertrot%90.0==0.0,"Rotationmustbeamultipleof90degrees"self._pageRotation=rot
5,441
def multiBuild(self, story, filename=None, canvasmaker=canvas.Canvas, maxPasses = 10): """Makes multiple passes until all indexing flowables are happy.""" self._indexingFlowables = [] #scan the story and keep a copy for thing in story: if thing.isIndexing(): self._indexingFlowables.append(thing) #print 'scanned story, found these indexing flowables:\n' #print self._indexingFlowables
def multiBuild(self, story, filename=None, canvasmaker=canvas.Canvas, maxPasses = 10): """Makes multiple passes until all indexing flowables are happy.""" self._indexingFlowables = [] #scan the story and keep a copy for thing in story: if thing.isIndexing(): self._indexingFlowables.append(thing) #print 'scanned story, found these indexing flowables:\n' #print self._indexingFlowables
5,442
def checkFileForTabs(self, filename): txt = open(filename, 'r').read() chunks = string.split(txt, '\t') tabCount = len(chunks) - 1 if tabCount: #raise Exception, "File %s contains %d tab characters!" % (filename, tabCount) print "file %s contains %d tab characters!" % (filename, tabCount)
def checkFileForTabs(self, filename): txt = open(filename, 'r').read() chunks = string.split(txt, '\t') tabCount = len(chunks) - 1 if tabCount: #raise Exception, "File %s contains %d tab characters!" % (filename, tabCount) print "file %s contains %d tab characters!" % (filename, tabCount)
5,443
def checkFileForTrailingSpaces(self, filename): txt = open(filename, 'r').read() initSize = len(txt) badLines = 0 badChars = 0 for line in string.split(txt, '\n'): stripped = string.rstrip(line) spaces = len(line) - len(stripped) # OK, so they might be trailing tabs, who cares? if spaces: badLines = badLines + 1 badChars = badChars + spaces
def checkFileForTrailingSpaces(self, filename): txt = open(filename, 'r').read() initSize = len(txt) badLines = 0 badChars = 0 for line in string.split(txt, '\n'): stripped = string.rstrip(line) spaces = len(line) - len(stripped) # OK, so they might be trailing tabs, who cares? if spaces: badLines = badLines + 1 badChars = badChars + spaces
5,444
def makeSuite(): return makeSuiteForClasses(SourceTester)
def makeSuite(): return makeSuiteForClasses(SourceTester)
5,445
def checkPageSize(self,canv,doc): '''This gets called by the template framework''' if canv._pagesize != self.pagesize: if self.pagesize: canv.setPageSize(self.pagesize) elif canv._pagesize != doc.pagesize: canv.setPageSize(doc.pagesize)
def checkPageSize(self,canv,doc): '''This gets called by the template framework''' cp = None dp = None sp = None if canv._pagesize: cp = map(int, canv._pagesize) if self.pagesize: sp = map(int, self.pagesize) if doc.pagesize: dp = map(int, doc.pagesize) if cp != dp: if sp: canv.setPageSize(self.pagesize) elif canv._pagesize != doc.pagesize: canv.setPageSize(doc.pagesize)
5,446
def checkPageSize(self,canv,doc): '''This gets called by the template framework''' if canv._pagesize != self.pagesize: if self.pagesize: canv.setPageSize(self.pagesize) elif canv._pagesize != doc.pagesize: canv.setPageSize(doc.pagesize)
def checkPageSize(self,canv,doc): '''This gets called by the template framework''' if canv._pagesize != self.pagesize: if self.pagesize: canv.setPageSize(self.pagesize) elif cp != dp: canv.setPageSize(doc.pagesize)
5,447
def isEqual(self, other): return ((enc.name == other.name) and (enc.vector == other.vector))
def isEqual(self, other): return ((enc.name == other.name) and (enc.vector == other.vector))
5,448
def _SWRecover(text, fontName, fontSize, encoding): '''This is called when _rl_accel's database doesn't know about a font. Currently encoding is always a dummy. ''' try: print 'Attempting to register', fontName font = getFont(fontName) registerFont(font) print 'registered font %s' % fontName dumpFontData() return _stringWidth(text,fontName,fontSize,encoding) except: warnOnce('Font %s:%s not found - using Courier:%s for widths'%(fontName,encoding,encoding)) return _stringWidth(text,'courier',fontSize,encoding)
def _SWRecover(text, fontName, fontSize, encoding): '''This is called when _rl_accel's database doesn't know about a font. Currently encoding is always a dummy. ''' try: font = getFont(fontName) registerFont(font) print 'registered font %s' % fontName dumpFontData() return _stringWidth(text,fontName,fontSize,encoding) except: warnOnce('Font %s:%s not found - using Courier:%s for widths'%(fontName,encoding,encoding)) return _stringWidth(text,'courier',fontSize,encoding)
5,449
def _SWRecover(text, fontName, fontSize, encoding): '''This is called when _rl_accel's database doesn't know about a font. Currently encoding is always a dummy. ''' try: print 'Attempting to register', fontName font = getFont(fontName) registerFont(font) print 'registered font %s' % fontName dumpFontData() return _stringWidth(text,fontName,fontSize,encoding) except: warnOnce('Font %s:%s not found - using Courier:%s for widths'%(fontName,encoding,encoding)) return _stringWidth(text,'courier',fontSize,encoding)
def _SWRecover(text, fontName, fontSize, encoding): '''This is called when _rl_accel's database doesn't know about a font. Currently encoding is always a dummy. ''' try: print 'Attempting to register', fontName font = getFont(fontName) registerFont(font) return _stringWidth(text,fontName,fontSize,encoding) except: warnOnce('Font %s:%s not found - using Courier:%s for widths'%(fontName,encoding,encoding)) return _stringWidth(text,'courier',fontSize,encoding)
5,450
def configure(self, dataSeries): """Let the axis configure its scale and range based on the data. Called after setPosition.Let it look at a list of lists of numbers determine the tick mark intervals. If valueMin, valueMax and valueStep are configured then it will use them; if any of them are set to Auto it will look at the data and make some sensible decision. You may override this to build custom axes with irregular intervals. It creates an internal variable self._values, which is a list of numbers to use in plotting."""
def configure(self, dataSeries): """Let the axis configure its scale and range based on the data. Called after setPosition.Let it look at a list of lists of numbers determine the tick mark intervals. If valueMin, valueMax and valueStep are configured then it will use them; if any of them are set to Auto it will look at the data and make some sensible decision. You may override this to build custom axes with irregular intervals. It creates an internal variable self._values, which is a list of numbers to use in plotting."""
5,451
def configure(self, dataSeries): """Let the axis configure its scale and range based on the data. Called after setPosition.Let it look at a list of lists of numbers determine the tick mark intervals. If valueMin, valueMax and valueStep are configured then it will use them; if any of them are set to Auto it will look at the data and make some sensible decision. You may override this to build custom axes with irregular intervals. It creates an internal variable self._values, which is a list of numbers to use in plotting."""
def configure(self, dataSeries): """Let the axis configure its scale and range based on the data. Called after setPosition.Let it look at a list of lists of numbers determine the tick mark intervals. If valueMin, valueMax and valueStep are configured then it will use them; if any of them are set to Auto it will look at the data and make some sensible decision. You may override this to build custom axes with irregular intervals. It creates an internal variable self._values, which is a list of numbers to use in plotting."""
5,452
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.background = background if self.caption: self.captionHeight = 0 # work out later self.captionStyle = ParagraphStyle( 'Caption', fontName=captionFont, fontSize=captionSize, leading=1.2*captionSize, spaceBefore=captionSize * 0.5, alignment=TA_CENTER) #must build paragraph now to get sequencing in synch with rest of story self.captionPara = Paragraph(self.caption, self.captionStyle)
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None, captionTextColor=toColor('black'), captionBackColor=None): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.background = background if self.caption: self.captionHeight = 0 # work out later self.captionStyle = ParagraphStyle( 'Caption', fontName=captionFont, fontSize=captionSize, leading=1.2*captionSize, spaceBefore=captionSize * 0.5, alignment=TA_CENTER) #must build paragraph now to get sequencing in synch with rest of story self.captionPara = Paragraph(self.caption, self.captionStyle)
5,453
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.background = background if self.caption: self.captionHeight = 0 # work out later self.captionStyle = ParagraphStyle( 'Caption', fontName=captionFont, fontSize=captionSize, leading=1.2*captionSize, spaceBefore=captionSize * 0.5, alignment=TA_CENTER) #must build paragraph now to get sequencing in synch with rest of story self.captionPara = Paragraph(self.caption, self.captionStyle)
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.background = background self.spaceBefore = 12 self.spaceAfter = 12 def _getCaptionPara(self): caption = self.caption captionFont = self.captionFont captionSize = self.captionSize captionTextColor = self.captionTextColor captionBackColor = self.captionBackColor if self._captionData!=(caption,captionFont,captionSize,captionTextColor,captionBackColor): self._captionData = (caption,captionFont,captionSize,captionTextColor,captionBackColor) # work out later self.captionStyle = ParagraphStyle( 'Caption', fontName=captionFont, fontSize=captionSize, leading=1.2*captionSize, spaceBefore=captionSize * 0.5, alignment=TA_CENTER) #must build paragraph now to get sequencing in synch with rest of story self.captionPara = Paragraph(self.caption, self.captionStyle)
5,454
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.background = background if self.caption: self.captionHeight = 0 # work out later self.captionStyle = ParagraphStyle( 'Caption', fontName=captionFont, fontSize=captionSize, leading=1.2*captionSize, spaceBefore=captionSize * 0.5, alignment=TA_CENTER) #must build paragraph now to get sequencing in synch with rest of story self.captionPara = Paragraph(self.caption, self.captionStyle)
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.background = background if self.caption: self.captionHeight = 0 # work out later self.captionStyle = ParagraphStyle( 'Caption', fontName=captionFont, fontSize=captionSize, leading=1.2*captionSize, spaceBefore=captionSize * 0.5, alignment=TA_CENTER) #must build paragraph now to get sequencing in synch with rest of story self.captionPara = Paragraph(self.caption, self.captionStyle)
5,455
def wrap(self, availWidth, availHeight): "Rescale to fit according to the rules, but only once" if self._scaleFactor is None or self.width>availWidth or self.height>availHeight: w, h = Figure.wrap(self, availWidth, availHeight) captionHeight = h - self.figureHeight if self.scaleFactor is None: #scale factor None means auto self._scaleFactor = min(availWidth/self.width,(availHeight-captionHeight)/self.figureHeight) else: #they provided a factor self._scaleFactor = self.scaleFactor if self._scaleFactor<1 and self.shrinkToFit: self.width = self.width * self._scaleFactor - 0.0001 self.figureHeight = self.figureHeight * self._scaleFactor elif self._scaleFactor>1 and self.growToFit: self.width = self.width*self._scaleFactor - 0.0001 self.figureHeight = self.figureHeight * self._scaleFactor return Figure.wrap(self, availWidth, availHeight)
def _scale(self,availWidth,availHeight): "Rescale to fit according to the rules, but only once" if self._scaleFactor is None or self.width>availWidth or self.height>availHeight: w, h = Figure.wrap(self, availWidth, availHeight) captionHeight = h - self.figureHeight if self.scaleFactor is None: #scale factor None means auto self._scaleFactor = min(availWidth/self.width,(availHeight-captionHeight)/self.figureHeight) else: #they provided a factor self._scaleFactor = self.scaleFactor if self._scaleFactor<1 and self.shrinkToFit: self.width = self.width * self._scaleFactor - 0.0001 self.figureHeight = self.figureHeight * self._scaleFactor elif self._scaleFactor>1 and self.growToFit: self.width = self.width*self._scaleFactor - 0.0001 self.figureHeight = self.figureHeight * self._scaleFactor return Figure.wrap(self, availWidth, availHeight)
5,456
def findFontName(path): "Extract a font name from an AFM file." f = open(path) found = 0 while not found: line = f.readline()[:-1] if not found and line[:16] == 'StartCharMetrics': raise FontNameNotFoundError, path if line[:8] == 'FontName': fontName = line[9:] found = 1 return fontName
def findFontName(path): "Extract a font name from an AFM file." f = open(path) found = 0 while not found: line = f.readline()[:-1] if not found and line[:16] == 'StartCharMetrics': raise FontNameNotFoundError, path if line[:8] == 'FontName': fontName = line[9:] found = 1 return fontName
5,457
def findFontName(path): "Extract a font name from an AFM file." f = open(path) found = 0 while not found: line = f.readline()[:-1] if not found and line[:16] == 'StartCharMetrics': raise FontNameNotFoundError, path if line[:8] == 'FontName': fontName = line[9:] found = 1 return fontName
def findFontName(path): "Extract a font name from an AFM file." f = open(path) found = 0 while not found: line = f.readline()[:-1] if not found and line[:16] == 'StartCharMetrics': raise FontNameNotFoundError, path if line[:8] == 'FontName': fontName = line[9:] found = 1 return fontName
5,458
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
5,459
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
5,460
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
5,461
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
5,462
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
5,463
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
5,464
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
5,465
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
5,466
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
5,467
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite."""
5,468
def calcBarPositions0(self): """Works out where they go.
def calcBarPositions(self): """Works out where they go.
5,469
def calcBarPositions0(self): """Works out where they go.
def calcBarPositions0(self): """Works out where they go.
5,470
def calcBarPositions0(self): """Works out where they go.
def calcBarPositions0(self): """Works out where they go.
5,471
def calcBarPositions0(self): """Works out where they go.
def calcBarPositions0(self): """Works out where they go.
5,472
def calcBarPositions(self): """Works out where they go.
def calcBarPositions(self): """Works out where they go.
5,473
def calcBarPositions(self): """Works out where they go.
def calcBarPositions(self): """Works out where they go.
5,474
def draw(self): self.valueAxis.configure(self.data) self.valueAxis.setPosition(self.x, self.y, self.height)
def draw(self): self.valueAxis.configure(self.data) self.valueAxis.setPosition(self.x, self.y, self.height)
5,475
def sample4d(): "Make a bar chart showing value axis region entirely *below* zero." drawing = Drawing(400, 200) data = [(-13, -20)] bc = VerticalBarChart() bc.x = 50 bc.y = 50 bc.height = 125 bc.width = 300 bc.data = data bc.strokeColor = colors.black bc.valueAxis.valueMin = -30 bc.valueAxis.valueMax = -10 bc.valueAxis.valueStep = 15 bc.categoryAxis.labels.boxAnchor = 'n' bc.categoryAxis.labels.dy = -5 bc.categoryAxis.categoryNames = ['Ying', 'Yang'] drawing.add(bc) return drawing
def sample4d(): "Make a bar chart showing value axis region entirely *below* zero." drawing = Drawing(400, 200) data = [(-13, -20)] bc = VerticalBarChart() bc.x = 50 bc.y = 50 bc.height = 125 bc.width = 300 bc.data = data bc.strokeColor = colors.black bc.valueAxis.valueMin = -30 bc.valueAxis.valueMax = -10 bc.valueAxis.valueStep = 15 bc.categoryAxis.labels.boxAnchor = 'n' bc.categoryAxis.labels.dy = -5 bc.categoryAxis.categoryNames = ['Ying', 'Yang'] drawing.add(bc) return drawing
5,476
def _flowableSublist(V): "if it isn't a list or tuple, wrap it in a list" if type(V) not in (ListType, TupleType): V = V is not None and [V] or [] from doctemplate import LCActionFlowable assert not filter(lambda x: isinstance(x,LCActionFlowable),V),'LCActionFlowables not allowed in sublists' return V
def _flowableSublist(V): "if it isn't a list or tuple, wrap it in a list" if type(V) not in (ListType, TupleType): V = V is not None and [V] or [] from doctemplate import LCActionFlowable assert not [x for x in V if isinstance(x,LCActionFlowable)],'LCActionFlowables not allowed in sublists' return V
5,477
def __init__(self, data, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1, emptyTableAction=None): #print "colWidths", colWidths self.hAlign = 'CENTER' self.vAlign = 'MIDDLE' if type(data) not in _SeqTypes: raise ValueError, "%s invalid data type" % self.identity() self._nrows = nrows = len(data) self._cellvalues = [] if nrows: self._ncols = ncols = max(map(_rowLen,data)) elif colWidths: ncols = len(colWidths) else: ncols = 0 if not emptyTableAction: emptyTableAction = rl_config.emptyTableAction if not (nrows and ncols): if emptyTableAction=='error': raise ValueError, "%s must have at least a row and column" % self.identity() elif emptyTableAction=='indicate': self.__class__ = Preformatted global _emptyTableStyle if '_emptyTableStyle' not in globals().keys(): _emptyTableStyle = ParagraphStyle('_emptyTableStyle') _emptyTableStyle.textColor = colors.red _emptyTableStyle.backColor = colors.yellow Preformatted.__init__(self,'%s(%d,%d)' % (self.__class__.__name__,nrows,ncols), _emptyTableStyle) elif emptyTableAction=='ignore': self.__class__ = Spacer Spacer.__init__(self,0,0) else: raise ValueError, '%s bad emptyTableAction: "%s"' % (self.identity(),emptyTableAction) return
def__init__(self,data,colWidths=None,rowHeights=None,style=None,repeatRows=0,repeatCols=0,splitByRow=1,emptyTableAction=None):#print"colWidths",colWidthsself.hAlign='CENTER'self.vAlign='MIDDLE'iftype(data)notin_SeqTypes:raiseValueError,"%sinvaliddatatype"%self.identity()self._nrows=nrows=len(data)self._cellvalues=[]ifnrows:self._ncols=ncols=max(map(_rowLen,data))elifcolWidths:ncols=len(colWidths)else:ncols=0ifnotemptyTableAction:emptyTableAction=rl_config.emptyTableActionifnot(nrowsandncols):ifemptyTableAction=='error':raiseValueError,"%smusthaveatleastarowandcolumn"%self.identity()elifemptyTableAction=='indicate':self.__class__=Preformattedglobal_emptyTableStyleif'_emptyTableStyle'notinglobals().keys():_emptyTableStyle=ParagraphStyle('_emptyTableStyle')_emptyTableStyle.textColor=colors.red_emptyTableStyle.backColor=colors.yellowPreformatted.__init__(self,'%s(%d,%d)'%(self.__class__.__name__,nrows,ncols),_emptyTableStyle)elifemptyTableAction=='ignore':self.__class__=SpacerSpacer.__init__(self,0,0)else:raiseValueError,'%sbademptyTableAction:"%s"'%(self.identity(),emptyTableAction)return
5,478
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth)if getattr(self,'_width_calculated_once',None): return #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
5,479
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
5,480
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
5,481
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
5,482
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
def_calc_width(self,availWidth,W=None):#commentsaddedbyAndytoRobin'sslightly#tersevariablenamesifnotW:W=_calc_pc(self._argW,availWidth)#widthsarray#print'widthsarray=%s'%str(self._colWidths)canv=getattr(self,'canv',None)saved=None
5,483
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
def_calc_width(self,availWidth,W=None):#commentsaddedbyAndytoRobin'sslightly#tersevariablenamesifnotW:W=_calc_pc(self._argW,availWidth)#widthsarray#print'widthsarray=%s'%str(self._colWidths)canv=getattr(self,'canv',None)saved=None
5,484
def _calc_width(self,availWidth,W=None): #comments added by Andy to Robin's slightly #terse variable names if not W: W = _calc_pc(self._argW,availWidth) #widths array #print 'widths array = %s' % str(self._colWidths) canv = getattr(self,'canv',None) saved = None
def_calc_width(self,availWidth,W=None):#commentsaddedbyAndytoRobin'sslightly#tersevariablenamesifnotW:W=_calc_pc(self._argW,availWidth)#widthsarray#print'widthsarray=%s'%str(self._colWidths)canv=getattr(self,'canv',None)saved=None
5,485
def _calc_height(self, availHeight, availWidth, H=None, W=None):
def _calc_height(self, availHeight, availWidth, H=None, W=None):
5,486
def _calc_height(self, availHeight, availWidth, H=None, W=None):
def _calc_height(self, availHeight, availWidth, H=None, W=None):
5,487
def _calc_height(self, availHeight, availWidth, H=None, W=None):
def_calc_height(self,availHeight,availWidth,H=None,W=None):
5,488
def _calc_height(self, availHeight, availWidth, H=None, W=None):
def_calc_height(self,availHeight,availWidth,H=None,W=None):
5,489
def _calc(self, availWidth, availHeight): #if hasattr(self,'_width'): return
def_calc(self,availWidth,availHeight):#ifhasattr(self,'_width'):return
5,490
def _calc(self, availWidth, availHeight): #if hasattr(self,'_width'): return
def _calc(self, availWidth, availHeight): #if hasattr(self,'_width'): return
5,491
def _calc(self, availWidth, availHeight): #if hasattr(self,'_width'): return
def _calc(self, availWidth, availHeight): #if hasattr(self,'_width'): return
5,492
def _calcSpanRanges(self): """Work out rects for tables which do row and column spanning.
def _calcSpanRanges(self): """Work out rects for tables which do row and column spanning.
5,493
def _calcSpanRanges(self): """Work out rects for tables which do row and column spanning.
def _calcSpanRanges(self): """Work out rects for tables which do row and column spanning.
5,494
def _calcSpanRects(self): """Work out rects for tables which do row and column spanning.
def_calcSpanRects(self):"""Workoutrectsfortableswhichdorowandcolumnspanning.
5,495
def stringWidth(self, text, fontName, fontSize, encoding=None): "gets width of a string in the given font and size" if encoding is not None: import logger logger.warnOnce('encoding argument to Canvas.stringWidth is deprecated and has no effect!') #if encoding is None: encoding = self._doc.encoding return pdfmetrics.stringWidth(text, fontName, fontSize)
def stringWidth(self, text, fontName, fontSize, encoding=None): "gets width of a string in the given font and size" if encoding is not None: from reportlab.lib import logger logger.warnOnce('encoding argument to Canvas.stringWidth is deprecated and has no effect!') #if encoding is None: encoding = self._doc.encoding return pdfmetrics.stringWidth(text, fontName, fontSize)
5,496
def handle_pageBegin(self): '''shouldn't normally be called directly''' self.page = self.page + 1 self.pageTemplate.drawPage(self.canv,self) self.pageTemplate.onPage(self.canv,self) if hasattr(self,'_nextFrameIndex'): del self._nextFrameIndex self.frame = self.pageTemplate.frames[0] self.handle_frameBegin()
def handle_pageBegin(self): '''Perform actions required at beginning of page. shouldn't normally be called directly''' self.page = self.page + 1 self.pageTemplate.drawPage(self.canv,self) self.pageTemplate.onPage(self.canv,self) if hasattr(self,'_nextFrameIndex'): del self._nextFrameIndex self.frame = self.pageTemplate.frames[0] self.handle_frameBegin()
5,497
def HexColor(val): """This class converts a hex string, or an actual integer number, into the corresponding color. E.g., in "AABBCC" or 0xAABBCC, AA is the red, BB is the green, and CC is the blue (00-FF). HTML uses a hex string with a preceding hash; if this is present, it is stripped off. (AR, 3-3-2000) """ if type(val) == types.StringType: if val[:1] == '#': val = val[1:] val = string.atoi(val,16) factor = 1.0 / 255 return Color(factor * ((val >> 16) & 0xFF), factor * ((val >> 8) & 0xFF), factor * (val & 0xFF))
def HexColor(val): """This class converts a hex string, or an actual integer number, into the corresponding color. E.g., in "AABBCC" or 0xAABBCC, AA is the red, BB is the green, and CC is the blue (00-FF). HTML uses a hex string with a preceding hash; if this is present, it is stripped off. (AR, 3-3-2000) """ if type(val) == types.StringType: if val[:1] == '#': val = val[1:] b = 16 elif string.lower(val[:2]) == '0x': b = 16 val = val[2:] val = string.atoi(val,b) factor = 1.0 / 255 return Color(factor * ((val >> 16) & 0xFF), factor * ((val >> 8) & 0xFF), factor * (val & 0xFF))
5,498
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency import colors namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): namedColors[name] = value return namedColors
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency import colors __namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): namedColors[name] = value return namedColors
5,499