bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
|
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
| 4,400
|
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
|
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
| 4,401
|
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
|
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
| 4,402
|
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)
|
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)
| 4,403
|
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)
|
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)
| 4,404
|
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)
|
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)
| 4,405
|
def prepareCanvas(self, canvas): """You can ask a LineStyle to set up the canvas for drawing the lines.""" canvas.setLineWidth(1) #etc. etc.
|
def prepareCanvas(self, canvas): """You can ask a LineStyle to set up the canvas for drawing the lines.""" canvas.setLineWidth(1) #etc. etc.
| 4,406
|
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.
|
def __init__(self, text, style, bulletText = None): text = cleanBlockQuotedText(text) self.text = text self.style = style self.bulletText = bulletText self.debug = 0 #turn this on to see a pretty one with all the margins etc.
| 4,407
|
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)
|
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)
| 4,408
|
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)
|
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)
| 4,409
|
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)
|
defdrawPara(self,debug=0):"""Drawsaparagraphaccordingtothegivenstyle.Returnsthefinalypositionatthebottom.Notsafeforparagraphswithoutspacese.g.Japanese;wrappingalgorithmwillgoinfinite."""text=cleanBlockQuotedText(self.text)
| 4,410
|
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)
|
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)
| 4,411
|
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)
|
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)
| 4,412
|
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)
|
defdrawPara(self,debug=0):"""Drawsaparagraphaccordingtothegivenstyle.Returnsthefinalypositionatthebottom.Notsafeforparagraphswithoutspacese.g.Japanese;wrappingalgorithmwillgoinfinite."""text=cleanBlockQuotedText(self.text)
| 4,413
|
def __init__(self, text, style, bulletText = None, dedent=0): self.style = style self.bulletText = bulletText
|
def __init__(self, text, style, bulletText = None, dedent=0): self.style = style self.bulletText = bulletText
| 4,414
|
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch.
|
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch.
| 4,415
|
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()
|
def myFirstPage(canvas, doc): canvas.saveState() canvas.setStrokeColor(red) 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()
| 4,416
|
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()
|
def myLaterPages(canvas, doc): #canvas.drawImage("snkanim.gif", 36, 36) canvas.saveState() canvas.setStrokeColor(red) 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()
| 4,417
|
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
|
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
| 4,418
|
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
|
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 = fnRoot % getattr(self,'chartId',0) except TypeError, err: if err != 'not all arguments converted': raise
| 4,419
|
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
|
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
| 4,420
|
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
|
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
| 4,421
|
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
|
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
| 4,422
|
def PIL_imagedata(self): lib = import_zlib() if not zlib: return image = self.image myimage = image.convert('RGB') imgwidth, imgheight = myimage.size
|
def PIL_imagedata(self): zlib = import_zlib() if not zlib: return image = self.image myimage = image.convert('RGB') imgwidth, imgheight = myimage.size
| 4,423
|
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
|
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
| 4,424
|
def addObjects(self, doc): """Add whatever needed to PDF file, and return a FontDescriptor reference""" from reportlab.pdfbase import pdfdoc
|
def addObjects(self, doc): """Add whatever needed to PDF file, and return a FontDescriptor reference""" from reportlab.pdfbase import pdfdoc
| 4,425
|
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 circle(self, x_cen, y_cen, r): """adds a circle to the path""" x1 = 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)
| 4,426
|
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 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 width = height = 2*r self.ellipse(x1, y1, width, height)
| 4,427
|
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
|
def recursiveImport(modulename, baseDir=None, noCWD=0): """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
| 4,428
|
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
|
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 noCWD and '.' 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
| 4,429
|
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))
|
def kill(f): 'remove directory or file unconditionally' 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)
| 4,430
|
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))
|
def copy(src,dst): 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)
| 4,431
|
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:%s@cvs.reportlab.sourceforge.net:/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
|
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:%s@cvs.reportlab.sourceforge.net:/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()(verbose=verbose) os.chdir(dst) # 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
| 4,432
|
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:%s@cvs.reportlab.sourceforge.net:/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
|
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:%s@cvs.reportlab.sourceforge.net:/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('*.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
| 4,433
|
def makeBackground(self): g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor)) return g
|
def makeBackground(self): g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor)) return g
| 4,434
|
def save(self, file): file.write(self.template % (self.keyname, self.fontname, self.encoding) + LINEEND)
|
def save(self, file): file.write(self.template % (self.keyname, self.fontname, self.encoding) + LINEEND)
| 4,435
|
def save(self, file): file.write(self.template % (self.keyname, self.fontname, self.encoding) + LINEEND)
|
defsave(self,file):file.write(self.template%(self.keyname,self.fontname,self.encoding)+LINEEND)
| 4,436
|
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
|
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
| 4,437
|
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
|
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 = 'StandardEncoding' else: encUsed = encoding font = PDFType1Font('F'+str(pos), fontname, encUsed) fonts.append(font) pos = pos + 1 return fonts
| 4,438
|
def makeInnerTiles(self): # inner grid lines group = Group()
|
def makeInnerTiles(self): # inner grid lines group = Group()
| 4,439
|
def demo(self): D = Drawing(100, 100)
|
def demo(self): D = Drawing(100, 100)
| 4,440
|
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
|
def _flipRectCorners(self): "Flip rectangle's corners if width or height is negative." if self.width < 0 and self.height > 0: self.x = self.x + self.width self.width = -self.width if self.orientation == 'vertical': self.fillColorStart, self.fillColorEnd = self.fillColorEnd, self.fillColorStart
| 4,441
|
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
|
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
| 4,442
|
def draw(self): # general widget bits group = Group()
|
def draw(self): # general widget bits group = Group()
| 4,443
|
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'
|
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 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'
| 4,444
|
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'
|
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'
| 4,445
|
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))
|
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))
| 4,446
|
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
|
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
| 4,447
|
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
|
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
| 4,448
|
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
|
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
| 4,449
|
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
|
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(chr((rgb>>16)&0xff)) a(chr((rgb>>8)&0xff)) a(chr(rgb&0xff)) self._data = ''.join(pixels) else: rgb = self._image.convert('RGB') self._data = rgb.tostring() return self._data
| 4,450
|
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
|
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
| 4,451
|
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
|
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
| 4,452
|
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
|
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
| 4,453
|
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
|
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
| 4,454
|
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("""
|
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("""
| 4,455
|
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)
|
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(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)
| 4,456
|
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)
|
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(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)
| 4,457
|
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)
|
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.setStrokeColor(toColor(aColor)) else: raise 'Unknown color', str(aColor)
| 4,458
|
def start_font(self,attr): A = {} for i, j in self._fontAttrMap.items(): if attr.has_key(i): func = j[1] val = attr[i] try: A[j[0]] = (func is None) and val or apply(func,(val,)) except: self.syntax_error('%s: invalid value %s'%(i,val)) apply(self._push,(),A)
|
def start_font(self,attr): A = {} for i, j in self._fontAttrMap.items(): if attr.has_key(i): func = j[1] val = attr[i] try: A[j[0]] = (func is None) and val or apply(func,(val,)) except: self.syntax_error('%s: invalid value %s'%(i,val)) apply(self._push,(),A)
| 4,459
|
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. """
|
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. """
| 4,460
|
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. """
|
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. """
| 4,461
|
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))
|
def draw(self): nudge = 0.5 * (self.availWidth - self._width) if DO_NUDGE: self.canv.translate(nudge, 0) OLD_DO_NUDGE = DO_NUDGE DO_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))
| 4,462
|
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()
|
def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream' stripped = stripped[:-2] #chop off terminator #may have 'z' in it which complicates matters - expand them stripped = string.replace(stripped,'z','!!!!!') # special rules apply if not a multiple of five bytes. whole_word_count, remainder_size = divmod(len(stripped), 5) #print '%d words, %d leftover' % (whole_word_count, remainder_size) assert remainder_size <> 1, 'invalid Ascii 85 stream!' cut = 5 * whole_word_count body, lastbit = stripped[0:cut], stripped[cut:] for i in range(whole_word_count): offset = i*5 c1 = ord(body[offset]) - 33 c2 = ord(body[offset+1]) - 33 c3 = ord(body[offset+2]) - 33 c4 = ord(body[offset+3]) - 33 c5 = ord(body[offset+4]) - 33 num = (((85*c1+c2)*85+c3)*85+c4)*85L + (c5 +(0,0,0xFFFFFF,0xFFFF,0xFF)[remainder_size]) temp, b4 = divmod(num,256) temp, b3 = divmod(temp,256) b1, b2 = divmod(temp, 256) assert num == 16777216 * b1 + 65536 * b2 + 256 * b3 + b4, 'dodgy code!' outstream.write(chr(b1)) outstream.write(chr(b2)) outstream.write(chr(b3)) outstream.write(chr(b4)) #decode however many bytes we have as usual if remainder_size > 0: while len(lastbit) < 5: lastbit = lastbit + '!' c1 = ord(lastbit[0]) - 33 c2 = ord(lastbit[1]) - 33 c3 = ord(lastbit[2]) - 33 c4 = ord(lastbit[3]) - 33 c5 = ord(lastbit[4]) - 33 num = (((85*c1+c2)*85+c3)*85+c4)*85L + (c5 +(0,0,0xFFFFFF,0xFFFF,0xFF)[remainder_size]) 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()
| 4,463
|
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()
|
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) 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()
| 4,464
|
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()
|
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) 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()
| 4,465
|
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()
|
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) outstream.write(lastword) #terminator code for ascii 85 outstream.reset() return outstream.read()
| 4,466
|
def rotate(angle): a = angle * pi /180 return (cos(a), sin(a), -sin(a), cos(a), 0, 0)
|
def rotate(angle): a = angle * pi/180 return (cos(a), sin(a), -sin(a), cos(a), 0, 0)
| 4,467
|
def skewX(angle): a = angle * 180 / pi return (1, 0, tan(a), 1, 0, 0)
|
def skewX(angle): a = angle * pi/180 return (1, 0, tan(a), 1, 0, 0)
| 4,468
|
def skewY(angle): a = angle * 180 / pi return (1, tan(a), 0, 1, 0, 0)
|
def skewY(angle): a = angle * pi/180 return (1, tan(a), 0, 1, 0, 0)
| 4,469
|
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
|
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
| 4,470
|
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
|
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
| 4,471
|
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
|
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
| 4,472
|
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
|
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
| 4,473
|
def multiBuild(self, story, filename=None, canvasmaker=canvas.Canvas, maxPasses = 10): """Makes multiple passes until all indexing flowables are happy.""" self._indexingFlowables = [] #scan the story and keep a copy for thing in story: if thing.isIndexing(): self._indexingFlowables.append(thing) #print 'scanned story, found these indexing flowables:\n' #print self._indexingFlowables
|
def multiBuild(self, story, filename=None, canvasmaker=canvas.Canvas, maxPasses = 10): """Makes multiple passes until all indexing flowables are happy.""" self._indexingFlowables = [] #scan the story and keep a copy for thing in story: if thing.isIndexing(): self._indexingFlowables.append(thing) #print 'scanned story, found these indexing flowables:\n' #print self._indexingFlowables
| 4,474
|
def close(self): pass
|
def close(self): pass
| 4,475
|
def close(self): pass
|
def close(self): pass
| 4,476
|
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)
|
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)
| 4,477
|
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)
|
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)
| 4,478
|
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)
|
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)
| 4,479
|
def makeTickLabels(self): g = Group()
|
def makeTickLabels(self): g = Group()
| 4,480
|
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)
|
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.6f' % i) return string.join(s)
| 4,481
|
def setPosition(self, x, y, length): # ensure floating point self._x = x * 1.0 self._y = y * 1.0 self._length = length * 1.0
|
def setPosition(self, x, y, length): # ensure floating point self._x = x * 1.0 self._y = y * 1.0 self._length = length * 1.0
| 4,482
|
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.'''
|
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.'''
| 4,483
|
def latin1_to_utf8(text): "helper to convert when needed from latin input" return utf_8_encode(latin_1_decode(text)[0])[0]
|
deflatin1_to_utf8(text):"helpertoconvertwhenneededfromlatininput"returnutf_8_encode(latin_1_decode(text)[0])[0]
| 4,484
|
def hex32(i): return '0X%8.8X' % i
|
def hex32(i): return '0X%8.8X' % i
| 4,485
|
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
|
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): sum = add32(sum,n) return sum
| 4,486
|
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
|
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
| 4,487
|
def makeStream(self): "Finishes the generation and returns the TTF file as a string" stm = StringIO()
|
defmakeStream(self):"FinishesthegenerationandreturnstheTTFfileasastring"stm=StringIO()
| 4,488
|
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)
|
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: self.setNormalDate(time.localtime(time.time())) else: self.setNormalDate(normalDate)
| 4,489
|
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`)
|
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 _DateSeqTypes: 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`)
| 4,490
|
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
|
def demo(self): D = shapes.Drawing(200, 100) et = RTriangle0() 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
| 4,491
|
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
|
def demo(self): D = shapes.Drawing(200, 100) 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
| 4,492
|
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
|
def demo(self): D = shapes.Drawing(200, 100) 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)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D
| 4,493
|
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
|
def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 15 yn.y = 25 yn.size = 70 yn.testValue = 0 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
| 4,494
|
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
|
def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 50 yn.y = 0 yn.testValue = 1 yn.draw() D.add(yn) yn2 = YesNo0() yn2.x = 120 yn2.y = 25 yn2.size = 70 yn2.testValue = 1 yn2.draw() D.add(yn2) labelFontSize = 8 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
| 4,495
|
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
|
def demo(self): D = shapes.Drawing(200, 100) a2 = ArrowTwo0() 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
| 4,496
|
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
|
def format(self, num): # positivize the numbers 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('.') 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
| 4,497
|
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
|
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 strFrac = sep + strFrac 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
| 4,498
|
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
|
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: strBody = '-' + strBody if self.prefix: strBody = self.prefix + strBody if self.suffix: strBody = strBody + self.suffix return strBody
| 4,499
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.