rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
self.seek(string_data_offset + offset) if length % 2 != 0: raise TTFError, "PostScript name is UTF-16BE string of odd length" length /= 2 N = [] A = N.append while length > 0: char = self.read_ushort() A(chr(char)) length -= 1 N = ''.join(N) | opos = self._pos try: self.seek(string_data_offset + offset) if length % 2 != 0: raise TTFError, "PostScript name is UTF-16BE string of odd length" length /= 2 N = [] A = N.append while length > 0: char = self.read_ushort() A(chr(char)) length -= 1 N = ''.join(N) finally: self._pos = opos | def extractInfo(self, charInfo=1): """Extract typographic information from the loaded font file. |
os.path.walk('.',find_cleanable_files,test_files) | os.path.walk('.',find_cleanable_files,None) | def find_cleanable_files(L,d,N): n = os.path.basename(d) for n in filter(lambda n: n[-3:]=='.PYC' or n[-4:]=='.PDF' or n[-4:]=='.A85',map(string.upper,N)): fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): os.remove(fn) |
bt = None if self._curPara.style == 'Bullet' and bt == '': bt = '\267' | if self._curPara.style == 'Bullet': bt = '\267' else: bt = None | def start_para(self, args): self._curPara = pythonpoint.PPPara() self._curPara.style = self._arg('para',args,'style') |
if valign != 'TOP' or just != 'LEFT': | if valign != 'BOTTOM' or just != 'LEFT': | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
y = rowpos + rowheight - cellstyle.topPadding | y = rowpos + rowheight - cellstyle.topPadding+h | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
y = rowpos+cellstyle.bottomPadding+h | y = rowpos+cellstyle.bottomPadding | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
y = rowpos+(rowheight+cellstyle.bottomPadding-cellstyle.topPadding+h)/2.0 | y = rowpos+(rowheight+cellstyle.bottomPadding-cellstyle.topPadding-h)/2.0 | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
apply(im.save,(fn,fmt),self.configPIL or {}) | configPIL = self.configPIL or {} if fmt=='TIFF': for a,d in ('resolution',self._dpi),('resolution unit','inch'): configPIL[a] = configPIL.get(a,d) apply(im.save,(fn,fmt),configPIL) | def saveToFile(self,fn,fmt=None): im = self.toPIL() if fmt is None: if type(fn) is not StringType: raise ValueError, "Invalid type '%s' for fn when fmt is None" % type(fn) else: fmt = string.upper(fmt) if fmt in ['GIF']: im = _convert2pilp(im) elif fmt in ['PCT','PICT']: return _saveAsPICT(im,fn,fmt) elif fmt in ['PNG','TIFF','BMP', 'PPM', 'TIF']: if fmt=='TIF': fmt = 'TIFF' if fmt=='PNG': try: from PIL import PngImagePlugin except ImportError: import PngImagePlugin elif fmt in ('JPG','JPEG'): fmt = 'JPEG' else: raise RenderPMError,"Unknown image kind %s" % fmt apply(im.save,(fn,fmt),self.configPIL or {}) if not hasattr(fn,'write'): from reportlab.lib.utils import markfilename markfilename(fn,creatorcode='ogle',filetype='PICT') |
assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','tiff','tif','py'], 'Unknown file format "%s"' % format | assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','bmp','ppm','tiff','tif','py','pict','pct'], 'Unknown file format "%s"' % format | def asString(self, format, verbose=None): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','tiff','tif','py'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0] if format == 'pdf': from reportlab.graphics import renderPDF return renderPDF.drawToString(self) elif format in ['gif','png','tif','jpg']: from reportlab.graphics import renderPM return renderPM.drawToString(self, fmt=format) elif format == 'eps': from rlextra.graphics import renderPS_SEP return renderPS_SEP.drawToString(self, preview = getattr(self,'preview',1), showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'ps': from reportlab.graphics import renderPS return renderPS.drawToString(self, showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'py': return self._renderPy() |
elif format in ['gif','png','tif','jpg']: | elif format in ['gif','png','tif','jpg','pct','pict','bmp','ppm']: | def asString(self, format, verbose=None): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','tiff','tif','py'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0] if format == 'pdf': from reportlab.graphics import renderPDF return renderPDF.drawToString(self) elif format in ['gif','png','tif','jpg']: from reportlab.graphics import renderPM return renderPM.drawToString(self, fmt=format) elif format == 'eps': from rlextra.graphics import renderPS_SEP return renderPS_SEP.drawToString(self, preview = getattr(self,'preview',1), showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'ps': from reportlab.graphics import renderPS return renderPS.drawToString(self, showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'py': return self._renderPy() |
y = thisy+(dy-leading*0.5)*0.5 | y = thisy+(dy-ascent)*0.5 | def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t) |
canv.scale(0.67, 0.67) canv.translate(self.pageWidth / 6.0, self.pageHeight / 3.0) | scale_amt = (min(pageSize)/float(max(pageSize)))*.95 canv.translate(.025*self.pageHeight, (self.pageWidth/2.0) + 5) canv.scale(scale_amt, scale_amt) | def saveAsPresentation(self): """Write the PDF document, one slide per page.""" if self.verbose: print 'saving presentation...' pageSize = (self.pageWidth, self.pageHeight) if self.sourceFilename: filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' if self.outDir: filename = os.path.join(self.outDir,os.path.basename(filename)) if self.verbose: print filename #canv = canvas.Canvas(filename, pagesize = pageSize) outfile = getStringIO() canv = canvas.Canvas(outfile, pagesize = pageSize) canv.setPageCompression(self.compression) canv.setPageDuration(self.pageDuration) if self.title: canv.setTitle(self.title) if self.author: canv.setAuthor(self.author) if self.subject: canv.setSubject(self.subject) |
'bulletIndent':0 | 'bulletIndent':0, 'textColor': black | def listAttrs(self): print 'name =', self.name print 'parent =', self.parent keylist = self.defaults.keys() keylist.sort() for key in keylist: value = self.attributes.get(key, None) if value: print '%s = %s (direct)' % (key, value) else: #try for inherited value = getattr(self.parent, key, None) if value: print '%s = %s (inherited)' % (key, value) else: value = self.defaults[key] print '%s = %s (class default)' % (key, value) |
'color': (0,0,0) | 'color': black | def listAttrs(self): print 'name =', self.name print 'parent =', self.parent keylist = self.defaults.keys() keylist.sort() for key in keylist: value = self.attributes.get(key, None) if value: print '%s = %s (direct)' % (key, value) else: #try for inherited value = getattr(self.parent, key, None) if value: print '%s = %s (inherited)' % (key, value) else: value = self.defaults[key] print '%s = %s (class default)' % (key, value) |
'color':(1,1,1), | 'color':white, | def prepareCanvas(self, canvas): """You can ask a LineStyle to set up the canvas for drawing the lines.""" canvas.setLineWidth(1) #etc. etc. |
self.text = cleanBlockQuotedText(text) | text = cleanBlockQuotedText(text) self.text = text | def __init__(self, text, style, bulletText = None): self.text = cleanBlockQuotedText(text) self.style = style self.bulletText = bulletText self.debug = 0 #turn this on to see a pretty one with all the margins etc. |
text = cleanBlockQuotedText(self.text) | 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.""" text = cleanBlockQuotedText(self.text) |
|
text = self.text | 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.""" text = cleanBlockQuotedText(self.text) |
|
canvas.setFillColorRGB(0.9,0.9,0.9) | canvas.setFillColor(Color(0.9,0.9,0.9)) | 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.""" text = cleanBlockQuotedText(self.text) |
canvas.setFillColorRGB(1.0,1.0,0.0) | canvas.setFillColor(Color(1.0,1.0,0.0)) | 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.""" text = cleanBlockQuotedText(self.text) |
canvas.setStrokeColorRGB(1,0,0) | canvas.setStrokeColor(red) | def myFirstPage(canvas, doc): canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Bold',24) canvas.drawString(108, PAGE_HEIGHT-108, "PLATYPUS") canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "First Page") canvas.restoreState() |
canvas.setStrokeColorRGB(1,0,0) | canvas.setStrokeColor(red) | def myLaterPages(canvas, doc): #canvas.drawImage("snkanim.gif", 36, 36) canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page) canvas.restoreState() |
fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') | fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) | def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): "Saves copies of self in desired location and formats" ext = '' if not fnRoot: fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') try: fnRoot = % getattr(self,'chartId',0) except TypeError, err: if err != 'not all arguments converted': raise |
fnRoot = % getattr(self,'chartId',0) | fnRoot = fnRoot % getattr(self,'chartId',0) | def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): "Saves copies of self in desired location and formats" ext = '' if not fnRoot: fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') try: fnRoot = % getattr(self,'chartId',0) except TypeError, err: if err != 'not all arguments converted': raise |
fnroot = os.path.normpath(os.path.join(outDir,fnRoot)) | def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): "Saves copies of self in desired location and formats" ext = '' if not fnRoot: fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') try: fnRoot = % getattr(self,'chartId',0) except TypeError, err: if err != 'not all arguments converted': raise |
|
return 0.001 * reduce(operator_add,map(width,text)) * size | return 0.001 * reduce(operator_add,map(width,text), 0) * size | def stringWidth(self, text, size, encoding='utf-8'): "Calculate text width" if type(text) is not UnicodeType: text = unicode(text, encoding or 'utf-8') # encoding defaults to utf-8 width = lambda x,f=self.face.getCharWidth: f(ord(x)) return 0.001 * reduce(operator_add,map(width,text)) * size |
self._curweight = self._curcolor = self._curcellstyle = None | def __init__(self, data, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1): #print "colWidths", colWidths self.hAlign = 'CENTER' self._nrows = nrows = len(data) if len(data)==0 or type(data) not in _SeqTypes: raise ValueError, "%s must have at least 1 row" % self.identity() ncols = max(map(_rowLen,data)) if not ncols: raise ValueError, "%s must have at least 1 column" % self.identity() if colWidths is None: colWidths = ncols*[None] elif len(colWidths) != ncols: raise ValueError, "%s data error - %d columns in data but %d in grid" % (self.identity(),ncols, len(colWidths)) if rowHeights is None: rowHeights = nrows*[None] elif len(rowHeights) != nrows: raise ValueError, "%s data error - %d rows in data but %d in grid" % (self.identity(),nrows, len(rowHeights)) ncols = len(colWidths) for i in range(nrows): if len(data[i]) != ncols: raise ValueError, "%s not enough data points in row %d!" % (self.identity(),i) self._ncols = ncols self._rowHeights = self._argH = rowHeights self._colWidths = self._argW = colWidths self._cellvalues = data |
|
lib = import_zlib() | zlib = import_zlib() | def PIL_imagedata(self): lib = import_zlib() if not zlib: return image = self.image myimage = image.convert('RGB') imgwidth, imgheight = myimage.size |
rawdata = open(pfbFileName, 'rb').read() self._binaryData = rawdata firstPS = string.find(rawdata, '%!PS') self._length = len(rawdata) self._length1 = string.find(rawdata, 'eexec') pos2 = string.find(rawdata, 'cleartomark') if pos2 < 0: rawdata = rawdata + '0'*256 + 'cleartomark' pos2 = string.find(rawdata, 'cleartomark') zeroes = 0 while zeroes < 512: pos2 = pos2 - 1 if rawdata[pos2] == '0': zeroes = zeroes + 1 self._length2 = pos2 - self._length1 self._length3 = len(rawdata) - pos2 | d = open(pfbFileName, 'rb').read() s1, l1 = _pfbCheck(0,d,PFB_ASCII,pfbFileName) s2, l2 = _pfbCheck(l1,d,PFB_BINARY,pfbFileName) s3, l3 = _pfbCheck(l2,d,PFB_ASCII,pfbFileName) _pfbCheck(l3,d,PFB_EOF,pfbFileName) self._binaryData = d[s1:l1]+d[s2:l2]+d[s3:l3] self._length = len(self._binaryData) self._length1 = l1-s1 self._length2 = l2-s2 self._length3 = l3-s3 | def _loadGlyphs(self, pfbFileName): """Loads in binary glyph data, and finds the four length measurements needed for the font descriptor""" assert os.path.isfile(pfbFileName), 'file %s not found' % pfbFileName rawdata = open(pfbFileName, 'rb').read() self._binaryData = rawdata firstPS = string.find(rawdata, '%!PS') self._length = len(rawdata) self._length1 = string.find(rawdata, 'eexec') pos2 = string.find(rawdata, 'cleartomark') if pos2 < 0: # need to append the zeros rawdata = rawdata + '0'*256 + 'cleartomark' pos2 = string.find(rawdata, 'cleartomark') zeroes = 0 while zeroes < 512: pos2 = pos2 - 1 if rawdata[pos2] == '0': zeroes = zeroes + 1 self._length2 = pos2 - self._length1 self._length3 = len(rawdata) - pos2 |
'FontFile': fontFileRef | 'FontFile': fontFileRef, | def addObjects(self, doc): """Add whatever needed to PDF file, and return a FontDescriptor reference""" from reportlab.pdfbase import pdfdoc |
x2 = x_cen + r | def circle(self, x_cen, y_cen, r): """adds a circle to the path""" x1 = x_cen - r x2 = x_cen + r y1 = y_cen - r y2 = y_cen + r self.ellipse(x_cen - r, y_cen - r, x_cen + r, y_cen + r) |
|
y2 = y_cen + r self.ellipse(x_cen - r, y_cen - r, x_cen + r, y_cen + r) | width = height = 2*r self.ellipse(x1, y1, width, height) | def circle(self, x_cen, y_cen, r): """adds a circle to the path""" x1 = x_cen - r x2 = x_cen + r y1 = y_cen - r y2 = y_cen + r self.ellipse(x_cen - r, y_cen - r, x_cen + r, y_cen + r) |
def recursiveImport(modulename, baseDir=None): | def recursiveImport(modulename, baseDir=None, noCWD=0): | def recursiveImport(modulename, baseDir=None): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') part = parts[0] path = list(baseDir and (type(baseDir) not in SeqTypes and [baseDir] or filter(None,baseDir)) or None) if '.' not in path: path.insert(0,'.') #make import errors a bit more informative try: (file, pathname, description) = imp.find_module(part, path) childModule = parentModule = imp.load_module(part, file, pathname, description) for name in parts[1:]: (file, pathname, description) = imp.find_module(name, parentModule.__path__) childModule = imp.load_module(name, file, pathname, description) setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (part, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule |
if '.' not in path: path.insert(0,'.') | if not noCWD and '.' not in path: path.insert(0,'.') | def recursiveImport(modulename, baseDir=None): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') part = parts[0] path = list(baseDir and (type(baseDir) not in SeqTypes and [baseDir] or filter(None,baseDir)) or None) if '.' not in path: path.insert(0,'.') #make import errors a bit more informative try: (file, pathname, description) = imp.find_module(part, path) childModule = parentModule = imp.load_module(part, file, pathname, description) for name in parts[1:]: (file, pathname, description) = imp.find_module(name, parentModule.__path__) childModule = imp.load_module(name, file, pathname, description) setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (part, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule |
if os.path.isfile(f): os.remove(f) elif os.path.isdir(f): rmdir(f) elif '*' in f: map(kill,glob.glob(f)) | if '*' in f: map(kill,glob.glob(f)) else: if verbose>=2: print 'kill(%s)' % f if os.path.isfile(f): os.remove(f) elif os.path.isdir(f): rmdir(f) | def kill(f): 'remove directory or file unconditionally' if os.path.isfile(f): os.remove(f) elif os.path.isdir(f): rmdir(f) elif '*' in f: map(kill,glob.glob(f)) |
if os.path.isdir(dst): dst = os.path.join(dst,os.path.basename(src)) if os.path.isfile(dst): kill(dst) if os.path.isfile(src): shutil.copy2(src,dst) elif os.path.isdir(src): shutil.copyTree(src,dst) elif '*' in src: map(lambda f,dst=dst: copy(f,dst),glob.glob(src)) | if '*' in src: map(lambda f,dst=dst: copy(f,dst),glob.glob(src)) else: if os.path.isdir(dst): dst = os.path.join(dst,os.path.basename(src)) if verbose>=2: print 'copy(%s,%s)' % (src,dst) if os.path.isfile(src): remove(dst) shutil.copy2(src,dst) elif os.path.isdir(src): shutil.copyTree(src,dst) | def copy(src,dst): if os.path.isdir(dst): dst = os.path.join(dst,os.path.basename(src)) if os.path.isfile(dst): kill(dst) if os.path.isfile(src): shutil.copy2(src,dst) elif os.path.isdir(src): shutil.copyTree(src,dst) elif '*' in src: map(lambda f,dst=dst: copy(f,dst),glob.glob(src)) |
genAll()(quiet='-s') | genAll()(verbose=verbose) os.chdir(dst) | def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) rmdir(cvsdir) rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,projdir)), 'the export phase') else: do_exec(cvs+' co -P %s' % projdir, 'the checkout phase') if py2pdf: # now we need to move the files & delete those we don't need dst = py2pdf_dir rmdir(dst) os.mkdir(dst) for f in ("py2pdf.py", "PyFontify.py", "idle_print.py"): move(os.path.join('reportlab/demos/py2pdf',f),dst) for f in ('reportlab/demos', 'reportlab/platypus', 'reportlab/lib/styles.py', 'reportlab/README.pdfgen.txt', 'reportlab/pdfgen/test', 'reportlab/tools','reportlab/test', 'reportlab/docs'): kill(f) move(projdir,dst) for f in ('py2pdf.py','idle_print.py'): os.chmod(os.path.join(dst,f),0775) #rwxrwxr-x CVS_remove(dst) else: dst = os.path.join(d,"reportlab","docs") PP = "%s" % (d,) #add our reportlab parent to the path so we import from there if os.environ.has_key('PYTHONPATH'): opp = os.environ['PYTHONPATH'] os.environ['PYTHONPATH']='%s:%s' % (PP,opp) else: opp = None os.environ['PYTHONPATH']=PP if '-pythonpath' in sys.argv: print 'PYTHONPATH=%s'%os.environ['PYTHONPATH'] os.chdir(dst) try: # this creates PDFs in each manual's directory, and copies them to reportlab/docs genAll()(quiet='-s') # we copy them out to our html area copy(os.path.join(dst,'*.pdf'),htmldir) # and then delete them for f in ('*.pdf', 'userguide/*.pdf', 'graphguide/*.pdf' 'reference/*.pdf'): kill(f) except: print '????????????????????????????????' print 'Failed to run genAll.py, cwd=%s' % os.getcwd() do_exec('ls -l') print '????????????????????????????????' os.chdir(d) pyc_remove(cvsdir) #restore the python path if opp is None: del os.environ['PYTHONPATH'] else: os.environ['PYTHONPATH'] = opp |
copy(os.path.join(dst,'*.pdf'),htmldir) | copy('*.pdf',htmldir) | def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) rmdir(cvsdir) rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,projdir)), 'the export phase') else: do_exec(cvs+' co -P %s' % projdir, 'the checkout phase') if py2pdf: # now we need to move the files & delete those we don't need dst = py2pdf_dir rmdir(dst) os.mkdir(dst) for f in ("py2pdf.py", "PyFontify.py", "idle_print.py"): move(os.path.join('reportlab/demos/py2pdf',f),dst) for f in ('reportlab/demos', 'reportlab/platypus', 'reportlab/lib/styles.py', 'reportlab/README.pdfgen.txt', 'reportlab/pdfgen/test', 'reportlab/tools','reportlab/test', 'reportlab/docs'): kill(f) move(projdir,dst) for f in ('py2pdf.py','idle_print.py'): os.chmod(os.path.join(dst,f),0775) #rwxrwxr-x CVS_remove(dst) else: dst = os.path.join(d,"reportlab","docs") PP = "%s" % (d,) #add our reportlab parent to the path so we import from there if os.environ.has_key('PYTHONPATH'): opp = os.environ['PYTHONPATH'] os.environ['PYTHONPATH']='%s:%s' % (PP,opp) else: opp = None os.environ['PYTHONPATH']=PP if '-pythonpath' in sys.argv: print 'PYTHONPATH=%s'%os.environ['PYTHONPATH'] os.chdir(dst) try: # this creates PDFs in each manual's directory, and copies them to reportlab/docs genAll()(quiet='-s') # we copy them out to our html area copy(os.path.join(dst,'*.pdf'),htmldir) # and then delete them for f in ('*.pdf', 'userguide/*.pdf', 'graphguide/*.pdf' 'reference/*.pdf'): kill(f) except: print '????????????????????????????????' print 'Failed to run genAll.py, cwd=%s' % os.getcwd() do_exec('ls -l') print '????????????????????????????????' os.chdir(d) pyc_remove(cvsdir) #restore the python path if opp is None: del os.environ['PYTHONPATH'] else: os.environ['PYTHONPATH'] = opp |
g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor)) return g | strokeColor,strokeWidth,fillColor=self.strokeColor, self.strokeWidth, self.fillColor if (strokeWidth and strokeColor) or fillColor: g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor)) return g else: return None | def makeBackground(self): g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor)) return g |
encUsed = 'MacRomanEncoding' | encUsed = 'StandardEncoding' | def MakeType1Fonts(encoding): "returns a list of all the standard font objects" fonts = [] pos = 1 for fontname in StandardEnglishFonts: #Symbol is almost empty in WinAnsi, no choice! if fontname in ['Symbol', 'ZapfDingbats']: encUsed = 'MacRomanEncoding' else: encUsed = encoding font = PDFType1Font('F'+str(pos), fontname, encUsed) fonts.append(font) pos = pos + 1 return fonts |
g.draw() | def demo(self): D = Drawing(100, 100) |
|
if self.width < 0: | if self.width < 0 and self.height > 0: | def _flipRectCorners(self): "Flip rectangle's corners if width or height is negative." if self.width < 0: self.x = self.x + self.width self.width = -self.width if self.orientation == 'vertical': self.fillColorStart, self.fillColorEnd = self.fillColorEnd, self.fillColorStart |
if self.height < 0: | elif self.height < 0 and self.width > 0: | def _flipRectCorners(self): "Flip rectangle's corners if width or height is negative." if self.width < 0: self.x = self.x + self.width self.width = -self.width if self.orientation == 'vertical': self.fillColorStart, self.fillColorEnd = self.fillColorEnd, self.fillColorStart |
r, g, b = c0.red, c0.green, c0.green | r, g, b = c0.red, c0.green, c0.blue | def draw(self): # general widget bits group = Group() |
sr.x = x+s | sr.x = x | def test(): D = Drawing(450, 650) d = 80 s = 60 for row in range(10): y = 530 - row*d if row == 0: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.width = s g.height = s g.useRects = 0 g.useLines = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 1: for col in range(3): x = 20 + col*d g = Grid0() g.y = y g.x = x g.width = s g.height = s if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.width = s g.height = s g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.width = s sr.height = s sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.width = s sr.height = s sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) elif row == 5: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.width = s sr.height = s sr.fillColorStart = colors.white sr.fillColorEnd = colors.green sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 sr.orientation = 'vertical' elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) elif row == 6: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x+s sr.y = y+s sr.width = -s sr.height = -s sr.fillColorStart = colors.white sr.fillColorEnd = colors.green sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 sr.orientation = 'vertical' elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf' |
sr.width = -s | sr.width = s | def test(): D = Drawing(450, 650) d = 80 s = 60 for row in range(10): y = 530 - row*d if row == 0: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.width = s g.height = s g.useRects = 0 g.useLines = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 1: for col in range(3): x = 20 + col*d g = Grid0() g.y = y g.x = x g.width = s g.height = s if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.width = s g.height = s g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.width = s sr.height = s sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.width = s sr.height = s sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) elif row == 5: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.width = s sr.height = s sr.fillColorStart = colors.white sr.fillColorEnd = colors.green sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 sr.orientation = 'vertical' elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) elif row == 6: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x+s sr.y = y+s sr.width = -s sr.height = -s sr.fillColorStart = colors.white sr.fillColorEnd = colors.green sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 sr.orientation = 'vertical' elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf' |
for k in ['gif','tiff']: | for k in ['gif','tiff', 'png', 'jpg']: | def test(): #grab all drawings from the test module and write out. #make a page of links in HTML to assist viewing. import os from reportlab.graphics import testshapes drawings = [] if not os.path.isdir('pmout'): os.mkdir('pmout') htmlTop = """<html><head><title>renderGD output results</title></head> <body> <h1>renderPM results of output</h1> """ htmlBottom = """</body> </html> """ html = [htmlTop] for funcname in dir(testshapes): #if funcname[0:12] == 'getDrawing10': if funcname[0:10] == 'getDrawing': drawing = eval('testshapes.' + funcname + '()') #execute it docstring = eval('testshapes.' + funcname + '.__doc__') drawings.append((drawing, docstring)) |
y = rowpos + (cellstyle.bottomPadding + rowheight-cellstyle.topPadding+(n-1)*leading)/2.0 | y = rowpos + (cellstyle.bottomPadding + rowheight-cellstyle.topPadding+n*leading)/2.0 - fontsize | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
from java.io import File fp = File(fileName) | fp = open(fileName,'rb') | def __init__(self, fileName): if not haveImages: warnOnce('Imaging Library not available, unable to import bitmaps') return #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None |
a((rgb>>16)&0xff) a((rgb>>8)&0xff) | a(chr((rgb>>16)&0xff)) a(chr((rgb>>8)&0xff)) | def getRGBData(self): "Return byte array of RGB data as string" if self._data is None: if sys.platform[0:4] == 'java': import jarray from java.awt.image import PixelGrabber width, height = self.getSize() buffer = jarray.zeros(width*height, 'i') pg = PixelGrabber(self._image, 0,0,width,height,buffer,0,width) pg.grabPixels() # there must be a way to do this with a cast not a byte-level loop, # I just haven't found it yet... pixels = [] a = pixels.append for i in range(len(buffer)): rgb = buffer[i] a((rgb>>16)&0xff) a((rgb>>8)&0xff) a(chr(rgb&0xff)) self._data = ''.join(pixels) else: rgb = self._image.convert('RGB') self._data = rgb.tostring() return self._data |
space_available = maxWidth - (currentWidth + spaceWidth + wordWidth) if space_available > 0 or len(cLine)==0: | newWidth = currentWidth + spaceWidth + wordWidth if newWidth<=maxWidth or len(cLine)==0: | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list |
currentWidth = currentWidth + spaceWidth + wordWidth | currentWidth = newWidth | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list |
space_available = maxWidth - (currentWidth + spaceWidth + wordWidth) if space_available > 0 or n==0: | if wordWidth>0: newWidth = currentWidth + spaceWidth + wordWidth else: newWidth = currentWidth if newWidth<=maxWidth or n==0: | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list |
I.drawWidth = 9.25*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, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted(""" |
|
self.setFillColorCMYK(self, aColor[0], aColor[1], aColor[2], aColor[3]) | self.setFillColorCMYK(aColor[0], aColor[1], aColor[2], aColor[3]) | def setFillColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if isinstance(aColor, CMYKColor): c,m,y,k = (aColor.cyan, aColor.magenta, aColor.yellow, aColor.black) self._fillColorCMYK = (c, m, y, k) self._code.append('%s k' % fp_str(c, m, y, k)) elif isinstance(aColor, Color): #if type(aColor) == ColorType: rgb = (aColor.red, aColor.green, aColor.blue) self._fillColorRGB = rgb self._code.append('%s rg' % fp_str(rgb) ) elif type(aColor) in _SeqTypes: l = len(aColor) if l==3: self._fillColorRGB = aColor self._code.append('%s rg' % fp_str(aColor) ) elif l==4: self.setFillColorCMYK(self, aColor[0], aColor[1], aColor[2], aColor[3]) else: raise 'Unknown color', str(aColor) elif type(aColor) is StringType: self.setFillColor(toColor(aColor)) else: raise 'Unknown color', str(aColor) |
self.setStrokeColorCMYK(self, aColor[0], aColor[1], aColor[2], aColor[3]) | self.setStrokeColorCMYK(aColor[0], aColor[1], aColor[2], aColor[3]) | def setStrokeColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if isinstance(aColor, CMYKColor): c,m,y,k = (aColor.cyan, aColor.magenta, aColor.yellow, aColor.black) self._strokeColorCMYK = (c, m, y, k) self._code.append('%s K' % fp_str(c, m, y, k)) elif isinstance(aColor, Color): #if type(aColor) == ColorType: rgb = (aColor.red, aColor.green, aColor.blue) self._strokeColorRGB = rgb self._code.append('%s RG' % fp_str(rgb) ) elif type(aColor) in _SeqTypes: l = len(aColor) if l==3: self._strokeColorRGB = aColor self._code.append('%s RG' % fp_str(aColor) ) elif l==4: self.setStrokeColorCMYK(self, aColor[0], aColor[1], aColor[2], aColor[3]) else: raise 'Unknown color', str(aColor) elif type(aColor) is StringType: self.setFillColor(toColor(aColor)) else: raise 'Unknown color', str(aColor) |
self.setFillColor(toColor(aColor)) | self.setStrokeColor(toColor(aColor)) | def setStrokeColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if isinstance(aColor, CMYKColor): c,m,y,k = (aColor.cyan, aColor.magenta, aColor.yellow, aColor.black) self._strokeColorCMYK = (c, m, y, k) self._code.append('%s K' % fp_str(c, m, y, k)) elif isinstance(aColor, Color): #if type(aColor) == ColorType: rgb = (aColor.red, aColor.green, aColor.blue) self._strokeColorRGB = rgb self._code.append('%s RG' % fp_str(rgb) ) elif type(aColor) in _SeqTypes: l = len(aColor) if l==3: self._strokeColorRGB = aColor self._code.append('%s RG' % fp_str(aColor) ) elif l==4: self.setStrokeColorCMYK(self, aColor[0], aColor[1], aColor[2], aColor[3]) else: raise 'Unknown color', str(aColor) elif type(aColor) is StringType: self.setFillColor(toColor(aColor)) else: raise 'Unknown color', str(aColor) |
after he had sacked the famous town of Troy. Many cities did he visit, | after</font> he had sacked the famous town of Troy. Many cities did he visit, | def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """ |
of Jove, from whatsoever source you may know them.</font> | of Jove, from whatsoever source you may know them. | def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """ |
self.canv.translate(nudge, 0) | if DO_NUDGE: self.canv.translate(nudge, 0) OLD_DO_NUDGE = DO_NUDGE DO_NUDGE = 0 | def draw(self): nudge = 0.5 * (self.availWidth - self._width) self.canv.translate(nudge, 0) self._drawBkgrnd() self._drawLines() for row, rowstyle, rowpos, rowheight in map(None, self._cellvalues, self._cellStyles, self._rowpositions[1:], self._rowHeights): for cellval, cellstyle, colpos, colwidth in map(None, row, rowstyle, self._colpositions[:-1], self._colWidths): self._drawCell(cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)) |
num = ((85L**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 | num = (((85*c1+c2)*85+c3)*85+c4)*85L + (c5 +(0,0,0xFFFFFF,0xFFFF,0xFF)[remainder_size]) | 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() |
lastword = chr(b1+1) | lastword = chr(b1) | 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() |
lastword = chr(b1) + chr(b2+1) | lastword = chr(b1) + chr(b2) | 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() |
lastword = chr(b1) + chr(b2) + chr(b3+1) | lastword = chr(b1) + chr(b2) + chr(b3) | 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() |
a = angle * 180 / pi | a = angle * pi/180 | def skewX(angle): a = angle * 180 / pi return (1, 0, tan(a), 1, 0, 0) |
a = angle * 180 / pi | a = angle * pi/180 | def skewY(angle): a = angle * 180 / pi return (1, tan(a), 0, 1, 0, 0) |
y = y+cellval[0].getSpaceBefore() | if cellval: y += cellval[0].getSpaceBefore() | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
y = y - v.getSpaceBefore() y = y - h | y -= v.getSpaceBefore() y -= h | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
y = y - v.getSpaceAfter() | y -= v.getSpaceAfter() | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
y = y-leading | y -= leading | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle |
isFile = getattr(filename,'write',None) if isFile: hasSeek = getattr(filename,'seek',None) if hasSeek: fLoc = filename.tell() else: class _DUMMYFILE: def __init__(self,filename): self._filename = filename def write(self,bytes): pass def close(self): pass filename = _DUMMYFILE(filename) | self._doSave = 0 | 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 |
if passes and isFile and hasSeek: filename.seek(fLoc) | def close(self): pass |
|
if isFile and not hasSeek: filename = filename._filename | self._doSave = 0 self.canv.save() | def close(self): pass |
w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPadding) | y = self.y p = self.bottomMargin + self.bottomPadding w, h = drawable.wrap(self.width, y - p ) | def add(self, drawable): """ Draws the object at the current position. Returns 1 if successful, 0 if it would not fit. Raises a LayoutError if the object is too wide, or if it is too high for a totally empty frame, to avoid infinite loops""" w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPadding) |
if self.y - h < (self.bottomMargin - self.bottomPadding): | y = y - h if y < p: | def add(self, drawable): """ Draws the object at the current position. Returns 1 if successful, 0 if it would not fit. Raises a LayoutError if the object is too wide, or if it is too high for a totally empty frame, to avoid infinite loops""" w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPadding) |
drawable.drawOn(self.canvas, self.x, self.y - h) self.y = self.y - h | drawable.drawOn(self.canvas, self.x, y) self.y = y | def add(self, drawable): """ Draws the object at the current position. Returns 1 if successful, 0 if it would not fit. Raises a LayoutError if the object is too wide, or if it is too high for a totally empty frame, to avoid infinite loops""" w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPadding) |
if not (categoryNames is None): | if categoryNames is not None: | def makeTickLabels(self): g = Group() |
s.append('%0.2f' % i) | s.append('%0.6f' % i) | def fp_str(*a): if len(a)==1 and type(a[0]) in SeqTypes: a = a[0] s = [] for i in a: s.append('%0.2f' % i) return string.join(s) |
self._x = x * 1.0 self._y = y * 1.0 self._length = length * 1.0 def configure(self, multiSeries): self._catCount = len(multiSeries[0]) self._barWidth = self._length / (self._catCount or 1) | self._x = x self._y = y self._length = length def configure(self, multiSeries,barWidth=None): self._catCount = max(map(len,multiSeries)) self._barWidth = barWidth or (self._length/float(self._catCount or 1)) | def setPosition(self, x, y, length): # ensure floating point self._x = x * 1.0 self._y = y * 1.0 self._length = length * 1.0 |
__version__ = '$Id: ttfonts.py,v 1.21 2004/03/23 16:18:29 rgbecker Exp $' | __version__ = '$Id: ttfonts.py,v 1.22 2004/04/05 14:17:29 rgbecker Exp $' | def getSubsetInternalName(self, subset, doc): '''Returns the name of a PDF Font object corresponding to a given subset of this dynamic font. Use this function instead of PDFDocument.getInternalFontName.''' |
return '0X%8.8X' % i | return '0X%8.8X' % (long(i)&0xFFFFFFFFL) try: add32 = _rl_accel.add32 except: if sys.hexversion>=0x02030000: def add32(x, y): "Calculate (x + y) modulo 2**32" return _L2U32((long(x)+y) & 0xffffffffL) else: def add32(x, y): "Calculate (x + y) modulo 2**32" lo = (x & 0xFFFF) + (y & 0xFFFF) hi = (x >> 16) + (y >> 16) + (lo >> 16) return (hi << 16) | (lo & 0xFFFF) | def hex32(i): return '0X%8.8X' % i |
lo = (sum & 0xFFFF) + (n & 0xFFFF) hi = (sum >> 16) + (n >> 16) + (lo >> 16) sum = (hi << 16) | (lo & 0xFFFF) | sum = add32(sum,n) | def calcChecksum(data): """Calculates PDF-style checksums""" if len(data)&3: data = data + (4-(len(data)&3))*"\0" sum = 0 for n in unpack(">%dl" % (len(data)>>2), data): lo = (sum & 0xFFFF) + (n & 0xFFFF) hi = (sum >> 16) + (n >> 16) + (lo >> 16) sum = (hi << 16) | (lo & 0xFFFF) return sum |
try: add32 = _rl_accel.add32 except: def add32(x, y): "Calculate (x + y) modulo 2**32" lo = (x & 0xFFFF) + (y & 0xFFFF) hi = (x >> 16) + (y >> 16) + (lo >> 16) return (hi << 16) | (lo & 0xFFFF) del _rl_accel | del _rl_accel, sys | def calcChecksum(data): """Calculates PDF-style checksums""" if len(data)&3: data = data + (4-(len(data)&3))*"\0" sum = 0 for n in unpack(">%dl" % (len(data)>>2), data): lo = (sum & 0xFFFF) + (n & 0xFFFF) hi = (sum >> 16) + (n >> 16) + (lo >> 16) sum = (hi << 16) | (lo & 0xFFFF) return sum |
import time | def __init__(self, normalDate=None): """ Accept 1 of 4 values to initialize a NormalDate: 1. None - creates a NormalDate for the current day 2. integer in yyyymmdd format 3. string in yyyymmdd format 4. tuple in (yyyy, mm, dd) - localtime/gmtime can also be used """ if normalDate is None: import time self.setNormalDate(time.localtime(time.time())) else: self.setNormalDate(normalDate) |
|
elif tn in _SeqTypes: | elif tn in _DateSeqTypes: | def setNormalDate(self, normalDate): """ accepts date as scalar string/integer (yyyymmdd) or tuple (year, month, day, ...)""" tn=type(normalDate) if tn is IntType: self.normalDate = normalDate elif tn is StringType: try: self.normalDate = int(normalDate) except: m = _iso_re.match(normalDate) if m: self.setNormalDate(m.group(1)+m.group(2)+m.group(3)) else: raise NormalDateException("unable to setNormalDate(%s)" % `normalDate`) elif tn in _SeqTypes: self.normalDate = int("%04d%02d%02d" % normalDate[:3]) elif tn is _NDType: self.normalDate = normalDate.normalDate if not self._isValidNormalDate(self.normalDate): raise NormalDateException("unable to setNormalDate(%s)" % `normalDate`) |
et = ETriangle0() | et = RTriangle0() | def demo(self): D = shapes.Drawing(200, 100) et = ETriangle0() et.x=50 et.y=0 et.draw() D.add(et) labelFontSize = 10 D.add(shapes.String(et.x+(et.size/2),(et.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
D = shapes.Drawing(200, 200) | D = shapes.Drawing(200, 100) | def demo(self): D = shapes.Drawing(200, 200) labelFontSize = 10 cb = Crossbox0() cb.x=50 cb.y=0 cb.draw() D.add(cb) D.add(shapes.String(cb.x+(cb.size/2),(cb.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
na = NoSmoking0() na.x=50 na.y=0 na.draw() D.add(na) labelFontSize = 10 D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), | ns = NoSmoking0() ns.x=50 ns.y=0 ns.draw() D.add(ns) labelFontSize = 10 D.add(shapes.String(ns.x+(ns.size/2),(ns.y-(1.2*labelFontSize)), | def demo(self): D = shapes.Drawing(200, 100) na = NoSmoking0() na.x=50 na.y=0 na.draw() D.add(na) labelFontSize = 10 D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
yn.x = 50 yn.y = 0 yn.testValue = 1 | yn.x = 15 yn.y = 25 yn.size = 70 yn.testValue = 0 | def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 50 yn.y = 0 yn.testValue = 1 yn.draw() D.add(yn) labelFontSize = 10 D.add(shapes.String(yn.x+(yn.size/2),(yn.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
labelFontSize = 10 | yn2 = YesNo0() yn2.x = 120 yn2.y = 25 yn2.size = 70 yn2.testValue = 1 yn2.draw() D.add(yn2) labelFontSize = 8 | def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 50 yn.y = 0 yn.testValue = 1 yn.draw() D.add(yn) labelFontSize = 10 D.add(shapes.String(yn.x+(yn.size/2),(yn.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
a2 = ArrowOne0() | a2 = ArrowTwo0() | def demo(self): D = shapes.Drawing(200, 100) a2 = ArrowOne0() a2.x=50 a2.y=0 a2.draw() D.add(a2) labelFontSize = 10 D.add(shapes.String(a2.x+(a2.size/2),(a2.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) | sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | def format(self, num): # positivize the numbers absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) if self.thousandSeparator is not None: strNew = '' while strInt: left, right = strInt[0:-3], strInt[-3:] if left == '': #strNew = self.thousandSeparator + right + strNew strNew = right + strNew else: strNew = self.thousandSeparator + right + strNew strInt = left strInt = strNew places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places pattern = '%0.' + str(places) + 'f' strFrac = sep + (pattern % fracPart)[2:] if strip: while strFrac and strFrac[-1] in ['0',sep]: strFrac = strFrac[:-1] strBody = strInt + strFrac if sign == -1: strBody = '-' + strBody if self.prefix: strBody = self.prefix + strBody if self.suffix: strBody = strBody + self.suffix return strBody |
places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places pattern = '%0.' + str(places) + 'f' strFrac = sep + (pattern % fracPart)[2:] | strFrac = sep + strFrac | def format(self, num): # positivize the numbers absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) if self.thousandSeparator is not None: strNew = '' while strInt: left, right = strInt[0:-3], strInt[-3:] if left == '': #strNew = self.thousandSeparator + right + strNew strNew = right + strNew else: strNew = self.thousandSeparator + right + strNew strInt = left strInt = strNew places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places pattern = '%0.' + str(places) + 'f' strFrac = sep + (pattern % fracPart)[2:] if strip: while strFrac and strFrac[-1] in ['0',sep]: strFrac = strFrac[:-1] strBody = strInt + strFrac if sign == -1: strBody = '-' + strBody if self.prefix: strBody = self.prefix + strBody if self.suffix: strBody = strBody + self.suffix return strBody |
if sign == -1: strBody = '-' + strBody | if sign: strBody = '-' + strBody | def format(self, num): # positivize the numbers absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) if self.thousandSeparator is not None: strNew = '' while strInt: left, right = strInt[0:-3], strInt[-3:] if left == '': #strNew = self.thousandSeparator + right + strNew strNew = right + strNew else: strNew = self.thousandSeparator + right + strNew strInt = left strInt = strNew places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places pattern = '%0.' + str(places) + 'f' strFrac = sep + (pattern % fracPart)[2:] if strip: while strFrac and strFrac[-1] in ['0',sep]: strFrac = strFrac[:-1] strBody = strInt + strFrac if sign == -1: strBody = '-' + strBody if self.prefix: strBody = self.prefix + strBody if self.suffix: strBody = strBody + self.suffix return strBody |
text = join(tx.lines[i][1]) | text = join(tx.XtraState.lines[i][1]) | def _do_under_lines(i, t_off, tx): y = tx.XtraState.cur_y - i*tx.XtraState.style.leading - tx.XtraState.f.fontSize/8.0 # 8.0 factor copied from para.py text = join(tx.lines[i][1]) textlen = tx._canvas.stringWidth(text, tx._fontname, tx._fontsize) tx._canvas.line(t_off, y, t_off+textlen, y) |
def cvs_checkout(d,u): | def cvs_checkout(d): | def cvs_checkout(d,u): recursive_rmdir(d) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) have_tmp = os.path.isdir(_tmp) os.makedirs(d) os.environ['HOME']=d os.environ['CVSROOT']=':pserver:[email protected]:/cvsroot/reportlab' os.chdir(d) f = open(os.path.join(d,'.cvspass'),'w') f.write(_cvspass+'\n') f.close() i=os.popen(cvs+' -z7 -d:pserver:[email protected]:/cvsroot/reportlab co reportlab','r') print i.read() i = i.close() if i is not None: print 'there was an error during the download phase' sys.exit(1) |
rawInterval = rawRange / min(self.maximumTicks-1,(float(self._length)/self.minimumTickSpacing )) | rawInterval = rawRange / min(float(self.maximumTicks-1),(float(self._length)/self.minimumTickSpacing )) | def _calcValueStep(self): '''Calculate _valueStep for the axis or get from valueStep.''' |
if self.inObject not in ["form", None]: raise ValueError, "can't go in form already in object %s" % self.inObject | def inForm(self): """specify that we are in a form xobject (disable page features, etc)""" if self.inObject not in ["form", None]: raise ValueError, "can't go in form already in object %s" % self.inObject self.inObject = "form" # don't need to do anything else, I think... |
|
self.initial = initial | self._initial = initial | def __init__(self,validate=None,desc=None,initial=None, **kw): self.validate = validate or isAnything self.desc = desc self.initial = initial for k,v in kw.items(): setattr(self,k,v) |
self._cellvalues = data | def __init__(self, data, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1, emptyTableAction=None): 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.