rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
data = self.data m, M = None, None for row in data: for val in row: if val is None: val = 0 if val is None: val = 0 if val < m: m = val if val > M: M = val return m, M | data = map(lambda x: map(lambda x: x is not None and x or 0,x), self.data) return min(min(data)), max(max(data)) | def _findMinMaxValues(self): "Find the minimum and maximum value of the data we have." |
scale = self.valueAxis.scale vm, vM = self.valueAxis.valueMin, self.valueAxis.valueMax if None in (vm, vM): y = scale(self._findMinMaxValues()[0]) elif vm <= 0 <= vM: y = scale(0) elif 0 < vm: y = scale(vm) elif vM < 0: y = scale(vM) | def calcBarPositions(self): """Works out where they go. default vertical. | |
return string.join(map(lambda x : "%0x" % ord(x), md5.md5(s).digest()), '') | return string.join(map(lambda x : "%02x" % ord(x), md5.md5(s).digest()), '') | def _digester(s): return string.join(map(lambda x : "%0x" % ord(x), md5.md5(s).digest()), '') |
if d not in sys.path: sys.path.insert(0,d) | def find_test_files(L,d,N): n = os.path.basename(d) if n!='test' : return for n in filter(lambda n: n[-3:]=='.py',N): fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) | |
os.chdir(os.path.dirname(fn)) | def find_test_files(L,d,N): n = os.path.basename(d) if n!='test' : return for n in filter(lambda n: n[-3:]=='.py',N): fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) | |
z.run(execfile,(fn,_globals.copy())) | z.run(execfile,(fn,g)) | def find_test_files(L,d,N): n = os.path.basename(d) if n!='test' : return for n in filter(lambda n: n[-3:]=='.py',N): fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
execfile(fn,_globals.copy()) | execfile(fn,g) | def find_test_files(L,d,N): n = os.path.basename(d) if n!='test' : return for n in filter(lambda n: n[-3:]=='.py',N): fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
self._strokeColorRGB = rgb | self._fillColorRGB = rgb | def setFillColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if type(aColor) == ColorType: rgb = (aColor.red, aColor.green, aColor.blue) self._strokeColorRGB = rgb self._code.append('%0.2f %0.2f %0.2f rg' % rgb ) elif type(aColor) in _SeqTypes: l = len(aColor) if l==3: self._str... |
self._strokeColorRGB = aColor | self._fillColorRGB = aColor | def setFillColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if type(aColor) == ColorType: rgb = (aColor.red, aColor.green, aColor.blue) self._strokeColorRGB = rgb self._code.append('%0.2f %0.2f %0.2f rg' % rgb ) elif type(aColor) in _SeqTypes: l = len(aColor) if l==3: self._str... |
R = String(upperleftx, upperlefty, text) R.textAnchor = anchor if self.color is not None: R.fillColor = self.color elif self.defaultColor is not None: R.fillColor = self.defaultColor if self.size is not None: R.fontSize = self.size if self.font is not None: R.fontName = self.font return [R] | textlist = string.split(text, "\n") result = [] for text1 in textlist: R = String(upperleftx, upperlefty, text1) upperlefty = upperlefty-self.size*1.1 R.textAnchor = anchor if self.color is not None: R.fillColor = self.color elif self.defaultColor is not None: R.fillColor = self.defaultColor if self.size is not None: R... | def materialize(self, text, length, xyorigin=(0,0), lengthoffset=0, widthoffset=0): "generate a drawables based on this template, with help of 'derived' parameters" # for purposes of generality return a *sequence* of drawables (x,y) = xyorigin orientation = self.orientation # semantics is flipped compared to bar groups... |
print "factor is", factor | def draw(self): orientation = self.orientation # this could be done cleverly using the other widgets, but what the .... x,y = self.x, self.y fmt = self.labelFormat (delta, startpoint) = scaleParameters(self.minimum, self.maximum, self.nLabels) G = Group() # orientation independent data (direct values for vertical case,... | |
print "lineposition, clineposition", lineposition, clineposition | def draw(self): orientation = self.orientation # this could be done cleverly using the other widgets, but what the .... x,y = self.x, self.y fmt = self.labelFormat (delta, startpoint) = scaleParameters(self.minimum, self.maximum, self.nLabels) G = Group() # orientation independent data (direct values for vertical case,... | |
print "done with lines" | def draw(self): orientation = self.orientation # this could be done cleverly using the other widgets, but what the .... x,y = self.x, self.y fmt = self.labelFormat (delta, startpoint) = scaleParameters(self.minimum, self.maximum, self.nLabels) G = Group() # orientation independent data (direct values for vertical case,... | |
def draw(self): self.valueAxis.configure(self.data) self.valueAxis.setPosition(self.x, self.y, self.height) xAxisCrossesAt = self.valueAxis.scale(0) if ((xAxisCrossesAt > self.y + self.height) or (xAxisCrossesAt < self.y)): self.categoryAxis.setPosition(self.x, self.y, self.width) else: self.categoryAxis.setPosition... | def makeBackground(self): | def draw(self): self.valueAxis.configure(self.data) self.valueAxis.setPosition(self.x, self.y, self.height) |
g.add(self.categoryAxis) g.add(self.valueAxis) | return g def makeBars(self): g = Group() | 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.width) yAxisCrossesAt = self.valueAxis.scale(0) if ((yAxisCrossesAt > self.x + self.width) or (yAxisCrossesAt < self.x)): self.categoryAxis.setPosition(self.x, self.y, self.height) else: self.categoryAxis.setPosition(... | def makeBackground(self): | def draw(self): self.valueAxis.configure(self.data) self.valueAxis.setPosition(self.x, self.y, self.width) |
g.add(self.categoryAxis) g.add(self.valueAxis) | return g def makeBars(self): g = Group() | def draw(self): self.valueAxis.configure(self.data) self.valueAxis.setPosition(self.x, self.y, self.width) |
rectList2 = [] for elem in rectList: if elem == (0,0,0,0): print 'got an empty one' if elem is not None: rectList2.append(elem) xMin, yMin, xMax, yMax = rectList2[0] for (x1, y1, x2, y2) in rectList2[1:]: | L = filter(lambda x: x is not None, rectList) if not L: return None xMin, yMin, xMax, yMax = L[0] for (x1, y1, x2, y2) in L[1:]: | def getRectsBounds(rectList): # filter out any None objects, e.g. empty groups rectList2 = [] for elem in rectList: if elem == (0,0,0,0): print 'got an empty one' if elem is not None: rectList2.append(elem) xMin, yMin, xMax, yMax = rectList2[0] for (x1, y1, x2, y2) in rectList2[1:]: if x1 < xMin: xMin = x1 if x2 > xMa... |
(x1, y1, x2, y2) = getRectsBounds(b) | x1 = getRectsBounds(b) if x1 is None: return None x1, y1, x2, y2 = x1 | def getBounds(self): if self.contents: b = [] for elem in self.contents: b.append(elem.getBounds()) (x1, y1, x2, y2) = getRectsBounds(b) trans = self.transform corners = [[x1,y1], [x1, y2], [x2, y1], [x2,y2]] newCorners = [] for corner in corners: newCorners.append(transformPoint(trans, corner)) return getPointsBounds(... |
WedgeLabel3d._ydepth_3d = self._ydepth_3d | checkLabelOverlap = self.checkLabelOverlap | def _checkDXY(self,ba): if ba[0]=='n': if not hasattr(self,'_ody'): self._ody = self.dy self.dy = -self._ody + self._ydepth_3d |
_addWedgeLabel(self,text,L.append,mid,OX(i,mid,0),OY(i,mid,0),style,labelClass=WedgeLabel3d) | labelX = OX(i,mid,0) labelY = OY(i,mid,0) _addWedgeLabel(self,text,L.append,mid,labelX,labelY,style,labelClass=WedgeLabel3d) if checkLabelOverlap: l = L[-1] l._origdata = { 'x': labelX, 'y':labelY, 'angle': mid, 'rx': self._radiusx, 'ry':self._radiusy, 'cx':CX(i,0), 'cy':CY(i,0), 'bounds': l.getBounds(), } | def _checkDXY(self,ba): if ba[0]=='n': if not hasattr(self,'_ody'): self._ody = self.dy self.dy = -self._ody + self._ydepth_3d |
rlDir = os.path.dirname(reportlab.__file__) ppDir = os.path.join(rlDir, 'tools','pythonpoint') m1 = recursiveImport('stdparser', baseDir=ppDir) | D = os.path.join(os.path.dirname(reportlab.__file__), 'tools','pythonpoint') fn = os.path.join(D,'stdparser.py') if os.path.isfile(fn) or os.path.isfile(fn+'c') or os.path.isfile(fn+'o'): m1 = recursiveImport('stdparser', baseDir=D) | def test2(self): "try under a directory NOT on the path" rlDir = os.path.dirname(reportlab.__file__) ppDir = os.path.join(rlDir, 'tools','pythonpoint') m1 = recursiveImport('stdparser', baseDir=ppDir) |
def open_for_read(name,mode='b'): | def open_for_read_by_name(name,mode='b'): if 'r' not in mode: mode = 'r'+mode try: return open(name,mode) except IOError: t, v = sys.exc_info()[:2] if _isFSD or __loader__ is None: raise try: name = _startswith_rl(name) s = __loader__.get_data(name) if 'b' not in mode and os.linesep!='\n': s = s.replace(os.linesep,'\... | def open_for_read(name,mode='b'): '''attempt to open a file or URL for reading''' if hasattr(name,'read'): return name import urllib try: t, o = urllib.splittype(name) if not t or t=='file': raise ValueError o = urllib.urlopen(name) return getStringIO(o.read()) except: if 'r' not in mode: mode = 'r'+mode try: return op... |
import urllib try: t, o = urllib.splittype(name) if not t or t=='file': raise ValueError o = urllib.urlopen(name) return getStringIO(o.read()) | try: P = urlparse(name) if not P[0] or P[0]=='file': raise ValueError return getStringIO(urlopen(name).read()) | def open_for_read(name,mode='b'): '''attempt to open a file or URL for reading''' if hasattr(name,'read'): return name import urllib try: t, o = urllib.splittype(name) if not t or t=='file': raise ValueError o = urllib.urlopen(name) return getStringIO(o.read()) except: if 'r' not in mode: mode = 'r'+mode try: return op... |
if 'r' not in mode: mode = 'r'+mode try: return open(name,mode) except IOError: t, v = sys.exc_info()[:2] if _isFSD or __loader__ is None: raise try: name = _startswith_rl(name) s = __loader__.get_data(name) if 'b' not in mode and os.linesep!='\n': s = s.replace(os.linesep,'\n') return getStringIO(s) except: raise t,... | return open_for_read_by_name(P[2],mode) del urllib, urlparse | def open_for_read(name,mode='b'): '''attempt to open a file or URL for reading''' if hasattr(name,'read'): return name import urllib try: t, o = urllib.splittype(name) if not t or t=='file': raise ValueError o = urllib.urlopen(name) return getStringIO(o.read()) except: if 'r' not in mode: mode = 'r'+mode try: return op... |
s = sin(30*_toradians)*r | s = sin(c)*r | def _StarSix(self): r = float(self.size)/2 c = 30*_toradians s = sin(30*_toradians)*r c = cos(c)*r z = s/2 g = c/2 return self._doPolygon((0,r,-z,s,-c,s,-s,0,-c,-s,-z,-s,0,-r,z,-s,c,-s,s,0,c,s,z,s)) |
if self.angle: m.rotate(angle) | if self.angle: m.rotate(self.angle) | def draw(self): if self.kind: m = getattr(self,'_'+self.kind) if self.angle: _x, _dx, _y, _dy = self.x, self.dx, self.y, self.dy self.x, self.dx, self.y, self.dy = 0,0,0,0 try: m = m() finally: self.x, self.dx, self.y, self.dy = _x, _dx, _y, _dy if not isinstance(m,Group): _m, m = m, Group() m.add(_m) if self.angle: m.... |
canvas.setFont('Times-Bold',16) canvas.drawString(108, layout.PAGE_HEIGHT-108, Title) canvas.setFont('Times-Roman',9) | def myFirstPage(canvas, doc): canvas.saveState() canvas.setFont('Times-Bold',16) canvas.drawString(108, layout.PAGE_HEIGHT-108, Title) canvas.setFont('Times-Roman',9) canvas.restoreState() | |
ChapterStyle.fontsize = 14 | ChapterStyle.fontsize = 16 InitialStyle = copy.deepcopy(ChapterStyle) InitialStyle.fontsize = 16 PreStyle = styles["Code"] | def go(): doc = layout.SimpleFlowDocument('fodyssey.pdf',layout.DEFAULT_PAGE_SIZE,showBoundary=0) doc.onFirstPage = myFirstPage doc.onNewPage = myLaterPages doc.build(Elements) |
Elements.append(layout.Spacer(0.2*inch, 0.1*inch)) | spacer(0.1) | def p(txt, style=ParaStyle): Elements.append(layout.Spacer(0.2*inch, 0.1*inch)) Elements.append(Paragraph(txt, style)) |
PreStyle = styles["Code"] InitialStyle = copy.copy(PreStyle) InitialStyle.alignment = TA_CENTER InitialStyle.fontsize = 14 | def p(txt, style=ParaStyle): Elements.append(layout.Spacer(0.2*inch, 0.1*inch)) Elements.append(Paragraph(txt, style)) | |
s = layout.Spacer(0.1*inch, 0.1*inch) Elements.append(s) p = layout.Preformatted(txt, PreStyle) | spacer(0.1) p = layout.Preformatted(txt, style) | def pre(txt, style=PreStyle): s = layout.Spacer(0.1*inch, 0.1*inch) Elements.append(s) p = layout.Preformatted(txt, PreStyle) Elements.append(p) |
E.append([layout.Preformatted,'The Odyssey\n\nHomer\n', InitialStyle]) | E.append([spacer,2]) E.append([fTitle,'<font color=red>%s</font>' % Title, InitialStyle]) E.append([fTitle,'<font size=-4>by</font> <font color=green>%s</font>' % Author, InitialStyle]) | def findNext(L, i): while 1: if string.strip(L[i])=='': del L[i] kind = 1 if i<len(L): while string.strip(L[i])=='': del L[i] |
self.x = self.y = self.angle = 0 | self.x = self.y = self.angle = self.skewY = self._dx = 0 self.skewX = 10 self._dy = 35.5 self.showPage = 1 | def __init__(self): self.fillColor = white self.strokeColor = None self.strokeWidth = 0.1 self.background = ReportLabBlue self.shadow = 0.5 self.height = 86 self.width = 129 self.x = self.y = self.angle = 0 |
g.add(definePath([ ('moveTo' ,15.7246,0 ), ('lineTo' ,9.49521,0 ), ('lineTo' ,6.64988,6.83711 ), ('curveTo' ,6.62224,6.95315 ,6.57391,7.10646 ,6.50485,7.29708 ), ('curveTo' ,6.43578,7.48767 ,6.35059,7.71559 ,6.24931,7.98079 ), ('lineTo' ,6.29074,6.71282 ), ('lineTo' ,6.29074,0 ), ('lineTo' ,0.55862,0 ), ('lineTo' ,0.55... | P = [ ('moveTo' ,15.7246,0 ), ('lineTo' ,9.49521,0 ), ('lineTo' ,6.64988,6.83711 ), ('curveTo' ,6.62224,6.95315 ,6.57391,7.10646 ,6.50485,7.29708 ), ('curveTo' ,6.43578,7.48767 ,6.35059,7.71559 ,6.24931,7.98079 ), ('lineTo' ,6.29074,6.71282 ), ('lineTo' ,6.29074,0 ), ('lineTo' ,0.55862,0 ), ('lineTo' ,0.55862,19.19365 ... | def _paintLogo(self, g, dx=0, dy=0, strokeColor=None, strokeWidth=0.1, fillColor=white): g.add(definePath([ ('moveTo' ,15.7246,0 ), ('lineTo' ,9.49521,0 ), ('lineTo' ,6.64988,6.83711 ), ('curveTo' ,6.62224,6.95315 ,6.57391,7.10646 ,6.50485,7.29708 ), ('curveTo' ,6.43578,7.48767 ,6.35059,7.71559 ,6.24931,7.98079 ), ('li... |
], strokeColor=strokeColor,strokeWidth=strokeWidth,fillColor=fillColor, dx=dx, dy=dy)) | ] or []) g.add(definePath(P,strokeColor=strokeColor,strokeWidth=strokeWidth,fillColor=fillColor, dx=dx, dy=dy)) | def _paintLogo(self, g, dx=0, dy=0, strokeColor=None, strokeWidth=0.1, fillColor=white): g.add(definePath([ ('moveTo' ,15.7246,0 ), ('lineTo' ,9.49521,0 ), ('lineTo' ,6.64988,6.83711 ), ('curveTo' ,6.62224,6.95315 ,6.57391,7.10646 ,6.50485,7.29708 ), ('curveTo' ,6.43578,7.48767 ,6.35059,7.71559 ,6.24931,7.98079 ), ('li... |
self._paintLogo(g,fillColor=fillColor) g.skew(kx=10, ky=0) g.shift(0,35.5) | self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx,self._dy) | def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background shadow = self.shadow if bg: shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow) self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow) self._paintLogo(g,fillColor=fillColor) g.skew(kx=10, ky=0) g.shift(0,35.5)... |
G.shift(self.x,self.y) | G.shift(x,y) | def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background shadow = self.shadow if bg: shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow) self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow) self._paintLogo(g,fillColor=fillColor) g.skew(kx=10, ky=0) g.shift(0,35.5)... |
n = len(vals)-1 | n = len(vals) | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFil... |
y = rowpos + cellstyle.bottomPadding+n*leading | y = rowpos + cellstyle.bottomPadding+n*leading-fontsize | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFil... |
y = rowpos + rowheight - cellstyle.topPadding - cellstyle.fontsize | y = rowpos + rowheight - cellstyle.topPadding - fontsize | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFil... |
y = rowpos + (cellstyle.bottomPadding + rowheight - cellstyle.topPadding+n*leading)/2.0 | y = rowpos + (cellstyle.bottomPadding + rowheight-cellstyle.topPadding+(n-1)*leading)/2.0+leading-fontsize | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFil... |
'GRID', 'BOX', 'OUTLINE', 'INNERGRID', 'LINEBELOW', 'LINEABOVE', 'LINEBEFORE', 'LINEAFTER', ) | 'GRID', 'BOX', 'OUTLINE', 'INNERGRID', 'BOXGRID', 'LINEBELOW', 'LINEABOVE', 'LINEBEFORE', 'LINEAFTER', ) | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFil... |
new.fontsize = values[1] | if n>1: new.fontsize = values[1] if n>2: new.leading = values[2] elif op in ('FONTNAME', 'FACE'): new.fontname = values[0] elif op in ('SIZE', 'FONTSIZE'): new.fontsize = values[0] elif op == 'LEADING': new.leading = values[0] | def _setCellStyle(cellStyles, i, j, op, values): new = CellStyle('<%d, %d>' % (i,j), cellStyles[i][j]) cellStyles[i][j] = new if op == 'FONT': new.fontname = values[0] new.fontsize = values[1] elif op == 'TEXTCOLOR': new.color = colors.toColor(values[0], colors.Color(0,0,0)) elif op in ('ALIGN', 'ALIGNMENT'): new.align... |
data= [['X00y', 'X01y', 'X02y', 'X03y', 'X04y'], | XY = [['X00y', 'X01y', 'X02y', 'X03y', 'X04y'], | def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2,... |
t=Table(data, 5*[0.4*inch], 4*[0.4*inch]) | t=Table(XY, 5*[0.6*inch], 4*[0.6*inch]) | def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2,... |
exec l | exec l.strip() | def get_version(): #determine Version if __name__=='__main__': HERE=os.path.dirname(sys.argv[0]) else: HERE=os.path.dirname(__file__) #first try source FN = pjoin(HERE,'__init__') try: for l in open(pjoin(FN+'.py'),'r').readlines(): if l.startswith('Version'): exec l return Version except: pass #don't have source, tr... |
if path=='None': path = [] if (isinstance (path, str)): path = [path] | if path=='None': path = [] if type(path) not in SeqTypes: path = [path] | def start_stylesheet(self, args): #makes it the current style sheet. path = self._arg('stylesheet',args,'path') if path=='None': path = [] if (isinstance (path, str)): path = [path] path.append('styles') path.append(os.getcwd()) modulename = self._arg('stylesheet', args, 'module') funcname = self._arg('stylesheet', arg... |
platypus.Image('file://'+gif.replace('\\','/'))]) | platypus.Image(furl)]) | def wrap(self, availWidth, availHeight): """This will be called by the enclosing frame before objects are asked their size, drawn or whatever. It returns the size actually used.""" return (self.width, self.height) |
if sys.platform=='win32': S = ['c:\\Program Files\\Adobe\\Acrobat 4.0\\Resource\\Font'] elif sys.platform in ('linux2','freebsd4',): S = ['/usr/lib/Acrobat4/Resource/Font'] elif sys.platform=='mac': diskName = string.split(os.getcwd(), ':')[0] fontDir = diskName + ':Applications:Python %s:reportlab:fonts' % sys_version... | import reportlab D = {'REPORTLAB_DIR': os.path.dirname(reportlab.__file__), 'disk': string.split(os.getcwd(), ':')[0], 'sys_version': sys_version, } | 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 |
for p in S: if os.path.isdir(p): P.append(p) | for p in T1SearchPath: d = apply(os.path.join,string.split(p % D,'/')) if os.path.isdir(d): P.append(d) | 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 |
if type(cap) is not type(int): | if not isinstance(cap,int): | def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','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 com... |
ValueError('Bad cap value %s in %s'%(cap,str(cmd))) | raise ValueError('Bad cap value %s in %s'%(cap,str(cmd))) | def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','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 com... |
if len(cmd)<7: cmd = cmd+(None,) | if len(cmd)<7: cmd += (None,) | def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','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 com... |
if type(join) is not type(int): | if not isinstance(join,int): | def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','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 com... |
cmd = cmd + (lineCount,) | cmd += (lineCount,) | def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','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 com... |
if maxx>400 or maxyy>200: _,_,D = drawit(F,maxx,maxy) | if maxx>400 or maxy>200: _,_,D = drawit(F,maxx,maxy) | def drawit(F,w=400,h=200,fontSize=12,slack=2,gap=5): D = Drawing(w,h) th = 2*gap + fontSize*1.2 gh = gap + .2*fontSize y = h maxx = 0 for fontName in F: y -= th text = fontName+": I should be totally horizontal and enclosed in a box" textWidth = stringWidth(text, fontName, fontSize) maxx = max(maxx,textWidth+20) D.add(... |
do_exec(cvs+(' rtag %s' % release), 'the tag phase') | def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) if release: print release os.environ['CVSROOT']=':ext:%s@cvs1:/cvsroot/reportlab' % USER #do_exec(cvs+(' rtag %s' % release), 'the tag phase') do_exec(cvs+(' co -r %s r... | |
self._x = x self._y = y self._x0 = x | self._x0 = self._x = x self._y0 = self._y = y | def setTextOrigin(self, x, y): if self._canvas.bottomup: self._code.append('1 0 0 1 %s Tm' % fp_str(x, y)) #bottom up else: self._code.append('1 0 0 -1 %s Tm' % fp_str(x, y)) #top down self._x = x self._y = y self._x0 = x #the margin |
self._x = e self._y = f | self._x0 = self._x = e self._y0 = self._y = f | def setTextTransform(self, a, b, c, d, e, f): "Like setTextOrigin, but does rotation, scaling etc." if not self._canvas.bottomup: c = -c #reverse bottom row of the 2D Transform d = -d self._code.append('%s Tm' % fp_str(a, b, c, d, e, f)) #we only measure coords relative to present text matrix self._x = e self._y = f |
dx = dx + float(L[-3]) dy = dy - float(L[-2]) | lastDx = float(L[-3]) lastDy = float(L[-2]) dx += lastDx dy -= lastDy self._x0 -= lastDx self._y0 -= lastDy | 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.jo... |
"""Moves to a point dx away from the start of the | """Starts a new line dx away from the start of the | 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.""" self.moveCursor(dx,0) |
self._code.append('%s T*' % self._formatText(line)) if self._canvas.bottomup: self._y = self._y - self._leading else: self._y = self._y + self._leading self._x = self._x0 | self.textLine(line) | def textLines(self, stuff, trim=1): """prints multi-line or newlined strings, moving down. One comon use is to quote a multi-line block in your Python code; since this may be indented, by default it trims whitespace off each line and from the beginning; set trim=0 to preserve whitespace.""" if type(stuff) == StringTyp... |
if sys.platform in ('linux2',) and ext='.pfb': ext = '' | if sys.platform in ('linux2',) and ext=='.pfb': ext = '' | 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 |
theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, iradius=iradius) | theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) | def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(nor... |
if I and inname not in I: continue | if I and zipname not in I: continue | def buildup_test(cls=test_pyRXPU,I=[]): ''' Add test methods to the TestCase ''' cls.valid = [] cls.invalid = [] cls.notwf = [] testdir = os.path.dirname(__file__) try: zipf = zipfile.ZipFile(os.path.join(testdir,'xmltest.zip')) except: print >> sys.stderr, "Can't locate file xmltest.zip\nPerhaps it should be downloade... |
if type(f)==type(''): | if type(filename)==type(''): | def SaveToFile(self, filename,canvas): """Open a file, and ask each object in turn to write itself to the file. Keep track of the file position at each point for use in the index at the end""" |
if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): | idToObject = self.idToObject if name is None and ( (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference)): | def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is Insta... |
idToObject = self.idToObject | def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is Insta... | |
raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name | other = idToObject[name] if other!=object: raise ValueError, "redefining named object: "+repr(name) return PDFObjectReference(name) if tob is InstanceType: object.__InternalName__ = name | def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is Insta... |
self._cellvalues = data | 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 = nro... | |
nr = self._nrows if not hasattr(self,'_ncols'): nc = 'unknown' else: nc = self._ncols cv = self._cellvalues | nr = getattr(self,'_nrows','unknown') nc = getattr(self,'_ncols','unknown') cv = self._cellvalues if cv and 'unknown' not in (nr,nc): | def identity(self, maxLen=30): '''Identify our selves as well as possible''' vx = None nr = self._nrows if not hasattr(self,'_ncols'): nc = 'unknown' else: nc = self._ncols cv = self._cellvalues b = 0 for i in xrange(nr): for j in xrange(nc): v = cv[i][j] t = type(v) if t in _SeqTypes or isinstance(v,Flowable): if not ... |
like the default verifiction strategy, or the way | like the default verification strategy, or the way | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
existence depends on other propereties' values :-)""") | existence depends on other properties' values :-)""") | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
people will experimate with push-down, pull-down and pattern-matching | people will experiment with push-down, pull-down and pattern-matching | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
This chapter presents a treament of the ideas behind our charting | This chapter presents a treatment of the ideas behind our charting | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
revious section; these are all optional and are there to let the end user configire the appearance. Things which must be set for a chart to | previous section; these are all optional and are there to let the end user configure the appearance. Things which must be set for a chart to | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
its positon relative to this origin and all of its formatting.""") | its position relative to this origin and all of its formatting.""") | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
rectangle' because it makes it vey easy to lay out multiple charts | rectangle' because it makes it very easy to lay out multiple charts | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
they are relative quantities and indicate the proprotional | they are relative quantities and indicate the proportional | def checkMood(moodName): return (moodName in ('happy','sad','ok')) |
if H<=maxHeight: self.width = W self.height = H | if H<=maxHeight+_FUZZ: self.width = W-_FUZZ self.height = H-_FUZZ | def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H |
self.width = W self.height = H | self.width = W-_FUZZ self.height = H-_FUZZ | def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H |
if H<min(0.95*maxHeight,maxHeight-10): | if H<min(0.95*maxHeight,maxHeight-10) or H>=maxHeight+_FUZZ: | def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H |
if H<=maxHeight-_FUZZ: self.width = W self.height = H | if H<=maxHeight+_FUZZ and W<=maxWidth+_FUZZ: self.width = W-_FUZZ self.height = H-_FUZZ | def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H |
for x in xrange(self.x + self.delta0, self.x + self.width, self.delta): line = Line(x, self.y, x, self.y + self.height) | for x in frange(self.x + self.delta0, self.x + w, self.delta): line = Line(x, self.y, x, self.y + h) | def makeInnerLines(self): # inner grid lines group = Group() if self.useLines == 1: if self.orientation == 'vertical': for x in xrange(self.x + self.delta0, self.x + self.width, self.delta): line = Line(x, self.y, x, self.y + self.height) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.ad... |
elif self.orientation == 'horizontal': for y in xrange(self.y + self.delta0, self.y + self.height, self.delta): line = Line(self.x, y, self.x + self.width, y) | if self.delta0 != 0: line = Line(self.x, self.y, self.x, self.y + h) | def makeInnerLines(self): # inner grid lines group = Group() if self.useLines == 1: if self.orientation == 'vertical': for x in xrange(self.x + self.delta0, self.x + self.width, self.delta): line = Line(x, self.y, x, self.y + self.height) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.ad... |
r = range(self.x + self.delta0, self.x + self.width, self.delta) for j in xrange(len(r)): | r = frange(self.x + self.delta0, self.x + w, self.delta) for j in frange(len(r)): | def makeInnerTiles(self): # inner grid lines group = Group() |
stripe = Rect(x, self.y, r[j+1]-x, self.height) | stripe = Rect(x, self.y, r[j+1]-x, h) | def makeInnerTiles(self): # inner grid lines group = Group() |
stripe = Rect(x, self.y, self.delta, self.height) | stripe = Rect(x, self.y, self.delta, h) | def makeInnerTiles(self): # inner grid lines group = Group() |
lmStripe = Rect(self.x, self.y, self.delta0, self.height) | lmStripe = Rect(self.x, self.y, self.delta0, h) | def makeInnerTiles(self): # inner grid lines group = Group() |
rmStripe = Rect(self.x + self.width - self.delta0, self.y, self.delta0, self.height) | rmStripe = Rect(self.x + w - self.delta0, self.y, self.delta0, h) | def makeInnerTiles(self): # inner grid lines group = Group() |
r = range(self.y + self.delta0, self.y + self.height, self.delta) for j in xrange(len(r)): | r = frange(self.y + self.delta0, self.y + h, self.delta) for j in frange(len(r)): | def makeInnerTiles(self): # inner grid lines group = Group() |
stripe = Rect(self.x, y, self.width, r[j+1]-y) | stripe = Rect(self.x, y, w, r[j+1]-y) | def makeInnerTiles(self): # inner grid lines group = Group() |
stripe = Rect(self.x, y, self.width, self.delta) | stripe = Rect(self.x, y, w, self.delta) | def makeInnerTiles(self): # inner grid lines group = Group() |
lmStripe = Rect(self.x, self.y, self.width, self.delta0) | lmStripe = Rect(self.x, self.y, w, self.delta0) | def makeInnerTiles(self): # inner grid lines group = Group() |
umStripe = Rect(self.x, self.y + self.width - self.delta0, self.width, self.delta0) | umStripe = Rect(self.x, self.y + w - self.delta0, w, self.delta0) | def makeInnerTiles(self): # inner grid lines group = Group() |
self.numShades = 20.0 | self.numShades = 20 | def __init__(self): self.x = 0 self.y = 0 self.width = 100 self.height = 100 self.orientation = 'vertical' self.numShades = 20.0 self.fillColorStart = colors.pink self.fillColorEnd = colors.black self.strokeColor = colors.black self.strokeWidth = 2 |
rect = Rect(self.x, self.y, self.width, self.height) | w, h = self.width, self.height rect = Rect(self.x, self.y, w, h) | def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect) |
num = self.numShades | num = float(self.numShades) | def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect) |
for x in xrange(self.x, self.x + self.width, self.width/num): line = Rect(x, self.y, self.width/num, self.height) | if num == 1: xVals = [self.x] else: xVals = frange(self.x, self.x + w, w/num) for x in xVals: stripe = Rect(x, self.y, w/num, h) | def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.