rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
outline = self.outline outline.prepare(self, canvas)
def SaveToFile(self, filename, canvas): from types import StringType # prepare outline outline = self.outline outline.prepare(self, canvas) if type(filename) is StringType: myfile = 1 f = open(filename, "wb") else: myfile = 0 f = filename # IT BETTER BE A FILE-LIKE OBJECT! txt = self.format() f.write(txt) if myfile: f.close() markfilename(filename) # do platform specific file junk
0be23823f1a584548422e9894db4903c2cd17df8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0be23823f1a584548422e9894db4903c2cd17df8/pdfdoc.py
if next >= end:
if inc > 0 and next >= end: break elif inc < 0 and next <= end:
def frange(start, end=None, inc=None): "A range function, that does accept float increments..." if end == None: end = start + 0.0 start = 0.0 if inc == None: inc = 1.0 L = [] while 1: next = start + len(L) * inc if next >= end: break L.append(next) return L
ae070abb3e34a307bab61a8b403456383e9d6417 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/ae070abb3e34a307bab61a8b403456383e9d6417/grids.py
FT_INC_DIR = ['/usr/local/include/freetype2']
FT_INC_DIR = ['/usr/local/include','/usr/local/include/freetype2']
def main(): cwd = os.getcwd() os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) MACROS=[('ROBIN_DEBUG',None)] MACROS=[] from glob import glob from distutils.core import setup, Extension pJoin=os.path.join LIBART_VERSION = libart_version() SOURCES=['_renderPM.c'] DEVEL_DIR=os.curdir LIBART_DIR=pJoin(DEVEL_DIR,'libart_lgpl') LIBART_SRCS=glob(pJoin(LIBART_DIR, 'art_*.c')) GT1_DIR=pJoin(DEVEL_DIR,'gt1') GLIB_DIR=pJoin(DEVEL_DIR,'glib') platform = sys.platform if platform in ['darwin', 'win32', 'sunos5', 'freebsd4', 'freebsd6', 'mac', 'linux2','linux-i386','aix4']: LIBS=[] else: raise ValueError, "Don't know about platform", platform if os.path.isdir('/usr/local/include/freetype2'): FT_LIB = ['freetype'] FT_LIB_DIR = ['/usr/local/lib'] FT_MACROS = [('RENDERPM_FT',None)] FT_INC_DIR = ['/usr/local/include/freetype2'] else: ft_lib = check_ft_lib() if ft_lib: FT_LIB = [os.path.splitext(os.path.basename(ft_lib))[0]] FT_LIB_DIR = [os.path.dirname(ft_lib)] FT_MACROS = [('RENDERPM_FT',None)] FT_INC_DIR = [FT_INCLUDE or os.path.join(os.path.dirname(os.path.dirname(ft_lib)),'include')] else: FT_LIB = [] FT_LIB_DIR = [] FT_MACROS = [] FT_INC_DIR = [] setup( name = "_renderPM", version = VERSION, description = "Python low level render interface", author = "Robin Becker", author_email = "[email protected]", url = "http://www.reportlab.com", packages = [], libraries=[('_renderPM_libart', { 'sources': LIBART_SRCS, 'include_dirs': [DEVEL_DIR,LIBART_DIR,], 'macros': [('LIBART_COMPILATION',None),]+BIGENDIAN('WORDS_BIGENDIAN')+MACROS, #'extra_compile_args':['/Z7'], } ), ('_renderPM_gt1', { 'sources': pfxJoin(GT1_DIR,'gt1-dict.c','gt1-namecontext.c','gt1-parset1.c','gt1-region.c','parseAFM.c'), 'include_dirs': [DEVEL_DIR,GT1_DIR,GLIB_DIR,], 'macros': MACROS, #'extra_compile_args':['/Z7'], } ), ], ext_modules = [Extension( '_renderPM', SOURCES, include_dirs=[DEVEL_DIR,LIBART_DIR,GT1_DIR]+FT_INC_DIR, define_macros=FT_MACROS+[('LIBART_COMPILATION',None)]+MACROS+[('LIBART_VERSION',LIBART_VERSION)], library_dirs=[]+FT_LIB_DIR, # libraries to link against libraries=LIBS+FT_LIB, #extra_objects=['gt1.lib','libart.lib',], #extra_compile_args=['/Z7'], extra_link_args=[] ), ], ) if sys.hexversion<0x2030000 and sys.platform=='win32' and ('install' in sys.argv or 'install_ext' in sys.argv): def MovePYDs(*F): for x in sys.argv: if x[:18]=='--install-platlib=': return src = sys.exec_prefix dst = os.path.join(src,'DLLs') if sys.hexversion>=0x20200a0: src = os.path.join(src,'lib','site-packages') for f in F: srcf = os.path.join(src,f) if not os.path.isfile(srcf): continue dstf = os.path.join(dst,f) if os.path.isfile(dstf): os.remove(dstf) os.rename(srcf,dstf) MovePYDs('_renderPM.pyd','_renderPM.pdb')
f2354a2e6cfb6d352844995d552555bca57bead7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f2354a2e6cfb6d352844995d552555bca57bead7/setup.py
(file, pathname, description) = imp.find_module(name, parentModule.__path__)
(file, pathname, description) = imp.find_module(name, parentModule.__file__)
def recursiveImport(modulename, baseDir=None, noCWD=0): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') part = parts[0] path = list(baseDir and (type(baseDir) not in SeqTypes and [baseDir] or filter(None,baseDir)) or None) if not noCWD and '.' not in path: path.insert(0,'.') #make import errors a bit more informative try: (file, pathname, description) = imp.find_module(part, path) childModule = parentModule = imp.load_module(part, file, pathname, description) for name in parts[1:]: (file, pathname, description) = imp.find_module(name, parentModule.__path__) childModule = imp.load_module(name, file, pathname, description) setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (part, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule
4235ee5d02ae8d66505b546551cebd45936dd345 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/4235ee5d02ae8d66505b546551cebd45936dd345/utils.py
"""Draws a string right-aligned with the y coordinate"""
"""Draws a string right-aligned with the x coordinate"""
def drawRightString(self, x, y, text): """Draws a string right-aligned with the y coordinate""" width = self.stringWidth(text, self._fontname, self._fontsize) t = self.beginText(x - width, y) t.textLine(text) self.drawText(t)
0c83eb1fb49e65692475d218070d2adba8f94c37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0c83eb1fb49e65692475d218070d2adba8f94c37/canvas.py
"""Draws a string right-aligned with the y coordinate. I
"""Draws a string right-aligned with the x coordinate. I
def drawCentredString(self, x, y, text): """Draws a string right-aligned with the y coordinate. I am British so the spelling is correct, OK?""" width = self.stringWidth(text, self._fontname, self._fontsize) t = self.beginText(x - 0.5*width, y) t.textLine(text) self.drawText(t)
0c83eb1fb49e65692475d218070d2adba8f94c37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0c83eb1fb49e65692475d218070d2adba8f94c37/canvas.py
self.width = 200 self.height = 100
self.x = 20 self.y = 10 self.height = 85 self.width = 180
def __init__(self): self.debug = 0
564845562a7cc276b8976fa4ce5c4e13bfb485e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/564845562a7cc276b8976fa4ce5c4e13bfb485e5/barcharts.py
data = map(lambda x: map(lambda x: x is not None and x or 0,x), self.data) return min(min(data)), max(max(data))
D = [] for d in self.data: for e in d: if e is None: e = 0 D.append(e) return min(D), max(D)
def _findMinMaxValues(self): "Find the minimum and maximum value of the data we have." data = map(lambda x: map(lambda x: x is not None and x or 0,x), self.data) return min(min(data)), max(max(data))
564845562a7cc276b8976fa4ce5c4e13bfb485e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/564845562a7cc276b8976fa4ce5c4e13bfb485e5/barcharts.py
g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor))
g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor))
def makeBackground(self): g = Group() #print 'BarChart.makeBackground(%s, %s, %s, %s)' % (self.x, self.y, self.width, self.height) g.add(Rect(self.x, self.y, self.width, self.height, strokeColor = self.strokeColor, fillColor= self.fillColor))
564845562a7cc276b8976fa4ce5c4e13bfb485e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/564845562a7cc276b8976fa4ce5c4e13bfb485e5/barcharts.py
def demo(self): """Shows basic use of a bar chart"""
564845562a7cc276b8976fa4ce5c4e13bfb485e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/564845562a7cc276b8976fa4ce5c4e13bfb485e5/barcharts.py
data = [ (13, 5, 20, 22, 37, 45, 19, 4), (14, 6, 21, 23, 38, 46, 20, 5) ]
def demo(self): """Shows basic use of a bar chart"""
564845562a7cc276b8976fa4ce5c4e13bfb485e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/564845562a7cc276b8976fa4ce5c4e13bfb485e5/barcharts.py
bc.x = 20 bc.y = 10 bc.height = 85 bc.width = 180 bc.data = data
def demo(self): """Shows basic use of a bar chart"""
564845562a7cc276b8976fa4ce5c4e13bfb485e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/564845562a7cc276b8976fa4ce5c4e13bfb485e5/barcharts.py
def demo(self): """Shows basic use of a bar chart"""
564845562a7cc276b8976fa4ce5c4e13bfb485e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/564845562a7cc276b8976fa4ce5c4e13bfb485e5/barcharts.py
if hasattr(self,saveLogger):
if hasattr(self,'saveLogger'):
def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): from reportlab import rl_config "Saves copies of self in desired location and formats" ext = '' if not fnRoot: fnRoot = getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) chartId = getattr(self,'chartId',0) if callable(fnRoot): fnRoot = fnRoot(chartId) else: try: fnRoot = fnRoot % getattr(self,'chartId',0) except TypeError, err: if str(err) != 'not all arguments converted': raise
af6c6dab559d71c5c08c6e5f46105c799fd65c94 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/af6c6dab559d71c5c08c6e5f46105c799fd65c94/shapes.py
print >>sys.stderr, '\n
sys.stderr.write('\n
def makeSuite(folder, exclude=[],nonImportable=[]): "Build a test suite of all available test files." allTests = unittest.TestSuite() sys.path.insert(0, folder) for filename in GlobDirectoryWalker(folder, 'test_*.py'): modname = os.path.splitext(os.path.basename(filename))[0] if modname not in exclude: try: module = __import__(modname) allTests.addTest(module.makeSuite()) except: tt, tv, tb = sys.exc_info()[:] nonImportable.append((filename,traceback.format_exception(tt,tv,tb))) del tt,tv,tb del sys.path[0] return allTests
525c865aaca24c538bfd1f595572a12f917681ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/525c865aaca24c538bfd1f595572a12f917681ee/runAll.py
def _listCellGeom(V,w,s,W=None):
def _listCellGeom(V,w,s,W=None,H=None):
def _listCellGeom(V,w,s,W=None): aW = w-s.leftPadding-s.rightPadding t = 0 w = 0 for v in V: vw, vh = v.wrap(aW, 72000) if W is not None: W.append(vw) w = max(w,vw) t = t + vh + v.getSpaceBefore()+v.getSpaceAfter() return w, t - V[0].getSpaceBefore()-V[-1].getSpaceAfter()
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
if t in _SeqTypes:
if t in _SeqTypes or isinstance(v,Flowable): if not t in _SeqTypes: v = (v,)
def _calc(self): if hasattr(self,'_width'): return
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
if t is not _stringtype: v = str(v)
if t is not StringType: v = v is None and '' or str(v)
def _calc(self): if hasattr(self,'_width'): return
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
t = s.leading*len(v)+s.bottomPadding+s.topPadding
t = s.leading*len(v) t = t+s.bottomPadding+s.topPadding
def _calc(self): if hasattr(self,'_width'): return
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
if t in _SeqTypes:
if t in _SeqTypes or isinstance(v,Flowable):
def _calc(self): if hasattr(self,'_width'): return
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
elif t is not _stringtype: v = str(v)
elif t is not StringType: v = v is None and '' or str(v)
def _calc(self): if hasattr(self,'_width'): return
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
if sr<(n-1) and er>=n:
if sr<n and er>=(n-1):
def _splitRows(self,availHeight): h = 0 n = 0 lim = len(self._rowHeights) while n<lim: hn = h + self._rowHeights[n] if hn>availHeight: break h = hn n = n + 1
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
if n in _SeqTypes:
if n in _SeqTypes or isinstance(cellval,Flowable): if not n in _SeqTypes: cellval = (cellval,)
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
if valign != 'BOTTOM' or just != 'LEFT': W = [] w, h = _listCellGeom(cellval,colwidth,cellstyle,W=W)
W = [] H = [] w, h = _listCellGeom(cellval,colwidth,cellstyle,W=W, H=H) if valign=='TOP': y = rowpos + rowheight - cellstyle.topPadding elif valign=='BOTTOM': y = rowpos+cellstyle.bottomPadding + h
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
W = len(cellval)*[0] if valign=='TOP': y = rowpos + rowheight - cellstyle.topPadding+h elif valign=='BOTTOM': y = rowpos+cellstyle.bottomPadding else: y = rowpos+(rowheight+cellstyle.bottomPadding-cellstyle.topPadding-h)/2.0
y = rowpos+(rowheight+cellstyle.bottomPadding-cellstyle.topPadding+h)/2.0
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
for v, w in map(None,cellval,W):
for v, w, h in map(None,cellval,W,H):
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
else: x = colpos+(colwidth+cellstyle.leftPadding-cellstyle.rightPadding-w)/2.0
elif just in ('CENTRE', 'CENTER'): x = colpos+(colwidth+cellstyle.leftPadding-cellstyle.rightPadding-w)/2.0 else: raise ValueError, 'Invalid justification %s' % just
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
if n is _stringtype: val = cellval
if n is StringType: val = cellval
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
t=Table(data,style=[('GRID',(1,1),(-2,-2),1,colors.green),
t=Table(data,style=[ ('GRID',(0,0),(-1,-1),0.5,colors.grey), ('GRID',(1,1),(-2,-2),1,colors.green),
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
data= [['A', 'B', 'C', (Paragraph("<b>A paragraph</b>",styleSheet["BodyText"]),), 'D'], ['00', '01', '02', '03', '04'], ['10', '11', '12', '13', '14'],
import os, reportlab.platypus I = Image(os.path.join(os.path.dirname(reportlab.platypus.__file__),'..','demos','pythonpoint','leftlogo.gif')) I.drawHeight = 1.25*inch*I.drawHeight / I.drawWidth I.drawWidth = 1.25*inch I.noImageCaching = 1 P = Paragraph("<para align=center spaceb=3>The <b>ReportLab Left <font color=red>Logo</font></b> Image</para>", styleSheet["BodyText"]) data= [['A', 'B', 'C', Paragraph("<b>A pa<font color=red>r</font>a<i>graph</i></b><super><font color=yellow>1</font></super>",styleSheet["BodyText"]), 'D'], ['00', '01', '02', [I,P], '04'], ['10', '11', '12', [I,P], '14'],
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
6d688252f8c20ac7342f18cb770cd48a8cc16d36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6d688252f8c20ac7342f18cb770cd48a8cc16d36/tables.py
headerline = string.join(canvas.headerLine, ' \215 ')
headerline = string.join(canvas.headerLine, ' \215 ')
def mainPageFrame(canvas, doc): "The page frame used for all PDF documents." canvas.saveState() pageNumber = canvas.getPageNumber() canvas.line(2*cm, A4[1]-2*cm, A4[0]-2*cm, A4[1]-2*cm) canvas.line(2*cm, 2*cm, A4[0]-2*cm, 2*cm) if pageNumber > 1: canvas.setFont('Times-Roman', 12) canvas.drawString(4 * inch, cm, "%d" % pageNumber) if hasattr(canvas, 'headerLine'): # hackish headerline = string.join(canvas.headerLine, ' \215 ') canvas.drawString(2*cm, A4[1]-1.75*cm, headerline) canvas.setFont('Times-Roman', 8) msg = "Generated with reportlab.lib.docpy. See http://www.reportlab.com!" canvas.drawString(2*cm, 1.65*cm, msg) canvas.restoreState()
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
if f.style.name[:8] == 'Heading0':
if name7 == 'Heading' and not hasattr(self.canv, 'headerLine'): self.canv.headerLine = [] if name8 == 'Heading0':
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
elif f.style.name[:8] == 'Heading1':
elif name8 == 'Heading1':
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
elif f.style.name[:8] == 'Heading2':
elif name8 == 'Heading2':
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
if f.style.name[:7] == 'Heading':
if name7 == 'Heading':
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
lev = int(f.style.name[7:])
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
if lev == 0:
if headLevel == 0:
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
c.addOutlineEntry(title, key, level=lev,
c.addOutlineEntry(title, key, level=headLevel,
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
except:
except ValueError:
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
"""
u """
def makeHtmlSection(text, bgcolor='#FFA0FF'): """Create HTML code for a section. This is usually a header for all classes or functions. """ text = htmlescape(expandtabs(text)) result = [] result.append("""<TABLE WIDTH="100\%" BORDER="0">""") result.append("""<TR><TD BGCOLOR="%s" VALIGN="CENTER">""" % bgcolor) result.append("""<H2>%s</H2>""" % text) result.append("""</TD></TR></TABLE>""") result.append('') return join(result, '\n')
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
def begin(self):
def begin(self, name='', typ=''):
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 = []
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
story.append(Paragraph('Imported modules', h2))
story.append(Paragraph('Imported modules', self.makeHeadingStyle(self.indentLevel + 1)))
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']
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
story.append(Paragraph(m, bt1))
p = Paragraph('<bullet>\201</bullet> %s' % m, bt1) p.style.bulletIndent = 10 p.style.leftIndent = 18 story.append(p)
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']
d0ba459482027816509931b8917ee5896cba381f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0ba459482027816509931b8917ee5896cba381f/docpy.py
else:
elif abs(width)>1e-7 and abs(height)>=1e-7 and (rowStyle.fillColor is not None or rowStyle.strokeColor is not None):
def makeBars(self): g = Group()
d258e0112c6e73e4fec31709b2067e11df7a222b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d258e0112c6e73e4fec31709b2067e11df7a222b/barcharts.py
r.strokeWidth = rowStyle.strokeWidth
r.strokeWidth = rowStyle.strokeWidth
def makeBars(self): g = Group()
d258e0112c6e73e4fec31709b2067e11df7a222b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d258e0112c6e73e4fec31709b2067e11df7a222b/barcharts.py
"Make sample legend." d = Drawing(200, 100) legend = Legend() legend.alignment = 'right' legend.x = 0 legend.y = 100 legend.dxTextSpace = 5 items = string.split('red green blue yellow pink black white', ' ') items = map(lambda i:(getattr(colors, i), i), items) legend.colorNamePairs = items d.add(legend, 'legend') return d
"Make sample legend." d = Drawing(200, 100) legend = Legend() legend.alignment = 'right' legend.x = 0 legend.y = 100 legend.dxTextSpace = 5 items = string.split('red green blue yellow pink black white', ' ') items = map(lambda i:(getattr(colors, i), i), items) legend.colorNamePairs = items d.add(legend, 'legend') return d
def sample1c(): "Make sample legend." d = Drawing(200, 100) legend = Legend() legend.alignment = 'right' legend.x = 0 legend.y = 100 legend.dxTextSpace = 5 items = string.split('red green blue yellow pink black white', ' ') items = map(lambda i:(getattr(colors, i), i), items) legend.colorNamePairs = items d.add(legend, 'legend') return d
dcd9af9d00684cad7fecd011518808867894b24a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/dcd9af9d00684cad7fecd011518808867894b24a/legends.py
valueSteps = AttrMapValue(isListOfNumbers),
valueSteps = AttrMapValue(isListOfNumbersOrNone),
def makeTickLabels(self): g = Group()
f02b07be27e77cea10157abbb94d0a92d726f3f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f02b07be27e77cea10157abbb94d0a92d726f3f8/axes.py
if hasattr(self, 'valueSteps'):
if hasattr(self, 'valueSteps') and self.valueSteps:
def _calcTickmarkPositions(self): """Calculate a list of tick positions on the axis.
f02b07be27e77cea10157abbb94d0a92d726f3f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f02b07be27e77cea10157abbb94d0a92d726f3f8/axes.py
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
f760f58369f882d86b9c4f874a0989b83e418f95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f760f58369f882d86b9c4f874a0989b83e418f95/graphdocpy.py
if lev == 0:
if lev == 0 or title != 'Functions':
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
f760f58369f882d86b9c4f874a0989b83e418f95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f760f58369f882d86b9c4f874a0989b83e418f95/graphdocpy.py
c.addOutlineEntry(title, key, level=lev, closed=isClosed)
c.addOutlineEntry(title, key, level=lev, closed=isClosed) c.showOutline()
def afterFlowable(self, flowable): "Takes care of header line, TOC and outline entries." if flowable.__class__.__name__ == 'Paragraph': f = flowable
f760f58369f882d86b9c4f874a0989b83e418f95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f760f58369f882d86b9c4f874a0989b83e418f95/graphdocpy.py
def beginClass(self, name, doc, bases): "Append a graphic demo of a widget at the end of a class." aClass = eval('self.skeleton.moduleSpace.' + name) if issubclass(aClass, Widget): if self.shouldDisplayModule: modName, modDoc, imported = self.shouldDisplayModule self.story.append(Paragraph(modName, self.makeHeadingStyle(self.indentLevel-2, 'module'))) self.story.append(XPreformatted(modDoc, self.bt)) self.shouldDisplayModule = 0 self.hasDisplayedModule = 1 if self.shouldDisplayClasses: self.story.append(Paragraph('Classes', self.makeHeadingStyle(self.indentLevel-1))) self.shouldDisplayClasses = 0 PdfDocBuilder0.beginClass(self, name, doc, bases)
f760f58369f882d86b9c4f874a0989b83e418f95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f760f58369f882d86b9c4f874a0989b83e418f95/graphdocpy.py
def _showWidgetDemo(self, widget): """Show a graphical demo of the widget."""
f760f58369f882d86b9c4f874a0989b83e418f95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f760f58369f882d86b9c4f874a0989b83e418f95/graphdocpy.py
widget.verify()
def _showWidgetDemo(self, widget): """Show a graphical demo of the widget."""
f760f58369f882d86b9c4f874a0989b83e418f95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f760f58369f882d86b9c4f874a0989b83e418f95/graphdocpy.py
dept = self.EPS_info[0], company = self.EPS_info[1], preview = self.preview, showBorder=self.showBorder)
dept = getattr(self,'EPS_info',['Testing'])[0], company = getattr(self,'EPS_info',['','ReportLab'])[1], preview = getattr(self,'preview',1), showBorder=getattr(self,'showBorder',0))
def save(self, formats=None, verbose=None, fnRoot=None, outDir=None): "Saves copies of self in desired location and formats" ext = '' outDir = outDir or getattr(self,'outDir','.') if not os.path.isabs(outDir): outDir = os.path.join(os.path.dirname(sys.argv[0]),outDir) if not os.path.isdir(outDir): os.makedirs(outDir) fnroot = os.path.normpath(os.path.join(outDir, fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0))))
5b38073372627f878dc0f00863aadbb4fa49e973 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/5b38073372627f878dc0f00863aadbb4fa49e973/shapes.py
text = join(lines[i][1])
text = join(tx.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(lines[i][1]) textlen = tx._canvas.stringWidth(text, tx._fontname, tx._fontsize) tx._canvas.line(t_off, y, t_off+textlen, y)
05006eb70065415d261e84f00ba1d2566c88a75c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/05006eb70065415d261e84f00ba1d2566c88a75c/paragraph.py
def polarToRect(self, r, theta): "Convert to rectangular based on current size" return (self._centerx + r * sin(theta),self._centery + r * cos(theta))
def polarToRect(self, r, theta): "Convert to rectangular based on current size" return (self._centerx + r * sin(theta),self._centery + r * cos(theta))
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
self._centerx = centerx = self.x + xradius self._centery = centery = self.y + yradius
centerx = self.x + xradius centery = self.y + yradius
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
n = len(self.data[0]) angleBetween = (2 * pi)/n angles = [] a = (self.startAngle * pi / 180) for i in range(n): angles.append(a) a = a + angleBetween if self.direction == "anticlockwise": whichWay = 1 else: whichWay = -1
n = len(data[0])
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
i = 0 startAngle = self.startAngle
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
for angle in angles: sa = sin(angle)*radius ca = cos(angle)*radius spoke = Line(centerx, centery, centerx + ca, centery + sa, strokeWidth = 0.5)
csa = [] angle = self.startAngle*pi/180 direction = self.direction == "clockwise" and -1 or 1 angleBetween = direction*(2 * pi)/n for i in xrange(n): car = cos(angle)*radius sar = sin(angle)*radius csa.append((car,sar,angle)) spoke = Line(centerx, centery, centerx + car, centery + sar, strokeWidth = 0.5)
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
ex = centerx + labelRadius*ca ey = centery + labelRadius*sa
ex = centerx + labelRadius*car ey = centery + labelRadius*sar
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
i = i + 1
angle = angle + angleBetween
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
theta = angles[-1]
car, sar = csa[-1][:2]
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
x0, y0 = self.polarToRect(r*radius, theta) points.append(x0) points.append(y0) for i in range(n): theta = angles[i]
points.append(centerx+car*r) points.append(centery+sar*r) for i in xrange(n): car, sar = csa[i][:2]
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
x1, y1 = self.polarToRect(r*radius, theta) x0, y0 = x1, y1 points.append(x0) points.append(y0)
points.append(centerx+car*r) points.append(centery+sar*r)
def draw(self): # normalize slice data g = self.makeBackground() or Group()
7560fdfa0895186c8f0183a636ad5504edbdd459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/7560fdfa0895186c8f0183a636ad5504edbdd459/spider.py
thisy = upperlefty = self.y - self.dx
thisy = upperlefty = self.y - self.dy
def draw(self): g = Group() colorNamePairs = self.colorNamePairs thisx = upperleftx = self.x thisy = upperlefty = self.y - self.dx dx, dy = self.dx, self.dy
d34ac22a27860fb0b1876030228683e7da0cb476 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d34ac22a27860fb0b1876030228683e7da0cb476/legends.py
G.add(Polygon(_ystrip_poly(x[0], x[1], y.y0, y.y1, xdepth, ydepth),
print 'Poly([%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f])'% tuple(_ystrip_poly(x[0], x[1], y.y0, y.y1, xdepth, -ydepth)) G.add(Polygon(_ystrip_poly(x[0], x[1], y.y0, y.y1, xdepth, -ydepth),
def F(x,i, slope=slope, y0=y0): return float((x-x0)*slope[i]+y0[i])
cf1d260e6e6e62494630abc50f1c00859d13ee7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cf1d260e6e6e62494630abc50f1c00859d13ee7e/utils3d.py
if x is X[0]: G.add(Line(x[0], y.y1, x[0]+xdepth, y.y1+ydepth,strokeColor=c,strokeWidth=0.6*xdelta))
def F(x,i, slope=slope, y0=y0): return float((x-x0)*slope[i]+y0[i])
cf1d260e6e6e62494630abc50f1c00859d13ee7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cf1d260e6e6e62494630abc50f1c00859d13ee7e/utils3d.py
return cmp(_rl_accel_dir_info(b),__rl_accel_dir_info(a))
return cmp(_rl_accel_dir_info(b),_rl_accel_dir_info(a))
def _cmp_rl_accel_dirs(a,b): return cmp(_rl_accel_dir_info(b),__rl_accel_dir_info(a))
51ebc39da3d313de76d2c9beda5f348d71f3dde0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/51ebc39da3d313de76d2c9beda5f348d71f3dde0/setup.py
text = escape(opcode) code.append('(%s) Tj' % text)
textobject.textOut(opcode)
def runOpCodes(self, program, canvas, textobject): "render the line(s)"
89cf707471f7b823e5e45312d8df8859c08a9762 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/89cf707471f7b823e5e45312d8df8859c08a9762/para.py
text = escape(text) code.append('(%s) Tj' % text)
textobject.textOut(text)
def draw(self): style = self.style lines = self.lines rightIndent = style.rightIndent leftIndent = style.leftIndent leading = style.leading font = style.fontName size = style.fontSize alignment = style.alignment firstindent = style.firstLineIndent c = self.canv escape = c._escape #if debug: # print "FAST", id(self), "page number", c.getPageNumber() height = self.height #if debug: # c.rect(0,0,-1, height-size, fill=1, stroke=1) c.translate(0, height-size) textobject = c.beginText() code = textobject._code #textobject.setTextOrigin(0,firstindent) textobject.setFont(font, size) if style.textColor: textobject.setFillColor(style.textColor) first = 1 y = 0 basicWidth = self.availableWidth - rightIndent count = 0 nlines = len(lines) while count<nlines: (text, length, nwords) = lines[count] count = count+1 thisindent = leftIndent if first: thisindent = firstindent if alignment==TA_LEFT: x = thisindent elif alignment==TA_CENTER: extra = basicWidth - length x = thisindent + extra/2.0 elif alignment==TA_RIGHT: extra = basicWidth - length x = thisindent + extra elif alignment==TA_JUSTIFY: x = thisindent if count<nlines and nwords>1: # patch from [email protected], 9 Nov 2002, no extraspace on last line textobject.setWordSpace((basicWidth-length)/(nwords-1.0)) else: textobject.setWordSpace(0.0) textobject.setTextOrigin(x,y) text = escape(text) code.append('(%s) Tj' % text) #textobject.textOut(text) y = y-leading c.drawText(textobject)
89cf707471f7b823e5e45312d8df8859c08a9762 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/89cf707471f7b823e5e45312d8df8859c08a9762/para.py
from paraparser import greeks, symenc
from paraparser import greeks
def handleSpecialCharacters(engine, text, program=None): from paraparser import greeks, symenc from string import whitespace, atoi, atoi_error 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
89cf707471f7b823e5e45312d8df8859c08a9762 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/89cf707471f7b823e5e45312d8df8859c08a9762/para.py
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(" ")
if n>=0: fragment = unichr(n).encode('utf8')+fragment[semi+1:]
def handleSpecialCharacters(engine, text, program=None): from paraparser import greeks, symenc from string import whitespace, atoi, atoi_error 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
89cf707471f7b823e5e45312d8df8859c08a9762 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/89cf707471f7b823e5e45312d8df8859c08a9762/para.py
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(" ")
fragment = greeks[name]+fragment[semi+1:]
def handleSpecialCharacters(engine, text, program=None): from paraparser import greeks, symenc from string import whitespace, atoi, atoi_error 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
89cf707471f7b823e5e45312d8df8859c08a9762 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/89cf707471f7b823e5e45312d8df8859c08a9762/para.py
justified text paragraph example
justified text paragraph example with a pound sign \xc2\xa3
def splitspace(text): # split on spacing but include spaces at element ends stext = text.split() result = [] for e in stext: result.append(e+" ") return result
89cf707471f7b823e5e45312d8df8859c08a9762 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/89cf707471f7b823e5e45312d8df8859c08a9762/para.py
pagesize=(595.27,841.89),
pagesize=None,
def __init__(self,filename, pagesize=(595.27,841.89), bottomup = 1, pageCompression=None, encoding=rl_config.defaultEncoding, invariant=rl_config.invariant, verbosity=0): """Create a canvas of a given size. etc. Most of the attributes are private - we will use set/get methods as the preferred interface. Default page size is A4.""" self._filename = filename self._encodingName = encoding self._doc = pdfdoc.PDFDocument(encoding, compression=pageCompression, invariant=invariant)
0dfc32eaeaff74aae5d82442e8308a1c0f42c955 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0dfc32eaeaff74aae5d82442e8308a1c0f42c955/canvas.py
encoding=rl_config.defaultEncoding, invariant=rl_config.invariant,
encoding = None, invariant = None,
def __init__(self,filename, pagesize=(595.27,841.89), bottomup = 1, pageCompression=None, encoding=rl_config.defaultEncoding, invariant=rl_config.invariant, verbosity=0): """Create a canvas of a given size. etc. Most of the attributes are private - we will use set/get methods as the preferred interface. Default page size is A4.""" self._filename = filename self._encodingName = encoding self._doc = pdfdoc.PDFDocument(encoding, compression=pageCompression, invariant=invariant)
0dfc32eaeaff74aae5d82442e8308a1c0f42c955 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0dfc32eaeaff74aae5d82442e8308a1c0f42c955/canvas.py
do_exec(cvs+(' export -r %s reportlab' % tagname), 'the export phase')
do_exec(cvs+(' export -r %s %s' % (tagname,projdir)), 'the export phase')
def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s reportlab' % tagname), 'the export phase') else: if py2pdf: do_exec(cvs+' co reportlab', 'the checkout phase') # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst, "mv py2pdf.py") do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst, "mv pyfontify.py") do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt", "rm") do_exec("mv reportlab %s" % dst) CVS_remove(dst) else: do_exec(cvs+' co reportlab', 'the checkout phase')
b44cd49e99d91cc912ae3ae1309819e6423841a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b44cd49e99d91cc912ae3ae1309819e6423841a9/daily.py
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: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s reportlab' % tagname), 'the export phase') else: if py2pdf: do_exec(cvs+' co reportlab', 'the checkout phase') # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst, "mv py2pdf.py") do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst, "mv pyfontify.py") do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt", "rm") do_exec("mv reportlab %s" % dst) CVS_remove(dst) else: do_exec(cvs+' co reportlab', 'the checkout phase')
b44cd49e99d91cc912ae3ae1309819e6423841a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b44cd49e99d91cc912ae3ae1309819e6423841a9/daily.py
do_exec("mv reportlab %s" % dst)
do_exec("mv %s %s" % (projdir,dst), "moving %s to %s" %(projdir,py2pdf_dir))
def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s reportlab' % tagname), 'the export phase') else: if py2pdf: do_exec(cvs+' co reportlab', 'the checkout phase') # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst, "mv py2pdf.py") do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst, "mv pyfontify.py") do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt", "rm") do_exec("mv reportlab %s" % dst) CVS_remove(dst) else: do_exec(cvs+' co reportlab', 'the checkout phase')
b44cd49e99d91cc912ae3ae1309819e6423841a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b44cd49e99d91cc912ae3ae1309819e6423841a9/daily.py
else: 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: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s reportlab' % tagname), 'the export phase') else: if py2pdf: do_exec(cvs+' co reportlab', 'the checkout phase') # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst, "mv py2pdf.py") do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst, "mv pyfontify.py") do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt", "rm") do_exec("mv reportlab %s" % dst) CVS_remove(dst) else: do_exec(cvs+' co reportlab', 'the checkout phase')
b44cd49e99d91cc912ae3ae1309819e6423841a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b44cd49e99d91cc912ae3ae1309819e6423841a9/daily.py
This document is both the user guide and the output of the test script.
This document is both the user guide &amp; the output of the test script.
def getCommentary(): """Returns the story for the commentary - all the paragraphs.""" styleSheet = getSampleStyleSheet() story = [] story.append(Paragraph(""" PLATYPUS User Guide and Test Script """, styleSheet['Heading1'])) spam = """ Welcome to PLATYPUS! Platypus stands for "Page Layout and Typography Using Scripts". It is a high level page layout library which lets you programmatically create complex documents with a minimum of effort. This document is both the user guide and the output of the test script. In other words, a script used platypus to create the document you are now reading, and the fact that you are reading it proves that it works. Or rather, that it worked for this script anyway. It is a first release! Platypus is built 'on top of' PDFgen, the Python library for creating PDF documents. To learn about PDFgen, read the document testpdfgen.pdf. """ for text in getParagraphs(spam): story.append(Paragraph(text, styleSheet['BodyText'])) story.append(Paragraph(""" What concepts does PLATYPUS deal with? """, styleSheet['Heading2'])) story.append(Paragraph(""" The central concepts in PLATYPUS are Flowable Objects, Frames, Flow Management, Styles and Style Sheets, Paragraphs and Tables. This is best explained in contrast to PDFgen, the layer underneath PLATYPUS. PDFgen is a graphics library, and has primitive commans to draw lines and strings. There is nothing in it to manage the flow of text down the page. PLATYPUS works at the conceptual level fo a desktop publishing package; you can write programs which deal intelligently with graphic objects and fit them onto the page. """, styleSheet['BodyText'])) story.append(Paragraph(""" How is this document organized? """, styleSheet['Heading2'])) story.append(Paragraph(""" Since this is a test script, we'll just note how it is organized. the top of each page contains commentary. The bottom half contains example drawings and graphic elements to whicht he commentary will relate. Down below, you can see the outline of a text frame, and various bits and pieces within it. We'll explain how they work on the next page. """, styleSheet['BodyText'])) story.append(FrameBreak()) ####################################################################### # Commentary Page 2 ####################################################################### story.append(Paragraph(""" Flowable Objects """, styleSheet['Heading2'])) spam = """ The first and most fundamental concept is that of a 'Flowable Object'. In PDFgen, you draw stuff by calling methods of the canvas to set up the colors, fonts and line styles, and draw the graphics primitives. If you set the pen color to blue, everything you draw after will be blue until you change it again. And you have to handle all of the X-Y coordinates yourself. A 'Flowable object' is exactly what it says. It knows how to draw itself on the canvas, and the way it does so is totally independent of what you drew before or after. Furthermore, it draws itself at the location on the page you specify. The most fundamental Flowable Objects in most documents are likely to be paragraphs, tables, diagrams/charts and images - but there is no restriction. You can write your own easily, and I hope that people will start to contribute them. PINGO users - we provide a "PINGO flowable" object to let you insert platform-independent graphics into the flow of a document. When you write a flowable object, you inherit from Flowable and must implement two methods. object.wrap(availWidth, availHeight) will be called by other parts of the system, and tells you how much space you have. You should return how much space you are going to use. For a fixed-size object, this is trivial, but it is critical - PLATYPUS needs to figure out if things will fit on the page before drawing them. For other objects such as paragraphs, the height is obviously determined by the available width. The second method is object.draw(). Here, you do whatever you want. The Flowable base class sets things up so that you have an origin of (0,0) for your drawing, and everything will fit nicely if you got the height and width right. It also saves and restores the graphics state around your calls, so you don;t have to reset all the properties you changed. Programs which actually draw a Flowable don't call draw() this directly - they call object.drawOn(canvas, x, y). So you can write code in your own coordinate system, and things can be drawn anywhere on the page (possibly even scaled or rotated). """ for text in getParagraphs(spam): story.append(Paragraph(text, styleSheet['BodyText'])) story.append(FrameBreak()) ####################################################################### # Commentary Page 3 ####################################################################### story.append(Paragraph(""" Available Flowable Objects """, styleSheet['Heading2'])) story.append(Paragraph(""" Platypus comes with a basic set of flowable objects. Here we list their class names and tell you what they do: """, styleSheet['BodyText'])) #we can use the bullet feature to do a definition list story.append(Paragraph(""" <para color=green bcolor=red bg=pink>This is a contrived object to give an example of a Flowable - just a fixed-size box with an X through it and a centred string.</para>""", styleSheet['Definition'], bulletText='XBox ' #hack - spot the extra space after )) story.append(Paragraph(""" This is the basic unit of a document. Paragraphs can be finely tuned and offer a host of properties through their associated ParagraphStyle.""", styleSheet['Definition'], bulletText='Paragraph ' #hack - spot the extra space after )) story.append(Paragraph(""" This is used for printing code and other preformatted text. There is no wrapping, and line breaks are taken where they occur. Many paragraph style properties do not apply. You may supply an optional 'dedent' parameter to trim a number of characters off the front of each line.""", styleSheet['Definition'], bulletText='Preformatted ' #hack - spot the extra space after )) story.append(Paragraph(""" This is a straight wrapper around an external image file. By default the image will be drawn at a scale of one pixel equals one point, and centred in the frame. You may supply an optional width and height.""", styleSheet['Definition'], bulletText='Image ' #hack - spot the extra space after )) story.append(Paragraph(""" This is a table drawing class; it is intended to be simpler than a full HTML table model yet be able to draw attractive output, and behave intelligently when the numbers of rows and columns vary. Still need to add the cell properties (shading, alignment, font etc.)""", styleSheet['Definition'], bulletText='Table ' #hack - spot the extra space after )) story.append(Paragraph(""" This is a 'null object' which merely takes up space on the page. Use it when you want some extra padding betweene elements.""", styleSheet['Definition'], bulletText='Spacer ' #hack - spot the extra space after )) story.append(Paragraph(""" A FrameBreak causes the document to call its handle_frameEnd method.""", styleSheet['Definition'], bulletText='FrameBreak ' #hack - spot the extra space after )) story.append(Paragraph(""" This is in progress, but a macro is basically a chunk of Python code to be evaluated when it is drawn. It could do lots of neat things.""", styleSheet['Definition'], bulletText='Macro ' #hack - spot the extra space after )) story.append(FrameBreak()) story.append(Paragraph( "The next example uses a custom font", styleSheet['Italic'])) story.append(FrameBreak()) return story
eeeb9fd41a3015f142728d4cf5dd8885d32e502b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/eeeb9fd41a3015f142728d4cf5dd8885d32e502b/test_platypus_general.py
unittest.TextTestRunner().run(makeSuite)
unittest.TextTestRunner().run(makeSuite())
def makeSuite(): return makeSuiteForClasses(PlatypusTestCase)
eeeb9fd41a3015f142728d4cf5dd8885d32e502b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/eeeb9fd41a3015f142728d4cf5dd8885d32e502b/test_platypus_general.py
logger.debug("enter Frame.addFromlist() for frame %s" % self.id)
if self._debug: logger.debug("enter Frame.addFromlist() for frame %s" % self.id)
def addFromList(self, drawlist, canv): """Consumes objects from the front of the list until the frame is full. If it cannot fit one object, raises an exception."""
a78519cff3ac9dc2304b952d2d663145562644fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a78519cff3ac9dc2304b952d2d663145562644fe/frames.py
def drawOn(self, canv): if self.effectName: canv.setPageTransition( effectname=self.effectName, direction = self.effectDirection, dimension = self.effectDimension, motion = self.effectMotion, duration = self.effectDuration ) if self.outlineEntry: #gets an outline automatically self.showOutline = 1 #put an outline entry in the left pane tag = self.title canv.bookmarkPage(tag) canv.addOutlineEntry(tag, tag, self.outlineLevel) if self.section: self.section.drawOn(canv) for graphic in self.graphics: graphic.drawOn(canv) for frame in self.frames: frame.drawOn(canv)
37a58cf6954c324d178af4eb2aaa2b76093473fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/37a58cf6954c324d178af4eb2aaa2b76093473fa/pythonpoint.py
def parseData(self): """Try to make sense of the table data!""" rawdata = string.strip(string.join(self.rawBlocks, '')) lines = string.split(rawdata, self.rowDelim) #clean up... lines = map(string.strip, lines) self.data = [] for line in lines: cells = string.split(line, self.fieldDelim) self.data.append(cells)
37a58cf6954c324d178af4eb2aaa2b76093473fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/37a58cf6954c324d178af4eb2aaa2b76093473fa/pythonpoint.py
if self.filename: canv.drawInlineImage( self.filename, self.x, self.y, self.width, self.height )
filename = self.filename if filename: internalname = canv._doc.hasForm(filename) if not internalname: canv.beginForm(filename) canv.saveState() x, y = self.x, self.y w, h = self.width, self.height canv.drawInlineImage(filename, x, y, w, h) canv.restoreState() canv.endForm() canv.doForm(filename) else: canv.doForm(filename)
def drawOn(self, canv): if self.filename: canv.drawInlineImage( self.filename, self.x, self.y, self.width, self.height )
37a58cf6954c324d178af4eb2aaa2b76093473fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/37a58cf6954c324d178af4eb2aaa2b76093473fa/pythonpoint.py
def __init__(self, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.fillColor = None self.strokeColor = (1,1,1) self.lineWidth=0
37a58cf6954c324d178af4eb2aaa2b76093473fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/37a58cf6954c324d178af4eb2aaa2b76093473fa/pythonpoint.py
def __init__(self, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.fillColor = None self.strokeColor = (1,1,1) self.lineWidth=0
37a58cf6954c324d178af4eb2aaa2b76093473fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/37a58cf6954c324d178af4eb2aaa2b76093473fa/pythonpoint.py
def __init__(self, pointlist): self.points = pointlist self.fillColor = None self.strokeColor = (1,1,1) self.lineWidth=0
37a58cf6954c324d178af4eb2aaa2b76093473fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/37a58cf6954c324d178af4eb2aaa2b76093473fa/pythonpoint.py
print """PythonPoint - copyright ReportLab Inc. 1999-2000
print """PythonPoint - copyright ReportLab Inc. 1999-2001
def process(datafilename, speakerNotes=0): parser = stdparser.PPMLParser() rawdata = open(datafilename).read() parser.feed(rawdata) pres = parser.getPresentation() pres.speakerNotes = speakerNotes pres.save() print 'saved presentation %s.pdf' % os.path.splitext(datafilename)[0] parser.close()
37a58cf6954c324d178af4eb2aaa2b76093473fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/37a58cf6954c324d178af4eb2aaa2b76093473fa/pythonpoint.py
return type(t) in SeqTypes
return type(v) in SeqTypes
def isSeqType(v): return type(t) in SeqTypes
09c05ef6c374a9918dca633cc3cfde05bbd0babf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/09c05ef6c374a9918dca633cc3cfde05bbd0babf/utils.py
print find_intersections([[(0,0.5),(1,0.5),(0.5,0),(0.5,1)],[(2666666667,0.4),(0.1,0.4),(0.1,0.2),(0,0),(1,1)],[(0,1),(0.4,0.1),(1,0.1)]])
print find_intersections([[(0,0.5),(1,0.5),(0.5,0),(0.5,1)],[(.2666666667,0.4),(0.1,0.4),(0.1,0.2),(0,0),(1,1)],[(0,1),(0.4,0.1),(1,0.1)]])
def find_intersections(data,small=0): ''' data is a sequence of series each series is a list of (x,y) coordinates where x & y are ints or floats find_intersections returns a sequence of 4-tuples i, j, x, y where i is a data index j is an insertion position for data[i] and x, y are coordinates of an intersection of series data[i] with some other series. If correctly implemented we get all such intersections. We don't count endpoint intersections and consider parallel lines as non intersecting (even when coincident). We ignore segments that have an estimated size less than small. ''' #find all line segments S = [] a = S.append for s in xrange(len(data)): ds = data[s] if not ds: continue n = len(ds) if n==1: continue for i in xrange(1,n): seg = _Segment(s,i,data) if seg.a+abs(seg.b)>=small: a(seg) S.sort(_segCmp) I = [] n = len(S) for i in xrange(0,n-1): s = S[i] for j in xrange(i+1,n): if s.intersect(S[j],I)==1: break I.sort() return I
0992e0cec07925841eb0fc4c23981740c85d52b7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0992e0cec07925841eb0fc4c23981740c85d52b7/utils3d.py
f = self.labelTextFormat and self._allIntTicks() and '%d' or str
f = self.labelTextFormat or (self._allIntTicks() and '%d' or str)
def makeTickLabels(self): g = Group()
c4a20834e65ae1e01472a47ce79888fd77bee387 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/c4a20834e65ae1e01472a47ce79888fd77bee387/axes.py
if self.bottomup: self._preamble = '1 0 0 1 0 0 cm BT /F9 12 Tf 14.4 TL ET' else: self._preamble = '1 0 0 -1 0 %0.2f cm BT /F9 12 Tf 14.4 TL ET' % self._pagesize[1]
self._make_preamble()
def __init__(self,filename,pagesize=(595.27,841.89), bottomup = 1, pageCompression=0 ): """Most of the attributes are private - we will use set/get methods as the preferred interface. Default page size is A4.""" self._filename = filename self._doc = pdfdoc.PDFDocument() self._pagesize = pagesize self._currentPageHasImages = 1 self._pageTransitionString = ''
c0956523058c8076c72d8def32a7c2d5841b1743 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/c0956523058c8076c72d8def32a7c2d5841b1743/canvas.py
txt = open(filename, 'r').read()
txt = open_and_read(filename, 'r')
def checkFileForTabs(self, filename): txt = open(filename, 'r').read() chunks = string.split(txt, '\t') tabCount = len(chunks) - 1 if tabCount: #raise Exception, "File %s contains %d tab characters!" % (filename, tabCount) self.output.write("file %s contains %d tab characters!\n" % (filename, tabCount))
f709459e51a2085fda6903cbd288add39f9707e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f709459e51a2085fda6903cbd288add39f9707e6/test_source_chars.py
txt = open(filename, 'r').read()
txt = open_and_read(filename, 'r')
def checkFileForTrailingSpaces(self, filename): txt = open(filename, 'r').read() initSize = len(txt) badLines = 0 badChars = 0 for line in string.split(txt, '\n'): stripped = string.rstrip(line) spaces = len(line) - len(stripped) # OK, so they might be trailing tabs, who cares? if spaces: badLines = badLines + 1 badChars = badChars + spaces
f709459e51a2085fda6903cbd288add39f9707e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f709459e51a2085fda6903cbd288add39f9707e6/test_source_chars.py