rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
if fragment and fragment[0] in WHITESPACE: | if fragment and fragment[0] in whitespace: | def handleSpecialCharacters(engine, text, program=None): from paraparser import greeks, symenc from string import whitespace standard={'lt':'<', 'gt':'>', 'amp':'&'} # add space prefix if space here if text[0:1] in whitespace: program.append(" ") #print "handling", repr(text) # shortcut if 0 and "&" not in text: result = [] for x in text.split(): result.append(x+" ") if result: last = result[-1] if text[-1:] not in whitespace: result[-1] = last.strip() program.extend(result) return program if program is None: program = [] amptext = text.split("&") first = 1 lastfrag = amptext[-1] for fragment in amptext: if not first: # check for special chars semi = fragment.find(";") if semi>0: name = fragment[:semi] if name[0]=='#': try: if name[1] == 'x': n = atoi(name[2:], 16) else: n = atoi(name[1:]) except atoi_error: n = -1 if 0<=n<=255: fragment = chr(n)+fragment[semi+1:] elif symenc.has_key(n): fragment = fragment[semi+1:] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(symenc[n]) engine.shiftfont(program, face=f) if fragment and fragment[0] in WHITESPACE: program.append(" ") # follow with a space else: fragment = "&"+fragment elif standard.has_key(name): fragment = standard[name]+fragment[semi+1:] elif greeks.has_key(name): fragment = fragment[semi+1:] greeksub = greeks[name] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(greeksub) engine.shiftfont(program, face=f) if fragment and fragment[0] in WHITESPACE: program.append(" ") # follow with a space else: # add back the & fragment = "&"+fragment else: # add back the & fragment = "&"+fragment # add white separated components of fragment followed by space sfragment = fragment.split() for w in sfragment[:-1]: program.append(w+" ") # does the last one need a space? if sfragment and fragment: # reader 3 used to go nuts if you don't special case the last frag, but it's fixed? if fragment[-1] in WHITESPACE: # or fragment==lastfrag: program.append( sfragment[-1]+" " ) else: last = sfragment[-1].strip() if last: #print "last is", repr(last) program.append( last ) first = 0 #print "HANDLED", program return program |
if fragment[-1] in WHITESPACE: | if fragment[-1] in whitespace: | def handleSpecialCharacters(engine, text, program=None): from paraparser import greeks, symenc from string import whitespace standard={'lt':'<', 'gt':'>', 'amp':'&'} # add space prefix if space here if text[0:1] in whitespace: program.append(" ") #print "handling", repr(text) # shortcut if 0 and "&" not in text: result = [] for x in text.split(): result.append(x+" ") if result: last = result[-1] if text[-1:] not in whitespace: result[-1] = last.strip() program.extend(result) return program if program is None: program = [] amptext = text.split("&") first = 1 lastfrag = amptext[-1] for fragment in amptext: if not first: # check for special chars semi = fragment.find(";") if semi>0: name = fragment[:semi] if name[0]=='#': try: if name[1] == 'x': n = atoi(name[2:], 16) else: n = atoi(name[1:]) except atoi_error: n = -1 if 0<=n<=255: fragment = chr(n)+fragment[semi+1:] elif symenc.has_key(n): fragment = fragment[semi+1:] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(symenc[n]) engine.shiftfont(program, face=f) if fragment and fragment[0] in WHITESPACE: program.append(" ") # follow with a space else: fragment = "&"+fragment elif standard.has_key(name): fragment = standard[name]+fragment[semi+1:] elif greeks.has_key(name): fragment = fragment[semi+1:] greeksub = greeks[name] (f,b,i) = engine.shiftfont(program, face="symbol") program.append(greeksub) engine.shiftfont(program, face=f) if fragment and fragment[0] in WHITESPACE: program.append(" ") # follow with a space else: # add back the & fragment = "&"+fragment else: # add back the & fragment = "&"+fragment # add white separated components of fragment followed by space sfragment = fragment.split() for w in sfragment[:-1]: program.append(w+" ") # does the last one need a space? if sfragment and fragment: # reader 3 used to go nuts if you don't special case the last frag, but it's fixed? if fragment[-1] in WHITESPACE: # or fragment==lastfrag: program.append( sfragment[-1]+" " ) else: last = sfragment[-1].strip() if last: #print "last is", repr(last) program.append( last ) first = 0 #print "HANDLED", program return program |
stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, joiner) | L = map(_lineClean, split(text, '\n')) return join(L, joiner) def setXPos(tx,dx): if dx>1e-6 or dx<-1e-6: tx.setXPos(dx) | def cleanBlockQuotedText(text,joiner=' '): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, joiner) |
tx.setXPos(offset) tx._textOut(string.join(words),1) | setXPos(tx,offset) tx._textOut(join(words),1) setXPos(tx,-offset) | def _leftDrawParaLine( tx, offset, extraspace, words, last=0): tx.setXPos(offset) tx._textOut(string.join(words),1) |
tx.setXPos(m) tx._textOut(string.join(words),1) | setXPos(tx,m) tx._textOut(join(words),1) setXPos(tx,-m) | def _centerDrawParaLine( tx, offset, extraspace, words, last=0): m = offset + 0.5 * extraspace tx.setXPos(m) tx._textOut(string.join(words),1) |
tx.setXPos(m) tx._textOut(string.join(words),1) | setXPos(tx,m) tx._textOut(join(words),1) setXPos(tx,-m) | def _rightDrawParaLine( tx, offset, extraspace, words, last=0): m = offset + extraspace tx.setXPos(m) tx._textOut(string.join(words),1) |
tx.setXPos(offset) text = string.join(words) | setXPos(tx,offset) text = join(words) | def _justifyDrawParaLine( tx, offset, extraspace, words, last=0): tx.setXPos(offset) text = string.join(words) if last: #last one, left align tx._textOut(text,1) else: nSpaces = len(words)-1 if nSpaces: tx.setWordSpace(extraspace / float(nSpaces)) tx._textOut(text,1) tx.setWordSpace(0) else: tx._textOut(text,1) |
tx.setXPos(offset) | setXPos(tx,offset) | def _leftDrawParaLineX( tx, offset, line, last=0): tx.setXPos(offset) _putFragLine(tx, line.words) |
tx.setXPos(m) | setXPos(tx,m) | def _centerDrawParaLineX( tx, offset, line, last=0): m = offset+0.5*line.extraSpace tx.setXPos(m) _putFragLine(tx, line.words) |
tx.setXPos(m) | setXPos(tx,m) | def _rightDrawParaLineX( tx, offset, line, last=0): m = offset+line.extraSpace tx.setXPos(m) _putFragLine(tx, line.words) |
tx.setXPos(offset) | def _justifyDrawParaLineX( tx, offset, line, last=0): if last: #last one, left align tx.setXPos(offset) _putFragLine(tx, line.words) else: tx.setXPos(offset) nSpaces = line.wordCount - 1 if nSpaces: tx.setWordSpace(line.extraSpace / float(nSpaces)) _putFragLine(tx, line.words) tx.setWordSpace(0) else: _putFragLine(tx, line.words) |
|
S = string.split(text,' ') | S = split(text,' ') | def _getFragWords(frags): ''' given a Parafrag list return a list of fragwords [[size, (f00,w00), ..., (f0n,w0n)],....,[size, (fm0,wm0), ..., (f0n,wmn)]] each pair f,w represents a style and some string each sublist represents a word ''' R = [] W = [] n = 0 for f in frags: text = f.text #del f.text # we can't do this until we sort out splitting # of paragraphs if text!='': S = string.split(text,' ') if S[-1]=='': del S[-1] if W!=[] and text[0] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 for w in S[:-1]: W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) W.insert(0,n) R.append(W) W = [] n = 0 w = S[-1] W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) if text[-1] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 elif hasattr(f,'cbDefn'): if W!=[]: W.insert(0,n) R.append(W) W = [] n = 0 R.append([0,(f,'')]) if W!=[]: W.insert(0,n) R.append(W) return R |
if bulletRight > style.firstLineIndent: | indent = style.leftIndent+style.firstLineIndent if bulletRight > indent: | def _handleBulletWidth(bulletText,style,maxWidths): '''work out bullet width and adjust maxWidths[0] if neccessary ''' if bulletText <> None: if type(bulletText) is StringType: bulletWidth = stringWidth( bulletText, style.bulletFontName, style.bulletFontSize) else: #it's a list of fragments bulletWidth = 0 for f in bulletText: bulletWidth = bulletWidth + stringWidth(f.text, f.fontName, f.fontSize) bulletRight = style.bulletIndent + bulletWidth if bulletRight > style.firstLineIndent: #..then it overruns, and we have less space available on line 1 maxWidths[0] = maxWidths[0] - (bulletRight - style.firstLineIndent) |
maxWidths[0] = maxWidths[0] - (bulletRight - style.firstLineIndent) | maxWidths[0] = maxWidths[0] - (bulletRight - indent) | def _handleBulletWidth(bulletText,style,maxWidths): '''work out bullet width and adjust maxWidths[0] if neccessary ''' if bulletText <> None: if type(bulletText) is StringType: bulletWidth = stringWidth( bulletText, style.bulletFontName, style.bulletFontSize) else: #it's a list of fragments bulletWidth = 0 for f in bulletText: bulletWidth = bulletWidth + stringWidth(f.text, f.fontName, f.fontSize) bulletRight = style.bulletIndent + bulletWidth if bulletRight > style.firstLineIndent: #..then it overruns, and we have less space available on line 1 maxWidths[0] = maxWidths[0] - (bulletRight - style.firstLineIndent) |
first_line_width = availWidth - self.style.firstLineIndent - self.style.rightIndent later_widths = availWidth - self.style.leftIndent - self.style.rightIndent | leftIndent = self.style.leftIndent first_line_width = availWidth - (leftIndent+self.style.firstLineIndent) - self.style.rightIndent later_widths = availWidth - leftIndent - self.style.rightIndent | def wrap(self, availWidth, availHeight): # work out widths array for breaking self.width = availWidth first_line_width = availWidth - self.style.firstLineIndent - self.style.rightIndent later_widths = availWidth - self.style.leftIndent - self.style.rightIndent self.blPara = self.breakLines([first_line_width, later_widths]) self.height = len(self.blPara.lines) * self.style.leading |
if style.firstLineIndent != style.leftIndent: | if style.firstLineIndent != 0: | def split(self,availWidth, availHeight): if len(self.frags)<=0: return [] |
style.firstLineIndent = style.leftIndent | style.firstLineIndent = 0 | def split(self,availWidth, availHeight): if len(self.frags)<=0: return [] |
maxWidth = maxWidths[lineno] | 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 |
|
words = hasattr(f,'text') and string.split(f.text, ' ') or f.words | words = hasattr(f,'text') and split(f.text, ' ') or f.words | 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 |
canvas.addLiteral('%% %s.drawPara' % _className(self)) | 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.""" |
|
offset = style.firstLineIndent - style.leftIndent | offset = style.firstLineIndent | 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.""" |
return string.join(plains, '') | return join(plains, '') | def getPlainText(self): """Convenience function for templates which want access to the raw text, without XML tags. """ plains = [] for frag in self.frags: plains.append(frag.text) return string.join(plains, '') |
image = PIL_Image.open(cStringIO.StringIO(str(logo.data))) (width, height) = image.size | image = ImageReader(cStringIO.StringIO(str(logo.data))) (width, height) = image.getSize() | def getImageFromZODB(self, name) : """Retrieves an Image from the ZODB, converts it to PIL, and makes it 0.75 inch high. """ try : # try to get it from ZODB logo = getattr(self.parent.context, name) except AttributeError : # not found ! return None |
print vm, vM, y, scale, self.valueAxis._y, self.valueAxis._valueMin, self._findMinMaxValues()[0] | def calcBarPositions(self): """Works out where they go. default vertical. |
|
version="1.15.3", | version="1.17", licence="BSD license, Copyright (c) 2000-2003, ReportLab Inc.", | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
package_dir = {'': '..'}, | package_dir = {'reportlab': '.'}, | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
'reportlab.docs.images', | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
|
'reportlab.fonts', | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
|
], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], | 'reportlab.test', 'reportlab.tools', 'reportlab.tools.docco', 'reportlab.tools.py2pdf', 'reportlab.tools.pythonpoint', 'reportlab.tools.pythonpoint.demos', 'reportlab.tools.pythonpoint.styles', ], data_files = [(pjoin(package_path, 'docs', 'images'), ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), (pjoin(package_path, 'fonts'), ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf']), (package_path, ['README', 'changes', 'license.txt']), (pjoin(package_path, 'test'), ['test/pythonpowered.gif',]), (pjoin(package_path, 'lib'), ['lib/hyphen.mashed',]), ], | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
ext_modules = [Extension( '_rl_accel', | ext_modules = [Extension( 'reportlab/lib/_rl_accel', | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
Extension( 'sgmlop', | Extension( 'reportlab/lib/sgmlop', | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
Extension( 'pyHnj', | Extension( 'reportlab/lib/pyHnj', | def run(): LIBS = [] setup( name="Reportlab", version="1.15.3", description="Reportlab PDF generation tools", author="The boys from SW19", author_email="[email protected]", url="http://www.reportlab.com/", package_dir = {'': '..'}, packages=[ # include anything with an __init__ 'reportlab', 'reportlab.docs', 'reportlab.docs.graphguide', 'reportlab.docs.images', 'reportlab.docs.reference', 'reportlab.docs.userguide', 'reportlab.fonts', 'reportlab.graphics', 'reportlab.graphics.charts', 'reportlab.graphics.widgets', 'reportlab.lib', 'reportlab.pdfbase', 'reportlab.pdfgen', 'reportlab.platypus', ], data_files = [('docs/images', ['docs/images/Edit_Prefs.gif', 'docs/images/Python_21.gif', 'docs/images/Python_21_HINT.gif', 'docs/images/fileExchange.gif', 'docs/images/jpn.gif', 'docs/images/jpnchars.jpg', 'docs/images/lj8100.jpg', 'docs/images/replogo.a85', 'docs/images/replogo.gif']), ('fonts', ['fonts/LeERC___.AFM', 'fonts/LeERC___.PFB', 'fonts/luxiserif.ttf', 'fonts/rina.ttf'] )], ext_modules = [Extension( '_rl_accel', ['lib/_rl_accel.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', ['lib/sgmlop.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', ['lib/pyHnjmodule.c', 'lib/hyphen.c', 'lib/hnjalloc.c'], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ], ) |
unittest.TextTestRunner().run(makeSuite()) | if '-debug' in sys.argv: run() else: unittest.TextTestRunner().run(makeSuite()) | def makeSuite(): suite = unittest.TestSuite() suite.addTest(PlatypusTestCase('test1')) return suite |
deltas['transform'] = [1,0,0,1,x,y] | deltas['transform'] = canvas._baseCTM[0:4]+(x,y) | def draw(self, drawing, canvas, x=0, y=0, showBoundary=rl_config.showBoundary): """This is the top level function, which draws the drawing at the given location. The recursive part is handled by drawNode.""" #stash references for ease of communication self._canvas = canvas canvas.__dict__['_drawing'] = self._drawing = drawing try: if showBoundary: canvas.rect(x, y, drawing.width, drawing.height) canvas.saveState() deltas = STATE_DEFAULTS.copy() deltas['transform'] = [1,0,0,1,x,y] self._tracker.push(deltas) self.applyState() self.drawNode(drawing) self.pop() canvas.restoreState() finally: #remove any circular references del self._canvas, self._drawing, canvas._drawing |
w = int(d.width+0.5) h = int(d.height+0.5) | w = int(d.width*dpi/72.0+0.5) h = int(d.height*dpi/72.0+0.5) | def drawToPMCanvas(d, dpi=72, bg=0xffffff, configPIL=None, showBoundary=rl_config.showBoundary): w = int(d.width+0.5) h = int(d.height+0.5) c = PMCanvas(w, h, dpi=dpi, bg=bg, configPIL=configPIL) draw(d, c, 0, 0) return c |
lineBreakPrev = False | def breakLines(self, width): """ Returns a broken line structure. There are two cases |
|
endLine = (newWidth>maxWidth and n>0) or (lineBreak and (currentWidth>0 or lineBreakPrev)) | endLine = (newWidth>maxWidth and n>0) or lineBreak | def breakLines(self, width): """ Returns a broken line structure. There are two cases |
lineBreakPrev = lineBreak | def breakLines(self, width): """ Returns a broken line structure. There are two cases |
|
while hasattr(words[i],'cbDefn'): i = i-1 | while hasattr(words[i],'cbDefn'): i -= 1 | def breakLines(self, width): """ Returns a broken line structure. There are two cases |
if lineBreak and not len(words): | if lineBreak: | def breakLines(self, width): """ Returns a broken line structure. There are two cases |
del g.lineBreak | def breakLines(self, width): """ Returns a broken line structure. There are two cases |
|
print "frag%d: '%s'" % (l, frags[l].text) | print "frag%d: '%s' %s" % (l, frags[l].text,' '.join(['%s=%s' % (k,getattr(frags[l],k)) for k in frags[l].__dict__ if k!=text])) | def dumpParagraphFrags(P): print 'dumpParagraphFrags(<Paragraph @ %d>) minWidth() = %.2f' % (id(P), P.minWidth()) frags = P.frags n =len(frags) for l in range(n): print "frag%d: '%s'" % (l, frags[l].text) |
w = [] for frag in self.blPara.lines: w.append(self.width - frag.extraSpace) return w | if self.blPara.kind: func = lambda frag, w=self.width: w - frag.extraSpace else: func = lambda frag, w=self.width: w - frag[0] return map(func,self.blPara.lines) | def getActualLineWidths0(self): """Convenience function; tells you how wide each line actually is. For justified styles, this will be the same as the wrap width; for others it might be useful for seeing if paragraphs will fit in spaces.""" assert hasattr(self, 'width'), "Cannot call this method before wrap()" w = [] for frag in self.blPara.lines: w.append(self.width - frag.extraSpace) return w |
R.extend(unicode2T1(utext[i0:il],fonts)) | R.extend(_py_unicode2T1(utext[i0:il],fonts)) | def _py_unicode2T1(utext,fonts): '''return a list of (font,string) pairs representing the unicode text''' #print 'unicode2t1(%s, %s): %s' % (utext, fonts, type(utext)) #if type(utext) R = [] font, fonts = fonts[0], fonts[1:] enc = font.encName if 'UCS-2' in enc: enc = 'UTF16' while utext: try: R.append((font,utext.encode(enc))) break except UnicodeEncodeError, e: i0, il = e.args[2:4] if i0: R.append((font,utext[:i0].encode(enc))) if fonts: R.extend(unicode2T1(utext[i0:il],fonts)) else: R.append((_notdefFont,_notdefChar*(il-i0))) utext = utext[il:] return R |
from rl_accel import getFontU as getFont | from _rl_accel import getFontU as getFont | def _py_getFont(fontName): """Lazily constructs known fonts if not found. Names of form 'face-encoding' will be built if face and encoding are known. Also if the name is just one of the standard 14, it will make up a font in the default encoding.""" try: return _fonts[fontName] except KeyError: return findFontAndRegister(fontName) |
self._addNABarLabel(g,rowNo,colNo,x,y,width,height) | self._addNABarLabel(lg,rowNo,colNo,x,y,width,height) | def makeBars(self): g = Group() |
self._addBarLabel(g,rowNo,colNo,x,y,width,height) | self._addBarLabel(lg,rowNo,colNo,x,y,width,height) g.add(lg) | def makeBars(self): g = Group() |
outDir = join(rlDir, 'test') pdf = join(outDir, 'pythonpoint.pdf') | datafilename = 'pythonpoiint.pdf' if isCompactDistro(): cwd = None outDir = '.' xml = open_for_read(xml) else: outDir = join(rlDir, 'test') cwd = os.getcwd() os.chdir(join(ppDir, 'demos')) pdf = join(outDir, datafilename) | def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml." |
cwd = os.getcwd() os.chdir(join(ppDir, 'demos')) pythonpoint.process(xml, outDir=outDir, verbose=0) os.chdir(cwd) | pythonpoint.process(xml, outDir=outDir, verbose=0, datafilename=datafilename) if cwd: os.chdir(cwd) | def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml." |
def _doNothing(drawables, doc): "Dummy callback for onFirstPage and onNewPage" pass | def reset(self, category): self.dict[category] = 0 |
|
self.onFirstPage = self.doNothing self.onNewPage = self.doNothing def doNothing(self, drawables, doc): "Dummy callback for onFirstPage and onNewPage" pass | self.onFirstPage = _doNothing self.onNewPage = _doNothing | def __init__(self, filename, pagesize, showBoundary=0): self.filename = filename self.pagesize = pagesize self.showBoundary=showBoundary #sensibel defaults; override if you wish self.leftMargin = inch self.bottomMargin = inch self.rightMargin = self.pagesize[0] - inch self.topMargin = self.pagesize[1] - inch |
return filter(lambda x: x is not None, self._attrMap['kind']._enum) | return filter(lambda x: x is not None, self._attrMap['kind'].validate._enum) | def availableFlagNames(self): '''return a list of the things we can display''' return filter(lambda x: x is not None, self._attrMap['kind']._enum) |
projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) | pdir = py2pdf_dir cvsdir = os.path.join(groupdir,pdir) else: pdir = projdir | def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile) |
do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') | do_exec('%s czvf %s %s' % (tar, tarfile, pdir), 'tar creation') | def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile) |
do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') | do_exec('%s -ur %s %s' % (zip, zipfile, pdir), 'zip creation') | def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile) |
if self._atTop: s = flowable.getSpaceBefore() | if not self._atTop: s = flowable.getSpaceBefore() | def split(self,flowable,canv): '''Ask the flowable to split using up the available space.''' y = self._y p = self._y1p s = 0 if self._atTop: s = flowable.getSpaceBefore() flowable.canv = canv #some flowables might need this r = flowable.split(self._aW, y-p-s) del flowable.canv return r |
obj.contents.append(newChild) | a(newChild) | def expandUserNodes(self): """Return a new object which only contains primitive shapes.""" |
if k in self_contents: | if v in self_contents: | def _copyNamedContents(self,obj,aKeys=None,noCopy=('contents',)): from copy import copy self_contents = self.contents if not aKeys: aKeys = self._attrMap.keys() for (k, v) in self.__dict__.items(): if k in self_contents: pos = self_contents.index(v) setattr(obj, oldKey, obj.contents[pos]) elif k in aKeys and k not in noCopy: setattr(obj, k, copy(v)) |
setattr(obj, oldKey, obj.contents[pos]) | setattr(obj, k, obj.contents[pos]) | def _copyNamedContents(self,obj,aKeys=None,noCopy=('contents',)): from copy import copy self_contents = self.contents if not aKeys: aKeys = self._attrMap.keys() for (k, v) in self.__dict__.items(): if k in self_contents: pos = self_contents.index(v) setattr(obj, oldKey, obj.contents[pos]) elif k in aKeys and k not in noCopy: setattr(obj, k, copy(v)) |
ascent=getFont(fontName).face.ascent | ascent=getFont(fontName).face.ascent/1000. | def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t) |
if ext == '.pfb': | if string.lower(ext) == '.pfb': | def findT1File(self,ext='.pfb'): possible_exts = (string.lower(ext), string.upper(ext)) if hasattr(self,'pfbFileName'): r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if ext == '.pfb': for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r |
elif ext == '.afm': | elif string.lower(ext) == '.afm': | def findT1File(self,ext='.pfb'): possible_exts = (string.lower(ext), string.upper(ext)) if hasattr(self,'pfbFileName'): r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if ext == '.pfb': for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r |
possibles = glob.glob(dirname + os.sep + '*.afm') | possibles = glob.glob(dirname + os.sep + '*.[aA][fF][mM]') | def bruteForceSearchForAFM(faceName): """Looks in all AFM files on path for face with given name. Returns AFM file name or None. Ouch!""" import glob from reportlab.rl_config import T1SearchPath for dirname in T1SearchPath: if not os.path.isdir(dirname): continue possibles = glob.glob(dirname + os.sep + '*.afm') for possible in possibles: (topDict, glyphDict) = parseAFMFile(possible) if topDict['FontName'] == faceName: return possible return None |
codes = map(ord, text) | codes = map(ord, uText) | def stringWidth(self, text, size, encoding='utf-8'): "Calculate text width" width = self.face.getCharWidth w = 0 if type(text) is UnicodeType: codes = map(ord, text) else: uText = unicode(text, encoding) codes = map(ord, text) for code in codes: w = w + width(code) return 0.001 * w * size |
fileSuffix = '-graph.pdf' | fileSuffix = '.pdf' | def getFunctionBody(f, linesInFile): """Pass in the function object and the lines in the file. Since we will typically grab several things out of the same file. it extracts a multiline text block. Works with methods too.""" if hasattr(f, 'im_func'): #it's a method, drill down and get its function f = f.im_func extracted = [] firstLineNo = f.func_code.co_firstlineno - 1 startingIndent = indentLevel(linesInFile[firstLineNo]) extracted.append(linesInFile[firstLineNo]) #brackets = 0 for line in linesInFile[firstLineNo+1:]: ind = indentLevel(line) if ind <= startingIndent: break else: extracted.append(line) # we are not indented return string.join(extracted, '\n') # ??? usefulLines = lines[firstLineNo:lineNo+1] return string.join(usefulLines, '\n') |
if name == 'demo': PdfDocBuilder0.beginMethod(self, name, doc, sig) | pass | def beginMethod(self, name, doc, sig): if name == 'demo': PdfDocBuilder0.beginMethod(self, name, doc, sig) |
if name == 'demo': PdfDocBuilder0.endMethod(self, name, doc, sig) | pass | def endMethod(self, name, doc, sig): if name == 'demo': PdfDocBuilder0.endMethod(self, name, doc, sig) |
self._showWidgetDemoCode(widget) | def endClass(self, name, doc, bases): "Append a graphic demo of a widget at the end of a class." PdfDocBuilder0.endClass(self, name, doc, bases) |
|
class UmlPdfDocBuilder0(PdfDocBuilder0): "Document the skeleton of a Python module with UML class diagrams." fileSuffix = '-uml.pdf' def begin(self): styleSheet = getSampleStyleSheet() self.h1 = styleSheet['Heading1'] self.h2 = styleSheet['Heading2'] self.h3 = styleSheet['Heading3'] self.code = styleSheet['Code'] self.bt = styleSheet['BodyText'] self.story = [] self.classCompartment = '' self.methodCompartment = [] def beginModule(self, name, doc, imported): story = self.story h1, h2, h3, bt = self.h1, self.h2, self.h3, self.bt styleSheet = getSampleStyleSheet() bt1 = styleSheet['BodyText'] story.append(Paragraph(name, h1)) story.append(XPreformatted(doc, bt1)) if imported: story.append(Paragraph('Imported modules', h2)) for m in imported: story.append(Paragraph(m, bt1)) def beginClasses(self, names): h1, h2, h3, bt = self.h1, self.h2, self.h3, self.bt if names: self.story.append(Paragraph('Classes', h2)) def beginClass(self, name, doc, bases): self.classCompartment = '' self.methodCompartment = [] if bases: bases = map(lambda b:b.__name__, bases) self.classCompartment = '%s(%s)' % (name, join(bases, ', ')) else: self.classCompartment = name def endClass(self, name, doc, bases): h1, h2, h3, bt, code = self.h1, self.h2, self.h3, self.bt, self.code styleSheet = getSampleStyleSheet() bt1 = styleSheet['BodyText'] story = self.story classDoc = _reduceDocStringLength(doc) tsa = tableStyleAttributes = [] p = Paragraph('<b>%s</b>' % self.classCompartment, bt) p.style.alignment = TA_CENTER rows = [(p,)] lenRows = len(rows) tsa.append(('BOX', (0,0), (-1,lenRows-1), 0.25, colors.black)) for name, doc, sig in self.methodCompartment: nameAndSig = Paragraph('<b>%s</b>%s' % (name, sig), bt1) rows.append((nameAndSig,)) tsa.append(('BOX', (0,lenRows), (-1,-1), 0.25, colors.black)) t = Table(rows, (12*cm,)) tableStyle = TableStyle(tableStyleAttributes) t.setStyle(tableStyle) self.story.append(t) self.story.append(Spacer(1*cm, 1*cm)) def beginMethod(self, name, doc, sig): self.methodCompartment.append((name, doc, sig)) def beginFunctions(self, names): h1, h2, h3, bt = self.h1, self.h2, self.h3, self.bt if names: self.story.append(Paragraph('Functions', h2)) self.classCompartment = chr(171) + ' Module-Level Functions ' + chr(187) self.methodCompartment = [] def beginFunction(self, name, doc, sig): self.methodCompartment.append((name, doc, sig)) def endFunctions(self, names): h1, h2, h3, bt, code = self.h1, self.h2, self.h3, self.bt, self.code styleSheet = getSampleStyleSheet() bt1 = styleSheet['BodyText'] story = self.story if not names: return tsa = tableStyleAttributes = [] p = Paragraph('<b>%s</b>' % self.classCompartment, bt) p.style.alignment = TA_CENTER rows = [(p,)] lenRows = len(rows) tsa.append(('BOX', (0,0), (-1,lenRows-1), 0.25, colors.black)) for name, doc, sig in self.methodCompartment: nameAndSig = Paragraph('<b>%s</b>%s' % (name, sig), bt1) rows.append((nameAndSig,)) tsa.append(('BOX', (0,lenRows), (-1,-1), 0.25, colors.black)) t = Table(rows, (12*cm,)) tableStyle = TableStyle(tableStyleAttributes) t.setStyle(tableStyle) self.story.append(t) self.story.append(Spacer(1*cm, 1*cm)) | def beginFunction(self, name, doc, sig): bt = self.bt story = self.story story.append(Paragraph(name+sig, bt)) story.append(XPreformatted(doc, bt)) |
|
def documentModule0(path, builder=DocBuilder0()): | def documentModule0(path, builder=GraphPdfDocBuilder0()): | def documentModule0(path, builder=DocBuilder0()): """Generate documentation for one Python file in some format. This handles Python standard modules like string, custom modules on the Python search path like e.g. docpy as well as modules specified with their full path like C:/tmp/junk.py. The doc file will always be saved in the current directory with a basename equal to the module's name. """ cwd = os.getcwd() # Append directory to Python search path if we get one. dirName = os.path.dirname(path) if dirName: sys.path.append(dirName) # Remove .py extension from module name. if path[-3:] == '.py': modname = path[:-3] else: modname = path # Remove directory paths from module name. if dirName: modname = os.path.basename(modname) # Load the module. try: module = __import__(modname) except: print 'Failed to import %s.' % modname os.chdir(cwd) return # Do the real documentation work. s = ModuleSkeleton0() s.inspect(module) builder.write(s) # Remove appended directory from Python search path if we got one. if dirName: del sys.path[-1] os.chdir(cwd) |
def documentPackage0(path, builder=DocBuilder0()): | def documentPackage0(pathOrName, builder=GraphPdfDocBuilder0()): | def documentPackage0(path, builder=DocBuilder0()): """Generate documentation for one Python package in some format. Rigiht now, 'path' must be a filesystem path, later it will also be a package name whose path will be resolved by importing the top-level module. The doc file will always be saved in the current directory. """ name = path if string.find(path, os.sep) > -1: name = os.path.splitext(os.path.basename(path))[0] else: package = __import__(name) name = path path = os.path.dirname(package.__file__) cwd = os.getcwd() builder.beginPackage(name) os.path.walk(path, _packageWalkCallback, builder) builder.endPackage(name) os.chdir(cwd) |
builder = DocBuilder0() | builder = GraphPdfDocBuilder0() | def main(): """Handle command-line options and trigger corresponding action. """ opts, args = getopt.getopt(sys.argv[1:], 'hf:m:p:') # On -h print usage and exit immediately. for o, a in opts: if o == '-h': print printUsage.__doc__ #printUsage() sys.exit(0) # On -f set the DocBuilder to use or a default one. builder = DocBuilder0() for o, a in opts: if o == '-f': builder = eval("%sDocBuilder0()" % a) break # Now call the real documentation functions. for o, a in opts: if o == '-m': builder.begin() documentModule0(a, builder) builder.end() sys.exit(0) elif o == '-p': builder.begin() documentPackage0(a, builder) builder.end() sys.exit(0) |
'''This gets called by the template framework | """This gets called by the template framework | def checkPageSize(self,canv,doc): '''This gets called by the template framework If canv size != template size then the canv size is set to the template size or if that's not available to the doc size. ''' #### NEVER EVER EVER COMPARE FLOATS FOR EQUALITY #RGB converting pagesizes to ints means we are accurate to one point #RGB I suggest we should be aiming a little better cp = None dp = None sp = None if canv._pagesize: cp = map(int, canv._pagesize) if self.pagesize: sp = map(int, self.pagesize) if doc.pagesize: dp = map(int, doc.pagesize) if cp!=sp: if sp: canv.setPageSize(self.pagesize) elif cp!=dp: canv.setPageSize(doc.pagesize) |
''' | """ | def checkPageSize(self,canv,doc): '''This gets called by the template framework If canv size != template size then the canv size is set to the template size or if that's not available to the doc size. ''' #### NEVER EVER EVER COMPARE FLOATS FOR EQUALITY #RGB converting pagesizes to ints means we are accurate to one point #RGB I suggest we should be aiming a little better cp = None dp = None sp = None if canv._pagesize: cp = map(int, canv._pagesize) if self.pagesize: sp = map(int, self.pagesize) if doc.pagesize: dp = map(int, doc.pagesize) if cp!=sp: if sp: canv.setPageSize(self.pagesize) elif cp!=dp: canv.setPageSize(doc.pagesize) |
fn = pjoin(dir,'_rl_accel') return getVersionFromCCode(fn),os.stat(fn)[stat.ST_MTIME] | fn = pjoin(dir,'_rl_accel.c') try: return getVersionFromCCode(fn),os.stat(fn)[stat.ST_MTIME] except: return None | def _rl_accel_dir_info(dir): import stat fn = pjoin(dir,'_rl_accel') return getVersionFromCCode(fn),os.stat(fn)[stat.ST_MTIME] |
if len(_)>1: _.sort(_cmp_rl_accel_dirs) return abspath(_[0]) | _ = filter(_rl_accel_dir_info,_) if len(_): _.sort(_cmp_rl_accel_dirs) return abspath(_[0]) | def _find_rl_accel(): '''locate where the accelerator code lives''' _ = [] for x in [ './rl_addons/rl_accel', '../rl_addons/rl_accel', '../../rl_addons/rl_accel', './rl_accel', '../rl_accel', '../../rl_accel', './lib'] \ + glob.glob('./rl_accel-*/rl_accel')\ + glob.glob('../rl_accel-*/rl_accel') \ + glob.glob('../../rl_accel-*/rl_accel') \ : fn = pjoin(x,'_rl_accel.c') if isfile(pjoin(x,'_rl_accel.c')): _.append(x) if _: if len(_)>1: _.sort(_cmp_rl_accel_dirs) return abspath(_[0]) return None |
RL_ACCEL = _find_rl_accel() LIBS = [] DATA_FILES = {} if not RL_ACCEL: EXT_MODULES = [] print '***************************************************' print '*No rl_accel code found, you can obtain it at *' print '*http://www.reportlab.org/downloads.html print '***************************************************' | _yesV=('yes','y','1','true') _yesnoV=_yesV+('no','n','0','false') tra=[_ for _ in sys.argv if _.lower().startswith('--rl_accel=')] if not tra: tra = True | def run(): RL_ACCEL = _find_rl_accel() LIBS = [] DATA_FILES = {} if not RL_ACCEL: EXT_MODULES = [] print '***************************************************' print '*No rl_accel code found, you can obtain it at *' print '*http://www.reportlab.org/downloads.html#_rl_accel*' print '***************************************************' else: fn = pjoin(RL_ACCEL,'lib','hyphen.mashed') if isfile(fn): DATA_FILES[pjoin(package_path, 'lib')] = [fn] EXT_MODULES = [ Extension( '_rl_accel', [pjoin(RL_ACCEL,'_rl_accel.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', [pjoin(RL_ACCEL,'sgmlop.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', [pjoin(RL_ACCEL,'pyHnjmodule.c'), pjoin(RL_ACCEL,'hyphen.c'), pjoin(RL_ACCEL,'hnjalloc.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ] for fn in _FILES: fn = os.sep.join(fn.split('/')) if isfile(fn): tn = dirname(fn) tn = tn and pjoin(package_path,tn) or package_path DATA_FILES.setdefault(tn,[]).append(fn) setup( name="Reportlab", version=get_version(), license="BSD license (see license.txt for details), Copyright (c) 2000-2003, ReportLab Inc.", description="The Reportlab Toolkit", long_description="""The ReportLab Toolkit. |
fn = pjoin(RL_ACCEL,'lib','hyphen.mashed') if isfile(fn): DATA_FILES[pjoin(package_path, 'lib')] = [fn] EXT_MODULES = [ Extension( '_rl_accel', [pjoin(RL_ACCEL,'_rl_accel.c')], | map(sys.argv.remove,tra) tra=tra[-1].split('=',1)[1].lower() assert tra in _yesnoV, 'bad argument --rl_accel='+tra tra = tra in _yesV if tra: RL_ACCEL = _find_rl_accel() LIBS = [] DATA_FILES = {} if not RL_ACCEL: EXT_MODULES = [] print '***************************************************' print '*No rl_accel code found, you can obtain it at *' print '*http://www.reportlab.org/downloads.html print '***************************************************' else: print ' print ' print ' print ' fn = pjoin(RL_ACCEL,'lib','hyphen.mashed') if isfile(fn): DATA_FILES[pjoin(package_path, 'lib')] = [fn] EXT_MODULES = [ Extension( '_rl_accel', [pjoin(RL_ACCEL,'_rl_accel.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, ), Extension( 'sgmlop', [pjoin(RL_ACCEL,'sgmlop.c')], | def run(): RL_ACCEL = _find_rl_accel() LIBS = [] DATA_FILES = {} if not RL_ACCEL: EXT_MODULES = [] print '***************************************************' print '*No rl_accel code found, you can obtain it at *' print '*http://www.reportlab.org/downloads.html#_rl_accel*' print '***************************************************' else: fn = pjoin(RL_ACCEL,'lib','hyphen.mashed') if isfile(fn): DATA_FILES[pjoin(package_path, 'lib')] = [fn] EXT_MODULES = [ Extension( '_rl_accel', [pjoin(RL_ACCEL,'_rl_accel.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', [pjoin(RL_ACCEL,'sgmlop.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', [pjoin(RL_ACCEL,'pyHnjmodule.c'), pjoin(RL_ACCEL,'hyphen.c'), pjoin(RL_ACCEL,'hnjalloc.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ] for fn in _FILES: fn = os.sep.join(fn.split('/')) if isfile(fn): tn = dirname(fn) tn = tn and pjoin(package_path,tn) or package_path DATA_FILES.setdefault(tn,[]).append(fn) setup( name="Reportlab", version=get_version(), license="BSD license (see license.txt for details), Copyright (c) 2000-2003, ReportLab Inc.", description="The Reportlab Toolkit", long_description="""The ReportLab Toolkit. |
define_macros=[], library_dirs=[], libraries=LIBS, ), Extension( 'sgmlop', [pjoin(RL_ACCEL,'sgmlop.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, ), Extension( 'pyHnj', [pjoin(RL_ACCEL,'pyHnjmodule.c'), pjoin(RL_ACCEL,'hyphen.c'), pjoin(RL_ACCEL,'hnjalloc.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, ), ] | define_macros=[], library_dirs=[], libraries=LIBS, ), Extension( 'pyHnj', [pjoin(RL_ACCEL,'pyHnjmodule.c'), pjoin(RL_ACCEL,'hyphen.c'), pjoin(RL_ACCEL,'hnjalloc.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, ), ] | def run(): RL_ACCEL = _find_rl_accel() LIBS = [] DATA_FILES = {} if not RL_ACCEL: EXT_MODULES = [] print '***************************************************' print '*No rl_accel code found, you can obtain it at *' print '*http://www.reportlab.org/downloads.html#_rl_accel*' print '***************************************************' else: fn = pjoin(RL_ACCEL,'lib','hyphen.mashed') if isfile(fn): DATA_FILES[pjoin(package_path, 'lib')] = [fn] EXT_MODULES = [ Extension( '_rl_accel', [pjoin(RL_ACCEL,'_rl_accel.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'sgmlop', [pjoin(RL_ACCEL,'sgmlop.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), Extension( 'pyHnj', [pjoin(RL_ACCEL,'pyHnjmodule.c'), pjoin(RL_ACCEL,'hyphen.c'), pjoin(RL_ACCEL,'hnjalloc.c')], include_dirs=[], define_macros=[], library_dirs=[], libraries=LIBS, # libraries to link against ), ] for fn in _FILES: fn = os.sep.join(fn.split('/')) if isfile(fn): tn = dirname(fn) tn = tn and pjoin(package_path,tn) or package_path DATA_FILES.setdefault(tn,[]).append(fn) setup( name="Reportlab", version=get_version(), license="BSD license (see license.txt for details), Copyright (c) 2000-2003, ReportLab Inc.", description="The Reportlab Toolkit", long_description="""The ReportLab Toolkit. |
if self._atTop: s = flowable.getSpaceBefore() | if not self._atTop: s = flowable.getSpaceBefore() | def _add(self, flowable, canv, trySplit=0): """ Draws the flowable 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""" y = self._y p = self._y1p s = 0 if self._atTop: s = flowable.getSpaceBefore() h = y - p - s if h>0: flowable.canv = canv #so they can use stringWidth etc w, h = flowable.wrap(self._aW, h) del flowable.canv else: return 0 |
c.bookmarkHorizontalAbsolute0(nameTag, pos) | c.bookmarkHorizontalAbsolute(nameTag, pos) | def addIdent(self, t): "Add an identifier." o = self.options # Make base font bold. fam, b, i = fonts.ps2tt(o.fontName) ps = fonts.tt2ps(fam, 1, i) font = (ps, o.fontSize) self.setFillColorAndFont(o.identCol, font) self.putText(t) # Bookmark certain identifiers (class and function names). if not o.noOutline and not o.multiPage: item = self.itemFound if item: # Add line height to current vert. position. pos = self.text.getY() + o.fontSize nameTag = "p%sy%s" % (self.pageNum, pos) c = self.canvas i = self.startPositions.index(self.startPos) c.bookmarkHorizontalAbsolute0(nameTag, pos) c.addOutlineEntry0('%s %s' % (item, t), nameTag, i) |
raise "LayoutError", "Flowable (%sx%s points) too wide for frame (%sx* points)." % (dW,t,w) | raise "LayoutError", "Flowable (%sx%s points) too wide for cell (%sx* points)." % (dW,t,w) | def _calc(self): if hasattr(self,'_width'): return |
self._canvas.ellipse(x1,y1,x2,y2,fill=1) | self._canvas.ellipse(x1,y1,x2,y2,fill=self._fill,stroke=self._stroke) | def drawEllipse(self, ellipse): #need to convert to pdfgen's bounding box representation x1 = ellipse.cx - ellipse.rx x2 = ellipse.cx + ellipse.rx y1 = ellipse.cy - ellipse.ry y2 = ellipse.cy + ellipse.ry self._canvas.ellipse(x1,y1,x2,y2,fill=1) |
internalname = canv._doc.hasForm(name) canv.saveState() | if definedForms.has_key(name): internalname = 1 else: internalname = None definedForms[name] = 1 | def drawOn(self, canv): for graphic in self.graphics: |
canv.restoreState() | def drawOn(self, canv): for graphic in self.graphics: |
|
if self._text == None: self._text = '' | _text = self._text self._text = _text or '' | def draw(self): if self._text == None: self._text = '' # hack, but it works for now... self.computeSize() g = Group() g.translate(self.x + self.dx, self.y + self.dy) g.rotate(self.angle) |
def _doNothing(flowables, doc): "Dummy callback for onFirstPage and onNewPage" | def _doNothing(canvas, doc): "Dummy callback for onPage" | def _doNothing(flowables, doc): "Dummy callback for onFirstPage and onNewPage" pass |
self.canv.drawCentredString( | try: self.canv.drawCentredString( | def drawChars(self, charList): """Fills boxes in order. None means skip a box. Empty boxes at end get filled with gray""" extraNeeded = (self.rows * self.charsPerRow - len(charList)) for i in range(extraNeeded): charList.append(None) #charList.extend([None] * extraNeeded) row = 0 col = 0 self.canv.setFont(self.fontName, self.boxSize * 0.75) for ch in charList: # may be 2 bytes or 1 if ch is None: self.canv.setFillGray(0.9) self.canv.rect((1+col) * self.boxSize, (self.rows - row - 1) * self.boxSize, self.boxSize, self.boxSize, stroke=0, fill=1) self.canv.setFillGray(0.0) else: self.canv.drawCentredString( (col+1.5) * self.boxSize, (self.rows - row - 0.875) * self.boxSize, ch ) col = col + 1 if col == self.charsPerRow: row = row + 1 col = 0 |
ch | ch, | def drawChars(self, charList): """Fills boxes in order. None means skip a box. Empty boxes at end get filled with gray""" extraNeeded = (self.rows * self.charsPerRow - len(charList)) for i in range(extraNeeded): charList.append(None) #charList.extend([None] * extraNeeded) row = 0 col = 0 self.canv.setFont(self.fontName, self.boxSize * 0.75) for ch in charList: # may be 2 bytes or 1 if ch is None: self.canv.setFillGray(0.9) self.canv.rect((1+col) * self.boxSize, (self.rows - row - 1) * self.boxSize, self.boxSize, self.boxSize, stroke=0, fill=1) self.canv.setFillGray(0.0) else: self.canv.drawCentredString( (col+1.5) * self.boxSize, (self.rows - row - 0.875) * self.boxSize, ch ) col = col + 1 if col == self.charsPerRow: row = row + 1 col = 0 |
return makeSuiteForClasses(RlAccelTestCase) except ImportError: return None | Klass = RlAccelTestCase except: class Klass(unittest.TestCase): pass return makeSuiteForClasses(Klass) | def makeSuite(): # only run the tests if _rl_accel is present try: import _rl_accel return makeSuiteForClasses(RlAccelTestCase) except ImportError: return None |
radius = self._radius = self._cx-self.x self._radiusx = radiusx = radius self._radiusy = radiusy = (1.0 - self.perspective/100.0)*radius | radiusx = radiusy = self._cx-self.x if self.xradius: radiusx = self.xradius if self.yradius: radiusy = self.yradius self._radiusx = radiusx self._radiusy = (1.0 - self.perspective/100.0)*radiusy | def draw(self): slices = self.slices _3d_angle = self.angle_3d _3dva = self._3dva = _360(_3d_angle+90) a0 = _2rad(_3dva) self._xdepth_3d = cos(a0)*self.depth_3d self._ydepth_3d = sin(a0)*self.depth_3d self._cx = self.x+self.width/2.0 self._cy = self.y+(self.height - self._ydepth_3d)/2.0 radius = self._radius = self._cx-self.x self._radiusx = radiusx = radius self._radiusy = radiusy = (1.0 - self.perspective/100.0)*radius data = self.normalizeData() sum = self._sum |
print "Can't find cvs anywhere on the path" | def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) if release: os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+(' co -r %s reportlab'%release), 'the download phase') else: os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+' co reportlab', 'the download phase') |
|
os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+(' co -r %s reportlab'%release), 'the download phase') | do_exec(cvs+(' export -r %s reportlab'%release), 'the export phase') | def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) if release: os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+(' co -r %s reportlab'%release), 'the download phase') else: os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+' co reportlab', 'the download phase') |
os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+' co reportlab', 'the download phase') | do_exec(cvs+' co reportlab', 'the checkout phase') | def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) if release: os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+(' co -r %s reportlab'%release), 'the download phase') else: os.environ['CVSROOT']=':pserver:%s@cvs:/cvsroot/reportlab' % USER do_exec(cvs+' co reportlab', 'the download phase') |
def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) | def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
|
src_files = [] os.path.walk(projdir,find_src_files,src_files) | def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
|
b = "%s" % release | b = release | def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
safe_remove(zipfile) safe_remove(tarfile) if src_files==[]: return src_files = string.join(src_files) | def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
|
do_exec('%s czvf %s %s' % (tar, tarfile, src_files), 'tar creation') | if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') | def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
do_exec('%s -u %s %s' % (zip, zipfile, src_files), 'zip creation') | if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') | def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.