rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.seek(string_data_offset + offset) if length % 2 != 0: raise TTFError, "PostScript name is UTF-16BE string of odd length" length /= 2 N = [] A = N.append while length > 0: char = self.read_ushort() A(chr(char)) length -= 1 N = ''.join(N) | opos = self._pos try: self.seek(string_data_offset + offset) if length % 2 != 0: raise TTFError, "PostScript name is UTF-16BE string of odd length" length /= 2 N = [] A = N.append while length > 0: char = self.read_ushort() A(chr(char)) length -= 1 N = ''.join(N) finally: self._pos = opos | def extractInfo(self, charInfo=1): """Extract typographic information from the loaded font file. |
os.path.walk('.',find_cleanable_files,test_files) | os.path.walk('.',find_cleanable_files,None) | def find_cleanable_files(L,d,N): n = os.path.basename(d) for n in filter(lambda n: n[-3:]=='.PYC' or n[-4:]=='.PDF' or n[-4:]=='.A85',map(string.upper,N)): fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): os.remove(fn) |
bt = None if self._curPara.style == 'Bullet' and bt == '': bt = '\267' | if self._curPara.style == 'Bullet': bt = '\267' else: bt = None | def start_para(self, args): self._curPara = pythonpoint.PPPara() self._curPara.style = self._arg('para',args,'style') |
if valign != 'TOP' or just != 'LEFT': | if valign != 'BOTTOM' or just != 'LEFT': | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
y = rowpos + rowheight - cellstyle.topPadding | y = rowpos + rowheight - cellstyle.topPadding+h | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
y = rowpos+cellstyle.bottomPadding+h | y = rowpos+cellstyle.bottomPadding | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
y = rowpos+(rowheight+cellstyle.bottomPadding-cellstyle.topPadding+h)/2.0 | y = rowpos+(rowheight+cellstyle.bottomPadding-cellstyle.topPadding-h)/2.0 | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
apply(im.save,(fn,fmt),self.configPIL or {}) | configPIL = self.configPIL or {} if fmt=='TIFF': for a,d in ('resolution',self._dpi),('resolution unit','inch'): configPIL[a] = configPIL.get(a,d) apply(im.save,(fn,fmt),configPIL) | def saveToFile(self,fn,fmt=None): im = self.toPIL() if fmt is None: if type(fn) is not StringType: raise ValueError, "Invalid type '%s' for fn when fmt is None" % type(fn) else: fmt = string.upper(fmt) if fmt in ['GIF']: im = _convert2pilp(im) elif fmt in ['PCT','PICT']: return _saveAsPICT(im,fn,fmt) elif fmt in ['PNG'... |
assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','tiff','tif','py'], 'Unknown file format "%s"' % format | assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','bmp','ppm','tiff','tif','py','pict','pct'], 'Unknown file format "%s"' % format | def asString(self, format, verbose=None): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','tiff','tif','py'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbos... |
elif format in ['gif','png','tif','jpg']: | elif format in ['gif','png','tif','jpg','pct','pict','bmp','ppm']: | def asString(self, format, verbose=None): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','tiff','tif','py'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbos... |
y = thisy+(dy-leading*0.5)*0.5 | y = thisy+(dy-ascent)*0.5 | def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t) |
canv.scale(0.67, 0.67) canv.translate(self.pageWidth / 6.0, self.pageHeight / 3.0) | scale_amt = (min(pageSize)/float(max(pageSize)))*.95 canv.translate(.025*self.pageHeight, (self.pageWidth/2.0) + 5) canv.scale(scale_amt, scale_amt) | def saveAsPresentation(self): """Write the PDF document, one slide per page.""" if self.verbose: print 'saving presentation...' pageSize = (self.pageWidth, self.pageHeight) if self.sourceFilename: filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' if self.outDir: filename = os.path.join(self.outDir,os.path.ba... |
'bulletIndent':0 | 'bulletIndent':0, 'textColor': black | def listAttrs(self): print 'name =', self.name print 'parent =', self.parent keylist = self.defaults.keys() keylist.sort() for key in keylist: value = self.attributes.get(key, None) if value: print '%s = %s (direct)' % (key, value) else: #try for inherited value = getattr(self.parent, key, None) if value: print '%s = %... |
'color': (0,0,0) | 'color': black | def listAttrs(self): print 'name =', self.name print 'parent =', self.parent keylist = self.defaults.keys() keylist.sort() for key in keylist: value = self.attributes.get(key, None) if value: print '%s = %s (direct)' % (key, value) else: #try for inherited value = getattr(self.parent, key, None) if value: print '%s = %... |
'color':(1,1,1), | 'color':white, | def prepareCanvas(self, canvas): """You can ask a LineStyle to set up the canvas for drawing the lines.""" canvas.setLineWidth(1) #etc. etc. |
self.text = cleanBlockQuotedText(text) | text = cleanBlockQuotedText(text) self.text = text | def __init__(self, text, style, bulletText = None): self.text = cleanBlockQuotedText(text) self.style = style self.bulletText = bulletText self.debug = 0 #turn this on to see a pretty one with all the margins etc. |
text = cleanBlockQuotedText(self.text) | def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text) | |
text = self.text | def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text) | |
canvas.setFillColorRGB(0.9,0.9,0.9) | canvas.setFillColor(Color(0.9,0.9,0.9)) | def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text) |
canvas.setFillColorRGB(1.0,1.0,0.0) | canvas.setFillColor(Color(1.0,1.0,0.0)) | def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text) |
canvas.setStrokeColorRGB(1,0,0) | canvas.setStrokeColor(red) | def myFirstPage(canvas, doc): canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Bold',24) canvas.drawString(108, PAGE_HEIGHT-108, "PLATYPUS") canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "First Page") canvas.... |
canvas.setStrokeColorRGB(1,0,0) | canvas.setStrokeColor(red) | def myLaterPages(canvas, doc): #canvas.drawImage("snkanim.gif", 36, 36) canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page) canvas.restoreState() |
fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') | fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) | def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): "Saves copies of self in desired location and formats" ext = '' if not fnRoot: fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') try: fnRoot = % getattr(self,'chartId',0) except TypeError, err: if err != 'not all arguments conv... |
fnRoot = % getattr(self,'chartId',0) | fnRoot = fnRoot % getattr(self,'chartId',0) | def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): "Saves copies of self in desired location and formats" ext = '' if not fnRoot: fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') try: fnRoot = % getattr(self,'chartId',0) except TypeError, err: if err != 'not all arguments conv... |
fnroot = os.path.normpath(os.path.join(outDir,fnRoot)) | def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): "Saves copies of self in desired location and formats" ext = '' if not fnRoot: fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') try: fnRoot = % getattr(self,'chartId',0) except TypeError, err: if err != 'not all arguments conv... | |
return 0.001 * reduce(operator_add,map(width,text)) * size | return 0.001 * reduce(operator_add,map(width,text), 0) * size | def stringWidth(self, text, size, encoding='utf-8'): "Calculate text width" if type(text) is not UnicodeType: text = unicode(text, encoding or 'utf-8') # encoding defaults to utf-8 width = lambda x,f=self.face.getCharWidth: f(ord(x)) return 0.001 * reduce(operator_add,map(width,text)) * size |
self._curweight = self._curcolor = self._curcellstyle = None | def __init__(self, data, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1): #print "colWidths", colWidths self.hAlign = 'CENTER' self._nrows = nrows = len(data) if len(data)==0 or type(data) not in _SeqTypes: raise ValueError, "%s must have at least 1 row" % self.identity() ncols = ... | |
lib = import_zlib() | zlib = import_zlib() | def PIL_imagedata(self): lib = import_zlib() if not zlib: return image = self.image myimage = image.convert('RGB') imgwidth, imgheight = myimage.size |
rawdata = open(pfbFileName, 'rb').read() self._binaryData = rawdata firstPS = string.find(rawdata, '%!PS') self._length = len(rawdata) self._length1 = string.find(rawdata, 'eexec') pos2 = string.find(rawdata, 'cleartomark') if pos2 < 0: rawdata = rawdata + '0'*256 + 'cleartomark' pos2 = string.find(rawdata, 'cleartoma... | d = open(pfbFileName, 'rb').read() s1, l1 = _pfbCheck(0,d,PFB_ASCII,pfbFileName) s2, l2 = _pfbCheck(l1,d,PFB_BINARY,pfbFileName) s3, l3 = _pfbCheck(l2,d,PFB_ASCII,pfbFileName) _pfbCheck(l3,d,PFB_EOF,pfbFileName) self._binaryData = d[s1:l1]+d[s2:l2]+d[s3:l3] self._length = len(self._binaryData) self._length1 = l1-s1 se... | 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') sel... |
'FontFile': fontFileRef | 'FontFile': fontFileRef, | def addObjects(self, doc): """Add whatever needed to PDF file, and return a FontDescriptor reference""" from reportlab.pdfbase import pdfdoc |
x2 = x_cen + r | def circle(self, x_cen, y_cen, r): """adds a circle to the path""" x1 = x_cen - r x2 = x_cen + r y1 = y_cen - r y2 = y_cen + r self.ellipse(x_cen - r, y_cen - r, x_cen + r, y_cen + r) | |
y2 = y_cen + r self.ellipse(x_cen - r, y_cen - r, x_cen + r, y_cen + r) | width = height = 2*r self.ellipse(x1, y1, width, height) | def circle(self, x_cen, y_cen, r): """adds a circle to the path""" x1 = x_cen - r x2 = x_cen + r y1 = y_cen - r y2 = y_cen + r self.ellipse(x_cen - r, y_cen - r, x_cen + r, y_cen + r) |
def recursiveImport(modulename, baseDir=None): | def recursiveImport(modulename, baseDir=None, noCWD=0): | def recursiveImport(modulename, baseDir=None): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') part = parts[0] path = list(baseDir and (type(baseDir) not in SeqTypes and [baseDir] or filter(None,baseDir)) or None) if '.' not in path: path.inse... |
if '.' not in path: path.insert(0,'.') | if not noCWD and '.' not in path: path.insert(0,'.') | def recursiveImport(modulename, baseDir=None): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') part = parts[0] path = list(baseDir and (type(baseDir) not in SeqTypes and [baseDir] or filter(None,baseDir)) or None) if '.' not in path: path.inse... |
if os.path.isfile(f): os.remove(f) elif os.path.isdir(f): rmdir(f) elif '*' in f: map(kill,glob.glob(f)) | if '*' in f: map(kill,glob.glob(f)) else: if verbose>=2: print 'kill(%s)' % f if os.path.isfile(f): os.remove(f) elif os.path.isdir(f): rmdir(f) | def kill(f): 'remove directory or file unconditionally' if os.path.isfile(f): os.remove(f) elif os.path.isdir(f): rmdir(f) elif '*' in f: map(kill,glob.glob(f)) |
if os.path.isdir(dst): dst = os.path.join(dst,os.path.basename(src)) if os.path.isfile(dst): kill(dst) if os.path.isfile(src): shutil.copy2(src,dst) elif os.path.isdir(src): shutil.copyTree(src,dst) elif '*' in src: map(lambda f,dst=dst: copy(f,dst),glob.glob(src)) | if '*' in src: map(lambda f,dst=dst: copy(f,dst),glob.glob(src)) else: if os.path.isdir(dst): dst = os.path.join(dst,os.path.basename(src)) if verbose>=2: print 'copy(%s,%s)' % (src,dst) if os.path.isfile(src): remove(dst) shutil.copy2(src,dst) elif os.path.isdir(src): shutil.copyTree(src,dst) | def copy(src,dst): if os.path.isdir(dst): dst = os.path.join(dst,os.path.basename(src)) if os.path.isfile(dst): kill(dst) if os.path.isfile(src): shutil.copy2(src,dst) elif os.path.isdir(src): shutil.copyTree(src,dst) elif '*' in src: map(lambda f,dst=dst: copy(f,dst),glob.glob(src)) |
genAll()(quiet='-s') | genAll()(verbose=verbose) os.chdir(dst) | def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) rmdir(cvsdir) rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%s@cvs.reportlab.sourceforge.net:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,... |
copy(os.path.join(dst,'*.pdf'),htmldir) | copy('*.pdf',htmldir) | def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) rmdir(cvsdir) rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%s@cvs.reportlab.sourceforge.net:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,... |
g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor)) return g | strokeColor,strokeWidth,fillColor=self.strokeColor, self.strokeWidth, self.fillColor if (strokeWidth and strokeColor) or fillColor: g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor)) return g else: return None | def makeBackground(self): g = Group() g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor)) return g |
encUsed = 'MacRomanEncoding' | encUsed = 'StandardEncoding' | def MakeType1Fonts(encoding): "returns a list of all the standard font objects" fonts = [] pos = 1 for fontname in StandardEnglishFonts: #Symbol is almost empty in WinAnsi, no choice! if fontname in ['Symbol', 'ZapfDingbats']: encUsed = 'MacRomanEncoding' else: encUsed = encoding font = PDFType1Font('F'+str(pos), fontn... |
g.draw() | def demo(self): D = Drawing(100, 100) | |
if self.width < 0: | if self.width < 0 and self.height > 0: | def _flipRectCorners(self): "Flip rectangle's corners if width or height is negative." if self.width < 0: self.x = self.x + self.width self.width = -self.width if self.orientation == 'vertical': self.fillColorStart, self.fillColorEnd = self.fillColorEnd, self.fillColorStart |
if self.height < 0: | elif self.height < 0 and self.width > 0: | def _flipRectCorners(self): "Flip rectangle's corners if width or height is negative." if self.width < 0: self.x = self.x + self.width self.width = -self.width if self.orientation == 'vertical': self.fillColorStart, self.fillColorEnd = self.fillColorEnd, self.fillColorStart |
r, g, b = c0.red, c0.green, c0.green | r, g, b = c0.red, c0.green, c0.blue | def draw(self): # general widget bits group = Group() |
sr.x = x+s | sr.x = x | def test(): D = Drawing(450, 650) d = 80 s = 60 for row in range(10): y = 530 - row*d if row == 0: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.width = s g.height = s g.useRects = 0 g.useLines = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() ... |
sr.width = -s | sr.width = s | def test(): D = Drawing(450, 650) d = 80 s = 60 for row in range(10): y = 530 - row*d if row == 0: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.width = s g.height = s g.useRects = 0 g.useLines = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() ... |
for k in ['gif','tiff']: | for k in ['gif','tiff', 'png', 'jpg']: | def test(): #grab all drawings from the test module and write out. #make a page of links in HTML to assist viewing. import os from reportlab.graphics import testshapes drawings = [] if not os.path.isdir('pmout'): os.mkdir('pmout') htmlTop = """<html><head><title>renderGD output results</title></head> <body> <h1>renderP... |
y = rowpos + (cellstyle.bottomPadding + rowheight-cellstyle.topPadding+(n-1)*leading)/2.0 | y = rowpos + (cellstyle.bottomPadding + rowheight-cellstyle.topPadding+n*leading)/2.0 - fontsize | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
from java.io import File fp = File(fileName) | fp = open(fileName,'rb') | def __init__(self, fileName): if not haveImages: warnOnce('Imaging Library not available, unable to import bitmaps') return #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._d... |
a((rgb>>16)&0xff) a((rgb>>8)&0xff) | a(chr((rgb>>16)&0xff)) a(chr((rgb>>8)&0xff)) | def getRGBData(self): "Return byte array of RGB data as string" if self._data is None: if sys.platform[0:4] == 'java': import jarray from java.awt.image import PixelGrabber width, height = self.getSize() buffer = jarray.zeros(width*height, 'i') pg = PixelGrabber(self._image, 0,0,width,height,buffer,0,width) pg.grabPixe... |
space_available = maxWidth - (currentWidth + spaceWidth + wordWidth) if space_available > 0 or len(cLine)==0: | newWidth = currentWidth + spaceWidth + wordWidth if newWidth<=maxWidth or len(cLine)==0: | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word li... |
currentWidth = currentWidth + spaceWidth + wordWidth | currentWidth = newWidth | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word li... |
space_available = maxWidth - (currentWidth + spaceWidth + wordWidth) if space_available > 0 or n==0: | if wordWidth>0: newWidth = currentWidth + spaceWidth + wordWidth else: newWidth = currentWidth if newWidth<=maxWidth or n==0: | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word li... |
I.drawWidth = 9.25*inch | def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2,... | |
self.setFillColorCMYK(self, aColor[0], aColor[1], aColor[2], aColor[3]) | self.setFillColorCMYK(aColor[0], aColor[1], aColor[2], aColor[3]) | def setFillColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if isinstance(aColor, CMYKColor): c,m,y,k = (aColor.cyan, aColor.magenta, aColor.yellow, aColor.black) self._fillColorCMYK = (c, m, y, k) self._code.append('%s k' % fp_str(c, m, y, k)) elif isinstance(aColor, Color): #... |
self.setStrokeColorCMYK(self, aColor[0], aColor[1], aColor[2], aColor[3]) | self.setStrokeColorCMYK(aColor[0], aColor[1], aColor[2], aColor[3]) | def setStrokeColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if isinstance(aColor, CMYKColor): c,m,y,k = (aColor.cyan, aColor.magenta, aColor.yellow, aColor.black) self._strokeColorCMYK = (c, m, y, k) self._code.append('%s K' % fp_str(c, m, y, k)) elif isinstance(aColor, Color... |
self.setFillColor(toColor(aColor)) | self.setStrokeColor(toColor(aColor)) | def setStrokeColor(self, aColor): """Takes a color object, allowing colors to be referred to by name""" if isinstance(aColor, CMYKColor): c,m,y,k = (aColor.cyan, aColor.magenta, aColor.yellow, aColor.black) self._strokeColorCMYK = (c, m, y, k) self._code.append('%s K' % fp_str(c, m, y, k)) elif isinstance(aColor, Color... |
after he had sacked the famous town of Troy. Many cities did he visit, | after</font> he had sacked the famous town of Troy. Many cities did he visit, | def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """ |
of Jove, from whatsoever source you may know them.</font> | of Jove, from whatsoever source you may know them. | def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """ |
self.canv.translate(nudge, 0) | if DO_NUDGE: self.canv.translate(nudge, 0) OLD_DO_NUDGE = DO_NUDGE DO_NUDGE = 0 | def draw(self): nudge = 0.5 * (self.availWidth - self._width) self.canv.translate(nudge, 0) self._drawBkgrnd() self._drawLines() for row, rowstyle, rowpos, rowheight in map(None, self._cellvalues, self._cellStyles, self._rowpositions[1:], self._rowHeights): for cellval, cellstyle, colpos, colwidth in map(None, row, row... |
num = ((85L**4) * c1) + ((85**3) * c2) + ((85**2) * c3) + (85*c4) + c5 | num = (((85*c1+c2)*85+c3)*85+c4)*85L + (c5 +(0,0,0xFFFFFF,0xFFFF,0xFF)[remainder_size]) | def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream'... |
lastword = chr(b1+1) | lastword = chr(b1) | def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream'... |
lastword = chr(b1) + chr(b2+1) | lastword = chr(b1) + chr(b2) | def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream'... |
lastword = chr(b1) + chr(b2) + chr(b3+1) | lastword = chr(b1) + chr(b2) + chr(b3) | def _AsciiBase85Decode(input): """This is not used - Acrobat Reader decodes for you - but a round trip is essential for testing.""" outstream = cStringIO.StringIO() #strip all whitespace stripped = string.join(string.split(input),'') #check end assert stripped[-2:] == '~>', 'Invalid terminator for Ascii Base 85 Stream'... |
a = angle * 180 / pi | a = angle * pi/180 | def skewX(angle): a = angle * 180 / pi return (1, 0, tan(a), 1, 0, 0) |
a = angle * 180 / pi | a = angle * pi/180 | def skewY(angle): a = angle * 180 / pi return (1, tan(a), 0, 1, 0, 0) |
y = y+cellval[0].getSpaceBefore() | if cellval: y += cellval[0].getSpaceBefore() | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
y = y - v.getSpaceBefore() y = y - h | y -= v.getSpaceBefore() y -= h | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
y = y - v.getSpaceAfter() | y -= v.getSpaceAfter() | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
y = y-leading | y -= leading | def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontn... |
isFile = getattr(filename,'write',None) if isFile: hasSeek = getattr(filename,'seek',None) if hasSeek: fLoc = filename.tell() else: class _DUMMYFILE: def __init__(self,filename): self._filename = filename def write(self,bytes): pass def close(self): pass filename = _DUMMYFILE(filename) | self._doSave = 0 | def multiBuild(self, story, filename=None, canvasmaker=canvas.Canvas, maxPasses = 10): """Makes multiple passes until all indexing flowables are happy.""" self._indexingFlowables = [] #scan the story and keep a copy for thing in story: if thing.isIndexing(): self._indexingFlowables.append(thing) #print 'scanned story, ... |
if passes and isFile and hasSeek: filename.seek(fLoc) | def close(self): pass | |
if isFile and not hasSeek: filename = filename._filename | self._doSave = 0 self.canv.save() | def close(self): pass |
w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPadding) | y = self.y p = self.bottomMargin + self.bottomPadding w, h = drawable.wrap(self.width, y - p ) | def add(self, drawable): """ Draws the object at the current position. Returns 1 if successful, 0 if it would not fit. Raises a LayoutError if the object is too wide, or if it is too high for a totally empty frame, to avoid infinite loops""" w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPaddi... |
if self.y - h < (self.bottomMargin - self.bottomPadding): | y = y - h if y < p: | def add(self, drawable): """ Draws the object at the current position. Returns 1 if successful, 0 if it would not fit. Raises a LayoutError if the object is too wide, or if it is too high for a totally empty frame, to avoid infinite loops""" w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPaddi... |
drawable.drawOn(self.canvas, self.x, self.y - h) self.y = self.y - h | drawable.drawOn(self.canvas, self.x, y) self.y = y | def add(self, drawable): """ Draws the object at the current position. Returns 1 if successful, 0 if it would not fit. Raises a LayoutError if the object is too wide, or if it is too high for a totally empty frame, to avoid infinite loops""" w, h = drawable.wrap(self.width, self.y - self.bottomMargin - self.bottomPaddi... |
if not (categoryNames is None): | if categoryNames is not None: | def makeTickLabels(self): g = Group() |
s.append('%0.2f' % i) | s.append('%0.6f' % i) | def fp_str(*a): if len(a)==1 and type(a[0]) in SeqTypes: a = a[0] s = [] for i in a: s.append('%0.2f' % i) return string.join(s) |
self._x = x * 1.0 self._y = y * 1.0 self._length = length * 1.0 def configure(self, multiSeries): self._catCount = len(multiSeries[0]) self._barWidth = self._length / (self._catCount or 1) | self._x = x self._y = y self._length = length def configure(self, multiSeries,barWidth=None): self._catCount = max(map(len,multiSeries)) self._barWidth = barWidth or (self._length/float(self._catCount or 1)) | def setPosition(self, x, y, length): # ensure floating point self._x = x * 1.0 self._y = y * 1.0 self._length = length * 1.0 |
__version__ = '$Id: ttfonts.py,v 1.21 2004/03/23 16:18:29 rgbecker Exp $' | __version__ = '$Id: ttfonts.py,v 1.22 2004/04/05 14:17:29 rgbecker Exp $' | def getSubsetInternalName(self, subset, doc): '''Returns the name of a PDF Font object corresponding to a given subset of this dynamic font. Use this function instead of PDFDocument.getInternalFontName.''' |
return '0X%8.8X' % i | return '0X%8.8X' % (long(i)&0xFFFFFFFFL) try: add32 = _rl_accel.add32 except: if sys.hexversion>=0x02030000: def add32(x, y): "Calculate (x + y) modulo 2**32" return _L2U32((long(x)+y) & 0xffffffffL) else: def add32(x, y): "Calculate (x + y) modulo 2**32" lo = (x & 0xFFFF) + (y & 0xFFFF) hi = (x >> 16) + (y >> 16) + (l... | def hex32(i): return '0X%8.8X' % i |
lo = (sum & 0xFFFF) + (n & 0xFFFF) hi = (sum >> 16) + (n >> 16) + (lo >> 16) sum = (hi << 16) | (lo & 0xFFFF) | sum = add32(sum,n) | def calcChecksum(data): """Calculates PDF-style checksums""" if len(data)&3: data = data + (4-(len(data)&3))*"\0" sum = 0 for n in unpack(">%dl" % (len(data)>>2), data): lo = (sum & 0xFFFF) + (n & 0xFFFF) hi = (sum >> 16) + (n >> 16) + (lo >> 16) sum = (hi << 16) | (lo & 0xFFFF) return sum |
try: add32 = _rl_accel.add32 except: def add32(x, y): "Calculate (x + y) modulo 2**32" lo = (x & 0xFFFF) + (y & 0xFFFF) hi = (x >> 16) + (y >> 16) + (lo >> 16) return (hi << 16) | (lo & 0xFFFF) del _rl_accel | del _rl_accel, sys | def calcChecksum(data): """Calculates PDF-style checksums""" if len(data)&3: data = data + (4-(len(data)&3))*"\0" sum = 0 for n in unpack(">%dl" % (len(data)>>2), data): lo = (sum & 0xFFFF) + (n & 0xFFFF) hi = (sum >> 16) + (n >> 16) + (lo >> 16) sum = (hi << 16) | (lo & 0xFFFF) return sum |
import time | def __init__(self, normalDate=None): """ Accept 1 of 4 values to initialize a NormalDate: 1. None - creates a NormalDate for the current day 2. integer in yyyymmdd format 3. string in yyyymmdd format 4. tuple in (yyyy, mm, dd) - localtime/gmtime can also be used """ if normalDate is None: import time self.setNormalDate... | |
elif tn in _SeqTypes: | elif tn in _DateSeqTypes: | def setNormalDate(self, normalDate): """ accepts date as scalar string/integer (yyyymmdd) or tuple (year, month, day, ...)""" tn=type(normalDate) if tn is IntType: self.normalDate = normalDate elif tn is StringType: try: self.normalDate = int(normalDate) except: m = _iso_re.match(normalDate) if m: self.setNormalDate(m.... |
et = ETriangle0() | et = RTriangle0() | def demo(self): D = shapes.Drawing(200, 100) et = ETriangle0() et.x=50 et.y=0 et.draw() D.add(et) labelFontSize = 10 D.add(shapes.String(et.x+(et.size/2),(et.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
D = shapes.Drawing(200, 200) | D = shapes.Drawing(200, 100) | def demo(self): D = shapes.Drawing(200, 200) labelFontSize = 10 cb = Crossbox0() cb.x=50 cb.y=0 cb.draw() D.add(cb) D.add(shapes.String(cb.x+(cb.size/2),(cb.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
na = NoSmoking0() na.x=50 na.y=0 na.draw() D.add(na) labelFontSize = 10 D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), | ns = NoSmoking0() ns.x=50 ns.y=0 ns.draw() D.add(ns) labelFontSize = 10 D.add(shapes.String(ns.x+(ns.size/2),(ns.y-(1.2*labelFontSize)), | def demo(self): D = shapes.Drawing(200, 100) na = NoSmoking0() na.x=50 na.y=0 na.draw() D.add(na) labelFontSize = 10 D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
yn.x = 50 yn.y = 0 yn.testValue = 1 | yn.x = 15 yn.y = 25 yn.size = 70 yn.testValue = 0 | def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 50 yn.y = 0 yn.testValue = 1 yn.draw() D.add(yn) labelFontSize = 10 D.add(shapes.String(yn.x+(yn.size/2),(yn.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
labelFontSize = 10 | yn2 = YesNo0() yn2.x = 120 yn2.y = 25 yn2.size = 70 yn2.testValue = 1 yn2.draw() D.add(yn2) labelFontSize = 8 | def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 50 yn.y = 0 yn.testValue = 1 yn.draw() D.add(yn) labelFontSize = 10 D.add(shapes.String(yn.x+(yn.size/2),(yn.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
a2 = ArrowOne0() | a2 = ArrowTwo0() | def demo(self): D = shapes.Drawing(200, 100) a2 = ArrowOne0() a2.x=50 a2.y=0 a2.draw() D.add(a2) labelFontSize = 10 D.add(shapes.String(a2.x+(a2.size/2),(a2.y-(1.2*labelFontSize)), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D |
absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) | sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | def format(self, num): # positivize the numbers absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) if self.thousandSeparator is not None: strNew = '' while strInt: left, right = strInt[0:-3], strInt[-3:] if left == '': #strNew = self.thousan... |
places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places pattern = '%0.' + str(places) + 'f' strFrac = sep + (pattern % fracPart)[2:] | strFrac = sep + strFrac | def format(self, num): # positivize the numbers absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) if self.thousandSeparator is not None: strNew = '' while strInt: left, right = strInt[0:-3], strInt[-3:] if left == '': #strNew = self.thousan... |
if sign == -1: strBody = '-' + strBody | if sign: strBody = '-' + strBody | def format(self, num): # positivize the numbers absNum = abs(num) if absNum == num: sign = 1 else: sign = -1 intPart, fracPart = divmod(absNum, 1.0) strInt = str(long(intPart)) if self.thousandSeparator is not None: strNew = '' while strInt: left, right = strInt[0:-3], strInt[-3:] if left == '': #strNew = self.thousan... |
text = join(tx.lines[i][1]) | text = join(tx.XtraState.lines[i][1]) | def _do_under_lines(i, t_off, tx): y = tx.XtraState.cur_y - i*tx.XtraState.style.leading - tx.XtraState.f.fontSize/8.0 # 8.0 factor copied from para.py text = join(tx.lines[i][1]) textlen = tx._canvas.stringWidth(text, tx._fontname, tx._fontsize) tx._canvas.line(t_off, y, t_off+textlen, y) |
def cvs_checkout(d,u): | def cvs_checkout(d): | def cvs_checkout(d,u): recursive_rmdir(d) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) have_tmp = os.path.isdir(_tmp) os.makedirs(d) os.environ['HOME']=d os.environ['CVSROOT']=':pserver:anonymous@cvs.reportlab.sourceforge.net:/cvsroot/reportlab' os.chdir(d) f = open(os.... |
rawInterval = rawRange / min(self.maximumTicks-1,(float(self._length)/self.minimumTickSpacing )) | rawInterval = rawRange / min(float(self.maximumTicks-1),(float(self._length)/self.minimumTickSpacing )) | def _calcValueStep(self): '''Calculate _valueStep for the axis or get from valueStep.''' |
if self.inObject not in ["form", None]: raise ValueError, "can't go in form already in object %s" % self.inObject | def inForm(self): """specify that we are in a form xobject (disable page features, etc)""" if self.inObject not in ["form", None]: raise ValueError, "can't go in form already in object %s" % self.inObject self.inObject = "form" # don't need to do anything else, I think... | |
self.initial = initial | self._initial = initial | def __init__(self,validate=None,desc=None,initial=None, **kw): self.validate = validate or isAnything self.desc = desc self.initial = initial for k,v in kw.items(): setattr(self,k,v) |
self._cellvalues = data | def __init__(self, data, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1, emptyTableAction=None): self.hAlign = 'CENTER' self.vAlign = 'MIDDLE' if type(data) not in _SeqTypes: raise ValueError, "%s invalid data type" % self.identity() self._nrows = nrows = len(data) self._cellvalue... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.