bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def dumpXPreformattedLines(P): print 'dumpXPreforemattedLines(%s)' % str(P) lines = P.bfrags.lines n =len(lines) for l in range(n): line = lines[l] words = line.words nwords = len(words) print 'line%d: %d(%d)\n ' % (l,nwords,line.wordCount), for w in range(nwords): print "%d:'%s'"%(w,words[w].text), print
|
def dumpXPreformattedLines(P): print '\n lines = P.bfrags.lines n =len(lines) for l in range(n): line = lines[l] words = line.words nwords = len(words) print 'line%d: %d(%d)\n ' % (l,nwords,line.wordCount), for w in range(nwords): print "%d:'%s'"%(w,words[w].text), print
| 4,600
|
def dumpXPreformattedFrags(P): print 'dumpXPreforemattedFrags(%s)' % str(P) frags = P.frags n =len(frags) for l in range(n): print "frag%d: '%s'" % (l, frags[l].text) l = 0 for L in _getFragLines(frags): n=0 for W in _getFragWords(L): print "frag%d.%d: size=%d" % (l, n, W[0]), n = n + 1 for w in W[1:]: print "'%s'" % w[1], print l = l + 1
|
def dumpXPreformattedFrags(P): print '\n frags = P.frags n =len(frags) for l in range(n): print "frag%d: '%s'" % (l, frags[l].text) l = 0 for L in _getFragLines(frags): n=0 for W in _getFragWords(L): print "frag%d.%d: size=%d" % (l, n, W[0]), n = n + 1 for w in W[1:]: print "'%s'" % w[1], print l = l + 1
| 4,601
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
|
def try_it(text,style,dedent,aW,aH): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
| 4,602
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
| 4,603
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
| 4,604
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
| 4,605
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
| 4,606
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
| 4,607
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
|
def try_it(text,style,dedent): P=XPreformatted(text,style,dedent=dedent) dumpXPreformattedFrags(P) aW, aH = 456.0, 42.8 w,h = P.wrap(aW, aH) dumpXPreformattedLines(P) S = P.split(aW,aH) for s in S: s.wrap(aW,aH) dumpXPreformattedLines(s) aH = 500
| 4,608
|
def verify(self): """If the _attrMap attribute is not None, this checks all expected attributes are present; no unwanted attributes are present; and (if a checking function is found) checks each attribute has a valid value. Either succeeds or raises an informative exception. """
|
def verify(self): """If the _attrMap attribute is not None, this checks all expected attributes are present; no unwanted attributes are present; and (if a checking function is found) checks each attribute has a valid value. Either succeeds or raises an informative exception. """
| 4,609
|
def verify(self): """If the _attrMap attribute is not None, this checks all expected attributes are present; no unwanted attributes are present; and (if a checking function is found) checks each attribute has a valid value. Either succeeds or raises an informative exception. """
|
defverify(self):"""Ifthe_attrMapattributeisnotNone,thischecksallexpectedattributesarepresent;nounwantedattributesarepresent;and(ifacheckingfunctionisfound)checkseachattributehasavalidvalue.Eithersucceedsorraisesaninformativeexception."""
| 4,610
|
def save(self): """Saves the file. If holding data, do a showPage() to save them having to.""" if len(self._code): self.showPage()
|
def save(self): """Saves the file. If holding data, do a showPage() to save them having to.""" if len(self._code): self.showPage()
| 4,611
|
def __init__(self, name): self.name = name self.glyphNames = [] self.glyphWidths = {} self.ascent = 0 self.descent = 0 if name == 'ZapfDingbats': self.requiredEncoding = 'ZapfDingbatsEncoding' elif name == 'Symbol': self.requiredEncoding = 'SymbolEncoding' else: self.requiredEncoding = None
|
def__init__(self,name):self.name=nameself.glyphNames=[]self.glyphWidths={}self.ascent=0self.descent=0ifname=='ZapfDingbats':self.requiredEncoding='ZapfDingbatsEncoding'elifname=='Symbol':self.requiredEncoding='SymbolEncoding'else:self.requiredEncoding=None
| 4,612
|
def _loadBuiltInData(self, name): """Called for the built in 14 fonts. Gets their glyph data.
|
def_loadBuiltInData(self,name):"""Calledforthebuiltin14fonts.Getstheirglyphdata.
| 4,613
|
def __init__(self, fileName): if isinstance(fileName,ImageReader): self.__dict__ = fileName.__dict__ #borgize return if not haveImages: raise RuntimeError('Imaging Library not available, unable to import bitmaps') #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None if _isPILImage(fileName): self._image = fileName self.fp = fileName.fp try: self.fileName = im.fileName except AttributeError: self.fileName = 'PILIMAGE_%d' % id(self) else: try: self.fp = open_for_read(fileName,'b') #detect which library we are using and open the image if sys.platform[0:4] == 'java': from javax.imageio import ImageIO self._image = ImageIO.read(self.fp) else: import PIL.Image self._image = PIL.Image.open(self.fp) if self._image=='JPEG': self.jpeg_fh = self._jpeg_fp except: et,ev,tb = sys.exc_info() if hasattr(ev,'args'): a = str(ev.args[-1])+(' fileName='+fileName) ev.args= ev.args[:-1]+(a,) raise et,ev,tb else: raise
|
def __init__(self, fileName): if isinstance(fileName,ImageReader): self.__dict__ = fileName.__dict__ #borgize return if not haveImages: raise RuntimeError('Imaging Library not available, unable to import bitmaps') #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None if _isPILImage(fileName): self._image = fileName self.fp = fileName.fp try: self.fileName = fileName except AttributeError: self.fileName = 'PILIMAGE_%d' % id(self) else: try: self.fp = open_for_read(fileName,'b') #detect which library we are using and open the image if sys.platform[0:4] == 'java': from javax.imageio import ImageIO self._image = ImageIO.read(self.fp) else: import PIL.Image self._image = PIL.Image.open(self.fp) if self._image=='JPEG': self.jpeg_fh = self._jpeg_fp except: et,ev,tb = sys.exc_info() if hasattr(ev,'args'): a = str(ev.args[-1])+(' fileName='+fileName) ev.args= ev.args[:-1]+(a,) raise et,ev,tb else: raise
| 4,614
|
def __init__(self): self.x = 0 self.y = 0 self.width = 100 self.height = 100 self.data = [1] self.labels = None # or list of strings self.startAngle = 90 self.direction = "clockwise"
|
def __init__(self): self.x = 0 self.y = 0 self.width = 100 self.height = 100 self.data = [1,1] self.labels = None # or list of strings self.startAngle = 90 self.direction = "clockwise"
| 4,615
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,616
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,617
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,618
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,619
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,620
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,621
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,622
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
| 4,623
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
defmakeSectors(self):#normalizeslicedataiftype(self.data)in(ListType,TupleType)andtype(self.data[0])in(ListType,TupleType):#it'sanestedlist,morethanonesequencenormData=[]forlinself.data:t=self.normalizeData(l)normData.append(t)else:normData=self.normalizeData(self.data)n=len(normData)
| 4,624
|
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
|
defmakeSectors(self):#normalizeslicedataiftype(self.data)in(ListType,TupleType)andtype(self.data[0])in(ListType,TupleType):#it'sanestedlist,morethanonesequencenormData=[]forlinself.data:t=self.normalizeData(l)normData.append(t)else:normData=self.normalizeData(self.data)n=len(normData)
| 4,625
|
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
|
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
| 4,626
|
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
|
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
| 4,627
|
def registerTypeFace(face): assert isinstance(face, TypeFace), 'Not a TypeFace: %s' % face _typefaces[face.name] = face # HACK - bold/italic do not apply for type 1, so egister # all combinations of mappings. from reportlab.lib import fonts ttname = string.lower(face.name) fonts.addMapping(ttname, 0, 0, face.name) fonts.addMapping(ttname, 1, 0, face.name) fonts.addMapping(ttname, 0, 1, face.name) fonts.addMapping(ttname, 1, 1, face.name)
|
def registerTypeFace(face): assert isinstance(face, TypeFace), 'Not a TypeFace: %s' % face _typefaces[face.name] = face # HACK - bold/italic do not apply for type 1, so egister # all combinations of mappings. from reportlab.lib import fonts ttname = string.lower(face.name) if not face.name in standardFonts: fonts.addMapping(ttname, 0, 0, face.name) fonts.addMapping(ttname, 1, 0, face.name) fonts.addMapping(ttname, 0, 1, face.name) fonts.addMapping(ttname, 1, 1, face.name)
| 4,628
|
def makeTickLabels(self): g = Group() if not self.visibleLabels: return g
|
def makeTickLabels(self): g = Group() if not self.visibleLabels: return g
| 4,629
|
def rl_isdir(pn,os_path_isdir=os.path.isdir,os_path_normpath=os.path.normpath): if os_path_isdir(pn): return True if _isFSD or __loader__ is None: return False pn = os_path_normpath(pn) return len(filter(lambda x,pn=pn: x.startswith(pn),__loader__._files.keys()))>0
|
def rl_isdir(pn,os_path_isdir=os.path.isdir,os_path_normpath=os.path.normpath): if os_path_isdir(pn): return True if _isFSD or __loader__ is None: return False pn = _startswith_rl(os_path_normpath(pn)) if not pn.endswith(os.sep): pn += os.sep return len(filter(lambda x,pn=pn: x.startswith(pn),__loader__._files.keys()))>0
| 4,630
|
def expandUserNodes(self): """Return a new object which only contains primitive shapes."""
|
def expandUserNodes(self): """Return a new object which only contains primitive shapes."""
| 4,631
|
def _setRange(self, dataSeries): """Set minimum and maximum axis values.
|
def _setRange(self, dataSeries): """Set minimum and maximum axis values.
| 4,632
|
def rl_get_module(name,dir): if sys.modules.has_key(name): om = sys.modules[name] del sys.modules[name] else: om = None try: f = None try: f, p, desc= imp.find_module(name,[dir]) return imp.load_module(name,f,p,desc) except: if isCompactDistro(): #attempt a load from inside the zip archive import zipimport dir = _startswith_rl(dir) dir = dir and os.path.join(_archive,dir.replace('/',os.sep)) or _archive zi = zipimport.zipimporter(dir) return zi.load_module(name) raise ImportError('%s[%s]' % (name,dir)) finally: if om: sys.modules[name] = om del om if f: f.close()
|
def rl_get_module(name,dir): if sys.modules.has_key(name): om = sys.modules[name] del sys.modules[name] else: om = None try: f = None try: f, p, desc= imp.find_module(name,[dir]) return imp.load_module(name,f,p,desc) except: if isCompactDistro(): #attempt a load from inside the zip archive import zipimport dir = _startswith_rl(dir) dir = (dir=='.' or not dir) and _archive or os.path.join(_archive,dir.replace('/',os.sep)) zi = zipimport.zipimporter(dir) return zi.load_module(name) raise ImportError('%s[%s]' % (name,dir)) finally: if om: sys.modules[name] = om del om if f: f.close()
| 4,633
|
def colorDistance(col1, col2): """Returns a number between 0 and root(3) stating how similar two colours are - distance in r,g,b, space. Only used to find names for things.""" return math.sqrt( (col1.red - col2.red)**2 + (col1.green - col2.green)**2 + (col1.blue - col2.blue)**2 )
|
def colorDistance(col1, col2): """Returns a number between 0 and root(3) stating how similar two colours are - distance in r,g,b, space. Only used to find names for things.""" return math.sqrt( (col1.red - col2.red)**2 + (col1.green - col2.green)**2 + (col1.blue - col2.blue)**2 )
| 4,634
|
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency if __namedColors is not None: return __namedColors import colors __namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): __namedColors[name] = value return __namedColors
|
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency global _namedColors if _namedColors is not None: return _namedColors import colors __namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): __namedColors[name] = value return __namedColors
| 4,635
|
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency if __namedColors is not None: return __namedColors import colors __namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): __namedColors[name] = value return __namedColors
|
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency if __namedColors is not None: return __namedColors import colors _namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): __namedColors[name] = value return __namedColors
| 4,636
|
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency if __namedColors is not None: return __namedColors import colors __namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): __namedColors[name] = value return __namedColors
|
def getAllNamedColors(): #returns a dictionary of all the named ones in the module # uses a singleton for efficiency if __namedColors is not None: return __namedColors import colors __namedColors = {} for (name, value) in colors.__dict__.items(): if isinstance(value, Color): _namedColors[name] = value return _namedColors
| 4,637
|
def beginAttributes(self, aClass): "Append a list of annotated attributes of a class."
|
def beginAttributes(self, aClass): "Append a list of annotated attributes of a class."
| 4,638
|
def wrap(self, aW, aH): W = 0 H = 0 F = self._flowables for f in F: w,h = f.wrap(aW,0xfffffff) if f is not F[0]: h = h + f.getSpaceBefore() if f is not F[-1]: h = h + f.getSpaceAfter() W = max(W,w) H = H+h print 'wrap', aW, aH, W, H self._CPage = H>aH return W, 0xffffff # force a split
|
def wrap(self, aW, aH): W = 0 H = 0 F = self._flowables for f in F: w,h = f.wrap(aW,0xfffffff) if f is not F[0]: h = h + f.getSpaceBefore() if f is not F[-1]: h = h + f.getSpaceAfter() W = max(W,w) H = H+h self._CPage = H>aH return W, 0xffffff # force a split
| 4,639
|
def split(self, aW, aH): print 'wrap', aW, aH, self._CPage S = self._CPage and [CondPageBreak(aH+1)] or [] for f in self._flowables: S.append(f) return S
|
def split(self, aW, aH): S = self._CPage and [CondPageBreak(aH+1)] or [] for f in self._flowables: S.append(f) return S
| 4,640
|
def loadImageFromA85(self,source): IMG=[] imagedata = map(string.strip,pdfutils.cacheImageFile(source,returnInMemory=1,IMG=IMG)) words = string.split(imagedata[1]) self.width, self.height = map(string.atoi,(words[1],words[3])) self.colorSpace = 'DeviceRGB' self.bitsPerComponent = 8 self._filters = 'A85','Fl' if IMG: self._checkTransparency(IMG[0]) else: self.mask = None self.streamContent = string.join(imagedata[2:-1],'')
|
def loadImageFromA85(self,source): IMG=[] imagedata = map(string.strip,pdfutils.cacheImageFile(source,returnInMemory=1,IMG=IMG)) words = string.split(imagedata[1]) self.width, self.height = map(string.atoi,(words[1],words[3])) self.colorSpace = 'DeviceRGB' self.bitsPerComponent = 8 self._filters = 'A85','Fl' if IMG: self._checkTransparency(IMG[0]) else: self.mask = None self.streamContent = string.join(imagedata[2:-1],'')
| 4,641
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, _py_getFont, registerFont from reportlab.pdfbase.ttfonts import TTFont from sys import getrefcount ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12. def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, getFont, registerFont, _fonts from reportlab.pdfbase.ttfonts import TTFont from sys import getrefcount ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12. def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
| 4,642
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, _py_getFont, registerFont from reportlab.pdfbase.ttfonts import TTFont from sys import getrefcount ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12. def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, _py_getFont, registerFont from reportlab.pdfbase.ttfonts import TTFont ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12. def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
| 4,643
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, _py_getFont, registerFont from reportlab.pdfbase.ttfonts import TTFont from sys import getrefcount ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12. def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, _py_getFont, registerFont from reportlab.pdfbase.ttfonts import TTFont from sys import getrefcount ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = getFont(ttfn) t1f = getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12. def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
| 4,644
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, _py_getFont, registerFont from reportlab.pdfbase.ttfonts import TTFont from sys import getrefcount ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12. def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
|
def testStringWidth(self): from _rl_accel import stringWidthU from reportlab.pdfbase.pdfmetrics import _py_stringWidth, _py_getFont, registerFont from reportlab.pdfbase.ttfonts import TTFont from sys import getrefcount ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' intern(senc) ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode('utf8') fontSize = 12 defns="ttfn t1fn ttf t1f testCp1252 enc senc ts utext fontSize ttf.face ttf.face.charWidths ttf.face.defaultWidth t1f.widths t1f.encName t1f.substitutionFonts _fonts" rcv = getrc(defns) def tfunc(ts,fn,fontSize,enc): w1 = stringWidthU(ts,fn,fontSize,enc) w2 = _py_stringWidth(ts,fn,fontSize,enc) assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2) tfunc(testCp1252,t1fn,fontSize,enc) tfunc(ts,t1fn,fontSize,senc) tfunc(utext,t1fn,fontSize,senc) tfunc(ts,ttfn,fontSize,senc) tfunc(testCp1252,ttfn,fontSize,enc) tfunc(utext,ttfn,fontSize,senc)
| 4,645
|
def test_instanceStringWidth(self): from reportlab.pdfbase.pdfmetrics import registerFont, _py_getFont from reportlab.pdfbase.ttfonts import TTFont ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode(senc) fontSize = 12. def tfunc(f,ts,fontSize,enc): w1 = f.stringWidth(ts,fontSize,enc) w2 = f._py_stringWidth(ts,fontSize,enc) assert abs(w1-w2)<1e-10,"f(%r).stringWidthU(%r,%s,%r)-->%r != f._py_stringWidth(...)-->%r" % (f,ts,fontSize,enc,w1,w2) tfunc(t1f,testCp1252,fontSize,enc) tfunc(t1f,ts,fontSize,senc) tfunc(t1f,utext,fontSize,senc) tfunc(ttf,ts,fontSize,senc) tfunc(ttf,testCp1252,fontSize,enc) tfunc(ttf,utext,fontSize,senc)
|
def test_instanceStringWidth(self): from reportlab.pdfbase.pdfmetrics import registerFont, getFont, _fonts, unicode2T1 from reportlab.pdfbase.ttfonts import TTFont ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode(senc) fontSize = 12. def tfunc(f,ts,fontSize,enc): w1 = f.stringWidth(ts,fontSize,enc) w2 = f._py_stringWidth(ts,fontSize,enc) assert abs(w1-w2)<1e-10,"f(%r).stringWidthU(%r,%s,%r)-->%r != f._py_stringWidth(...)-->%r" % (f,ts,fontSize,enc,w1,w2) tfunc(t1f,testCp1252,fontSize,enc) tfunc(t1f,ts,fontSize,senc) tfunc(t1f,utext,fontSize,senc) tfunc(ttf,ts,fontSize,senc) tfunc(ttf,testCp1252,fontSize,enc) tfunc(ttf,utext,fontSize,senc)
| 4,646
|
def test_instanceStringWidth(self): from reportlab.pdfbase.pdfmetrics import registerFont, _py_getFont from reportlab.pdfbase.ttfonts import TTFont ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode(senc) fontSize = 12. def tfunc(f,ts,fontSize,enc): w1 = f.stringWidth(ts,fontSize,enc) w2 = f._py_stringWidth(ts,fontSize,enc) assert abs(w1-w2)<1e-10,"f(%r).stringWidthU(%r,%s,%r)-->%r != f._py_stringWidth(...)-->%r" % (f,ts,fontSize,enc,w1,w2) tfunc(t1f,testCp1252,fontSize,enc) tfunc(t1f,ts,fontSize,senc) tfunc(t1f,utext,fontSize,senc) tfunc(ttf,ts,fontSize,senc) tfunc(ttf,testCp1252,fontSize,enc) tfunc(ttf,utext,fontSize,senc)
|
def test_instanceStringWidth(self): from reportlab.pdfbase.pdfmetrics import registerFont, _py_getFont from reportlab.pdfbase.ttfonts import TTFont ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = getFont(ttfn) t1f = getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode(senc) fontSize = 12. def tfunc(f,ts,fontSize,enc): w1 = f.stringWidth(ts,fontSize,enc) w2 = f._py_stringWidth(ts,fontSize,enc) assert abs(w1-w2)<1e-10,"f(%r).stringWidthU(%r,%s,%r)-->%r != f._py_stringWidth(...)-->%r" % (f,ts,fontSize,enc,w1,w2) tfunc(t1f,testCp1252,fontSize,enc) tfunc(t1f,ts,fontSize,senc) tfunc(t1f,utext,fontSize,senc) tfunc(ttf,ts,fontSize,senc) tfunc(ttf,testCp1252,fontSize,enc) tfunc(ttf,utext,fontSize,senc)
| 4,647
|
def test_instanceStringWidth(self): from reportlab.pdfbase.pdfmetrics import registerFont, _py_getFont from reportlab.pdfbase.ttfonts import TTFont ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode(senc) fontSize = 12. def tfunc(f,ts,fontSize,enc): w1 = f.stringWidth(ts,fontSize,enc) w2 = f._py_stringWidth(ts,fontSize,enc) assert abs(w1-w2)<1e-10,"f(%r).stringWidthU(%r,%s,%r)-->%r != f._py_stringWidth(...)-->%r" % (f,ts,fontSize,enc,w1,w2) tfunc(t1f,testCp1252,fontSize,enc) tfunc(t1f,ts,fontSize,senc) tfunc(t1f,utext,fontSize,senc) tfunc(ttf,ts,fontSize,senc) tfunc(ttf,testCp1252,fontSize,enc) tfunc(ttf,utext,fontSize,senc)
|
def test_instanceStringWidth(self): from reportlab.pdfbase.pdfmetrics import registerFont, _py_getFont from reportlab.pdfbase.ttfonts import TTFont ttfn = 'Luxi-Serif' t1fn = 'Times-Roman' registerFont(TTFont(ttfn, "luxiserif.ttf")) ttf = _py_getFont(ttfn) t1f = _py_getFont(t1fn) testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9)) enc='cp1252' senc = 'utf8' ts = 'ABCDEF\xce\x91\xce\xb2G' utext = 'ABCDEF\xce\x91\xce\xb2G'.decode(senc) fontSize = 12 defns="ttfn t1fn ttf t1f testCp1252 enc senc ts utext fontSize ttf.face ttf.face.charWidths ttf.face.defaultWidth t1f.widths t1f.encName t1f.substitutionFonts _fonts" rcv = getrc(defns) def tfunc(f,ts,fontSize,enc): w1 = f.stringWidth(ts,fontSize,enc) w2 = f._py_stringWidth(ts,fontSize,enc) assert abs(w1-w2)<1e-10,"f(%r).stringWidthU(%r,%s,%r)-->%r != f._py_stringWidth(...)-->%r" % (f,ts,fontSize,enc,w1,w2) tfunc(t1f,testCp1252,fontSize,enc) tfunc(t1f,ts,fontSize,senc) tfunc(t1f,utext,fontSize,senc) tfunc(ttf,ts,fontSize,senc) tfunc(ttf,testCp1252,fontSize,enc) tfunc(ttf,utext,fontSize,senc)
| 4,648
|
def test_unicode2T1(self): from reportlab.pdfbase.pdfmetrics import _py_unicode2T1, _py_getFont from _rl_accel import unicode2T1 t1fn = 'Times-Roman' t1f = _py_getFont(t1fn) enc = 'cp1252' senc = 'utf8' testCp1252 = ('copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9))).decode(enc) utext = 'This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86. This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86'.decode('utf8') def tfunc(f,ts): w1 = unicode2T1(ts,[f]+f.substitutionFonts) w2 = _py_unicode2T1(ts,[f]+f.substitutionFonts) assert w1==w2,"%r != %r" % (w1,w2) tfunc(t1f,testCp1252) tfunc(t1f,utext)
|
def test_unicode2T1(self): from reportlab.pdfbase.pdfmetrics import _py_unicode2T1, getFont, _fonts from _rl_accel import unicode2T1 t1fn = 'Times-Roman' t1f = _py_getFont(t1fn) enc = 'cp1252' senc = 'utf8' testCp1252 = ('copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9))).decode(enc) utext = 'This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86. This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86'.decode('utf8') def tfunc(f,ts): w1 = unicode2T1(ts,[f]+f.substitutionFonts) w2 = _py_unicode2T1(ts,[f]+f.substitutionFonts) assert w1==w2,"%r != %r" % (w1,w2) tfunc(t1f,testCp1252) tfunc(t1f,utext)
| 4,649
|
def test_unicode2T1(self): from reportlab.pdfbase.pdfmetrics import _py_unicode2T1, _py_getFont from _rl_accel import unicode2T1 t1fn = 'Times-Roman' t1f = _py_getFont(t1fn) enc = 'cp1252' senc = 'utf8' testCp1252 = ('copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9))).decode(enc) utext = 'This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86. This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86'.decode('utf8') def tfunc(f,ts): w1 = unicode2T1(ts,[f]+f.substitutionFonts) w2 = _py_unicode2T1(ts,[f]+f.substitutionFonts) assert w1==w2,"%r != %r" % (w1,w2) tfunc(t1f,testCp1252) tfunc(t1f,utext)
|
def test_unicode2T1(self): from reportlab.pdfbase.pdfmetrics import _py_unicode2T1, _py_getFont from _rl_accel import unicode2T1 t1fn = 'Times-Roman' t1f = getFont(t1fn) enc = 'cp1252' senc = 'utf8' testCp1252 = ('copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9))).decode(enc) utext = 'This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86. This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86'.decode('utf8') def tfunc(f,ts): w1 = unicode2T1(ts,[f]+f.substitutionFonts) w2 = _py_unicode2T1(ts,[f]+f.substitutionFonts) assert w1==w2,"%r != %r" % (w1,w2) tfunc(t1f,testCp1252) tfunc(t1f,utext)
| 4,650
|
def test_getFont(self): from reportlab.pdfbase.pdfmetrics import _py_getFont from _rl_accel import getFontU t1fn = 'Times-Roman' assert _py_getFont(t1fn) is getFontU(t1fn)
|
def test_getFont(self): from reportlab.pdfbase.pdfmetrics import _py_getFont, getFont from _rl_accel import getFontU t1fn = 'Times-Roman' assert _py_getFont(t1fn) is getFontU(t1fn)
| 4,651
|
def normalizeText(self): """It contains literal XML text typed over several lines. We want to throw away tabs, newlines and so on, and only accept embedded string like '\n'""" lines = string.split(self.text, '\n') newtext = [] for line in lines: newtext.append(string.strip(line)) #eval turns all the escape sequences into real data self.text = eval(string.join(newtext, ' '))
|
def normalizeText(self): """It contains literal XML text typed over several lines. We want to throw away tabs, newlines and so on, and only accept embedded string like '\n'""" lines = string.split(self.text, '\n') newtext = [] for line in lines: newtext.append(string.strip(line)) #eval turns all the escape sequences into real data self.text = newtext
| 4,652
|
def drawOn(self, canv): if self.color is None: return lines = string.split(string.strip(self.text), '\n') canv.saveState() canv.setFont(self.font, self.size) r,g,b = self.color canv.setFillColorRGB(r,g,b) cur_y = self.y for line in lines: if self.align == layout.TA_LEFT: canv.drawString(self.x, cur_y, line) elif self.align == layout.TA_CENTER: canv.drawCentredString(self.x, cur_y, line) elif self.align == layout.TA_RIGHT: canv.drawRightString(self.x, cur_y, line) cur_y = cur_y - 1.2*self.size canv.restoreState()
|
def drawOn(self, canv): if self.color is None: return lines = string.split(string.strip(self.text), '\\n') canv.saveState() canv.setFont(self.font, self.size) r,g,b = self.color canv.setFillColorRGB(r,g,b) cur_y = self.y for line in lines: if self.align == layout.TA_LEFT: canv.drawString(self.x, cur_y, line) elif self.align == layout.TA_CENTER: canv.drawCentredString(self.x, cur_y, line) elif self.align == layout.TA_RIGHT: canv.drawRightString(self.x, cur_y, line) cur_y = cur_y - 1.2*self.size canv.restoreState()
| 4,653
|
def makeDistancesList(list): """Returns a list of distances between adjacent numbers in some input list. E.g. [1, 1, 2, 3, 5, 7] -> [0, 1, 1, 2, 2] """ d = [] for i in range(len(list[:-1])): d.append(list[i+1] - list[i]) return d
|
def makeDistancesList(list): """Returns a list of distances between adjacent numbers in some input list. E.g. [1, 1, 2, 3, 5, 7] -> [0, 1, 1, 2, 2] """ d = [] for i in range(len(list[:-1])): d.append(list[i+1] - list[i]) return d
| 4,654
|
def demo(self): D = Drawing(100, 100)
|
defdemo(self):D=Drawing(100,100)
| 4,655
|
def makeOuterRect(self): # outer grid rectangle group = Group() #print 'Grid.makeOuterRect(%d, %d, %d, %d)' % (self.x, self.y, self.width, self.height) rect = Rect(self.x, self.y, self.width, self.height) rect.fillColor = self.fillColor rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth
|
def makeOuterRect(self): # outer grid rectangle group = Group() #print 'Grid.makeOuterRect(%d, %d, %d, %d)' % (self.x, self.y, self.width, self.height) rect = Rect(self.x, self.y, self.width, self.height) rect.fillColor = self.fillColor rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth
| 4,656
|
def draw(self): # general widget bits group = Group()
|
def draw(self): # general widget bits group = Group()
| 4,657
|
def draw(self): group = Group()
|
defdraw(self):group=Group()
| 4,658
|
def draw(self): group = Group()
|
defdraw(self):group=Group()
| 4,659
|
def draw(self): group = Group()
|
def draw(self): group = Group()
| 4,660
|
def do_exec(cmd, cmdname=None): i=os.popen(cmd,'r') print i.read() i = i.close() if i is not None: if cmdname is not None: print 'Error: '+ cmdname or cmd sys.exit(1)
|
def do_exec(cmd, cmdname=None): i=os.popen(cmd,'r') print i.read() i = i.close() if i is not None: if cmdname is not None: print 'Error: '+ (cmdname or cmd) sys.exit(1)
| 4,661
|
def usage(code=0, msg=''): f = code and sys.stderr or sys.stdout if msg is not None: f.write(msg+'\n') f.write(\
|
def usage(code=0, msg=''): f = code and sys.stderr or sys.stdout if msg is not None: f.write(msg+'\n') f.write(\
| 4,662
|
def _AsciiHexDecode(input): """Decodes input using ASCII-Hex coding. Not used except to provide a test of the inverse function.""" #strip out all whitespace stripped = string.join(string.split(input),'') assert stripped[-1] == '>', 'Invalid terminator for Ascii Hex Stream' stripped = stripped[:-1] #chop off terminator assert len(stripped) % 2 == 0, 'Ascii Hex stream has odd number of bytes' i = 0 output = cStringIO.StringIO() while i < len(stripped): twobytes = stripped[i:i+2] output.write(chr(eval('0x'+twobytes))) i = i + 2 output.reset() return output.read()
|
def _AsciiHexDecode(input): """Decodes input using ASCII-Hex coding. Not used except to provide a test of the inverse function.""" #strip out all whitespace stripped = string.join(string.split(input),'') assert stripped[-1] == '>', 'Invalid terminator for Ascii Hex Stream' stripped = stripped[:-1] #chop off terminator assert len(stripped) % 2 == 0, 'Ascii Hex stream has odd number of bytes' i = 0 output = cStringIO.StringIO() while i < len(stripped): twobytes = stripped[i:i+2] output.write(chr(eval('0x'+twobytes))) i = i + 2 output.reset() return output.read()
| 4,663
|
def _AsciiHexDecode(input): """Decodes input using ASCII-Hex coding. Not used except to provide a test of the inverse function.""" #strip out all whitespace stripped = string.join(string.split(input),'') assert stripped[-1] == '>', 'Invalid terminator for Ascii Hex Stream' stripped = stripped[:-1] #chop off terminator assert len(stripped) % 2 == 0, 'Ascii Hex stream has odd number of bytes' i = 0 output = cStringIO.StringIO() while i < len(stripped): twobytes = stripped[i:i+2] output.write(chr(eval('0x'+twobytes))) i = i + 2 output.reset() return output.read()
|
def _AsciiHexDecode(input): """Decodes input using ASCII-Hex coding. Not used except to provide a test of the inverse function.""" #strip out all whitespace stripped = string.join(string.split(input),'') assert stripped[-1] == '>', 'Invalid terminator for Ascii Hex Stream' stripped = stripped[:-1] #chop off terminator assert len(stripped) % 2 == 0, 'Ascii Hex stream has odd number of bytes' i = 0 output = cStringIO.StringIO() while i < len(stripped): twobytes = stripped[i:i+2] output.write(chr(eval('0x'+twobytes))) i = i + 2 output.reset() return output.read()
| 4,664
|
def draw(self): _text = self._text self._text = _text or '' self.computeSize() self._text = _text g = Group() g.translate(self.x + self.dx, self.y + self.dy) g.rotate(self.angle)
|
def draw(self): _text = self._text self._text = _text or '' self.computeSize() self._text = _text g = Group() g.translate(self.x + self.dx, self.y + self.dy) g.rotate(self.angle)
| 4,665
|
def format(self, document): self.BBox = self.BBox or PDFArray([self.lowerx, self.lowery, self.upperx, self.uppery]) self.Matrix = self.Matrix or PDFArray([1, 0, 0, 1, 0, 0]) if not self.Annots: self.Annots = None else:
|
def format(self, document): self.BBox = self.BBox or PDFArray([self.lowerx, self.lowery, self.upperx, self.uppery]) self.Matrix = self.Matrix or PDFArray([1, 0, 0, 1, 0, 0]) if not self.Annots: self.Annots = None else:
| 4,666
|
def loadImageFromPIL(self, PILImage): "Extracts the stream, width and height" zlib = import_zlib() if not zlib: return #standardize it to RGB. We could be more optimal later. if PILImage.mode <> 'RGB': PILImage = PILImage.convert('RGB') imgwidth, imgheight = PILImage.size raw = PILImage.tostring() assert(len(raw) == imgwidth * imgheight, "Wrong amount of data for image") compressed = zlib.compress(raw) encoded = pdfutils._AsciiBase85Encode(compressed) self.colorSpace = 'DeviceRGB' self.bitsPerComponent = 8 self.streamContent = encoded self.width = imgwidth self.height = imgheight
|
defif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None loadImageFromPIL(self,if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None PILImage):if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None "Extractsif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None theif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None stream,if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None widthif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None andif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None height"if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None zlibif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None import_zlib()if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None ifif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None notif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None zlib:if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None returnif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None #standardizeif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None itif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None toif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None RGB.if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None Weif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None couldif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None beif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None moreif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None optimalif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None later.if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None ifif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None PILImage.modeif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None <>if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None 'RGB':if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None PILImageif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None PILImage.convert('RGB')if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None imgwidth,if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None imgheightif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None PILImage.sizeif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None rawif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None PILImage.tostring()if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None assert(len(raw)if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None ==if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None imgwidthif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None *if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None imgheight,if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None "Wrongif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None amountif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None ofif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None dataif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None forif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None image")if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None compressedif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None zlib.compress(raw)if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None encodedif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None pdfutils._AsciiBase85Encode(compressed)if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None self.colorSpaceif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None 'DeviceRGB'if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None self.bitsPerComponentif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None 8if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None self.streamContentif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None encodedif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None self.widthif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None imgwidthif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None self.heightif self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None =if self.mask=='auto': if PILImage.info.has_key("transparency") : transparency = PILImage.info["transparency"] * 3 (tred, tgreen, tblue) = map(ord, PILImage.palette.data[transparency:transparency+3]) self.mask = (tred, tred, tgreen, tgreen, tblue, tblue) else: self.mask = None imgheight
| 4,667
|
def format(self, document): S = PDFStream() S.content = self.streamContent
|
def format(self, document): S = PDFStream() S.content = self.streamContent
| 4,668
|
def __init__(self, filename, **kw): frame1 = Frame(2.5*cm, 15.5*cm, 6*cm, 10*cm, id='F1') frame2 = Frame(11.5*cm, 15.5*cm, 6*cm, 10*cm, id='F2') frame3 = Frame(2.5*cm, 2.5*cm, 6*cm, 10*cm, id='F3') frame4 = Frame(11.5*cm, 2.5*cm, 6*cm, 10*cm, id='F4') self.allowSplitting = 0 self.showBoundary = 1 apply(BaseDocTemplate.__init__, (self, filename), kw) template = PageTemplate('normal', [frame1, frame2, frame3, frame4], myMainPageFrame) self.addPageTemplates(template)
|
def__init__(self,filename,**kw):frame1=Frame(2.5*cm,15.5*cm,6*cm,10*cm,id='F1')frame2=Frame(11.5*cm,15.5*cm,6*cm,10*cm,id='F2')frame3=Frame(2.5*cm,2.5*cm,6*cm,10*cm,id='F3')frame4=Frame(11.5*cm,2.5*cm,6*cm,10*cm,id='F4')self.allowSplitting=0self.showBoundary=1apply(BaseDocTemplate.__init__,(self,filename),kw)template=PageTemplate('normal',[frame1,frame2,frame3,frame4],myMainPageFrame)self.addPageTemplates(template)
| 4,669
|
def _test0(self): "This makes one long multi-page paragraph." # Build story. story = [] a = story.append styleSheet = getSampleStyleSheet() h1 = styleSheet['Heading1'] h1.pageBreakBefore = 1 h1.keepWithNext = 1 h2 = styleSheet['Heading2'] h2.frameBreakBefore = 1 h2.keepWithNext = 1 h3 = styleSheet['Heading3'] h3.backColor = colors.cyan h3.keepWithNext = 1 bt = styleSheet['BodyText'] a(Paragraph(""" Subsequent pages test pageBreakBefore, frameBreakBefore and keepTogether attributes. Generated at %s. The number in brackets at the end of each paragraph is its position in the story. (%d)""" % ( time.ctime(time.time()), len(story)), bt)) for i in range(10): a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1)) for j in range(3): a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2)) a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) for j in range(3): a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt)) a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3)) a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt)) a(Paragraph('Now we do <br/> tests', h1)) a(Paragraph('First off no br tags',h3)) a(Paragraph(_text1,bt)) a(Paragraph("<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bt)) a(Paragraph("2*<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bt)) a(Paragraph("<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bt)) a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bt)) doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf')) doc.multiBuild(story)
|
def_test0(self):"Thismakesonelongmulti-pageparagraph."#Buildstory.story=[]a=story.appendstyleSheet=getSampleStyleSheet()h1=styleSheet['Heading1']h1.pageBreakBefore=1h1.keepWithNext=1h2=styleSheet['Heading2']h2.frameBreakBefore=1h2.keepWithNext=1h3=styleSheet['Heading3']h3.backColor=colors.cyanh3.keepWithNext=1bt=styleSheet['BodyText']a(Paragraph("""SubsequentpagestestpageBreakBefore,frameBreakBeforeandkeepTogetherattributes.Generatedat%s.Thenumberinbracketsattheendofeachparagraphisitspositioninthestory.(%d)"""%(time.ctime(time.time()),len(story)),bt))foriinrange(10):a(Paragraph('Heading1alwaysstartsanewpage(%d)'%len(story),h1))forjinrange(3):a(Paragraph('Heading1paragraphsshouldalways''haveapagebreakbefore.Heading2ontheotherhand''shouldalwayshaveaFRAMEbreakbefore(%d)'%len(story),bt))a(Paragraph('Heading2alwaysstartsanewframe(%d)'%len(story),h2))a(Paragraph('Heading1paragraphsshouldalways''haveapagebreakbefore.Heading2ontheotherhand''shouldalwayshaveaFRAMEbreakbefore(%d)'%len(story),bt))forjinrange(3):a(Paragraph(randomText(theme=PYTHON,sentences=2)+'(%d)'%len(story),bt))a(Paragraph('Ishouldneverbeatthebottomofaframe(%d)'%len(story),h3))a(Paragraph(randomText(theme=PYTHON,sentences=1)+'(%d)'%len(story),bt))a(Paragraph('Nowwedo<br/>tests',h1))a(Paragraph('Firstoffnobrtags',h3))a(Paragraph(_text1,bt))a(Paragraph("<br/>after'the'inline4",h3))a(Paragraph(_text1.replace('formsofthe','formsofthe<br/>',1),bt))a(Paragraph("2*<br/>after'the'inline4",h3))a(Paragraph(_text1.replace('formsofthe','formsofthe<br/><br/>',1),bt))a(Paragraph("<br/>after'Isuggested'inline5",h3))a(Paragraph(_text1.replace('Isuggested','Isuggested<br/>',1),bt))a(Paragraph("2*<br/>after'Isuggested'inline5",h3))a(Paragraph(_text1.replace('Isuggested','Isuggested<br/><br/>',1),bt))doc=MyDocTemplate(outputfile('test_platypus_breaking.pdf'))doc.multiBuild(story)
| 4,670
|
def _test0(self): "This makes one long multi-page paragraph." # Build story. story = [] a = story.append styleSheet = getSampleStyleSheet() h1 = styleSheet['Heading1'] h1.pageBreakBefore = 1 h1.keepWithNext = 1 h2 = styleSheet['Heading2'] h2.frameBreakBefore = 1 h2.keepWithNext = 1 h3 = styleSheet['Heading3'] h3.backColor = colors.cyan h3.keepWithNext = 1 bt = styleSheet['BodyText'] a(Paragraph(""" Subsequent pages test pageBreakBefore, frameBreakBefore and keepTogether attributes. Generated at %s. The number in brackets at the end of each paragraph is its position in the story. (%d)""" % ( time.ctime(time.time()), len(story)), bt)) for i in range(10): a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1)) for j in range(3): a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2)) a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) for j in range(3): a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt)) a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3)) a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt)) a(Paragraph('Now we do <br/> tests', h1)) a(Paragraph('First off no br tags',h3)) a(Paragraph(_text1,bt)) a(Paragraph("<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bt)) a(Paragraph("2*<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bt)) a(Paragraph("<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bt)) a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bt)) doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf')) doc.multiBuild(story)
|
def _test0(self): "This makes one long multi-page paragraph." # Build story. story = [] a = story.append styleSheet = getSampleStyleSheet() h1 = styleSheet['Heading1'] h1.pageBreakBefore = 1 h1.keepWithNext = 1 h2 = styleSheet['Heading2'] h2.frameBreakBefore = 1 h2.keepWithNext = 1 h3 = styleSheet['Heading3'] h3.backColor = colors.cyan h3.keepWithNext = 1 bt = styleSheet['BodyText'] a(Paragraph(""" Subsequent pages test pageBreakBefore, frameBreakBefore and keepTogether attributes. Generated at %s. The number in brackets at the end of each paragraph is its position in the story. (%d)""" % ( time.ctime(time.time()), len(story)), bt)) for i in xrange(10): a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1)) for j in range(3): a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2)) a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) for j in range(3): a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt)) a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3)) a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt)) a(Paragraph('Now we do <br/> tests', h1)) a(Paragraph('First off no br tags',h3)) a(Paragraph(_text1,bt)) a(Paragraph("<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bt)) a(Paragraph("2*<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bt)) a(Paragraph("<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bt)) a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bt)) doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf')) doc.multiBuild(story)
| 4,671
|
def _test0(self): "This makes one long multi-page paragraph." # Build story. story = [] a = story.append styleSheet = getSampleStyleSheet() h1 = styleSheet['Heading1'] h1.pageBreakBefore = 1 h1.keepWithNext = 1 h2 = styleSheet['Heading2'] h2.frameBreakBefore = 1 h2.keepWithNext = 1 h3 = styleSheet['Heading3'] h3.backColor = colors.cyan h3.keepWithNext = 1 bt = styleSheet['BodyText'] a(Paragraph(""" Subsequent pages test pageBreakBefore, frameBreakBefore and keepTogether attributes. Generated at %s. The number in brackets at the end of each paragraph is its position in the story. (%d)""" % ( time.ctime(time.time()), len(story)), bt)) for i in range(10): a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1)) for j in range(3): a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2)) a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) for j in range(3): a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt)) a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3)) a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt)) a(Paragraph('Now we do <br/> tests', h1)) a(Paragraph('First off no br tags',h3)) a(Paragraph(_text1,bt)) a(Paragraph("<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bt)) a(Paragraph("2*<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bt)) a(Paragraph("<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bt)) a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bt)) doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf')) doc.multiBuild(story)
|
def _test0(self): "This makes one long multi-page paragraph." # Build story. story = [] a = story.append styleSheet = getSampleStyleSheet() h1 = styleSheet['Heading1'] h1.pageBreakBefore = 1 h1.keepWithNext = 1 h2 = styleSheet['Heading2'] h2.frameBreakBefore = 1 h2.keepWithNext = 1 h3 = styleSheet['Heading3'] h3.backColor = colors.cyan h3.keepWithNext = 1 bt = styleSheet['BodyText'] a(Paragraph(""" Subsequent pages test pageBreakBefore, frameBreakBefore and keepTogether attributes. Generated at %s. The number in brackets at the end of each paragraph is its position in the story. (%d)""" % ( time.ctime(time.time()), len(story)), bt)) for i in range(10): a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1)) for j in xrange(3): a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2)) a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) for j in xrange(3): a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt)) a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3)) a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt)) a(Paragraph('Now we do <br/> tests', h1)) a(Paragraph('First off no br tags',h3)) a(Paragraph(_text1,bt)) a(Paragraph("<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bt)) a(Paragraph("2*<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bt)) a(Paragraph("<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bt)) a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bt)) doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf')) doc.multiBuild(story)
| 4,672
|
def _test0(self): "This makes one long multi-page paragraph." # Build story. story = [] a = story.append styleSheet = getSampleStyleSheet() h1 = styleSheet['Heading1'] h1.pageBreakBefore = 1 h1.keepWithNext = 1 h2 = styleSheet['Heading2'] h2.frameBreakBefore = 1 h2.keepWithNext = 1 h3 = styleSheet['Heading3'] h3.backColor = colors.cyan h3.keepWithNext = 1 bt = styleSheet['BodyText'] a(Paragraph(""" Subsequent pages test pageBreakBefore, frameBreakBefore and keepTogether attributes. Generated at %s. The number in brackets at the end of each paragraph is its position in the story. (%d)""" % ( time.ctime(time.time()), len(story)), bt)) for i in range(10): a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1)) for j in range(3): a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2)) a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) for j in range(3): a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt)) a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3)) a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt)) a(Paragraph('Now we do <br/> tests', h1)) a(Paragraph('First off no br tags',h3)) a(Paragraph(_text1,bt)) a(Paragraph("<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bt)) a(Paragraph("2*<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bt)) a(Paragraph("<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bt)) a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bt)) doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf')) doc.multiBuild(story)
|
def _test0(self): "This makes one long multi-page paragraph." # Build story. story = [] a = story.append styleSheet = getSampleStyleSheet() h1 = styleSheet['Heading1'] h1.pageBreakBefore = 1 h1.keepWithNext = 1 h2 = styleSheet['Heading2'] h2.frameBreakBefore = 1 h2.keepWithNext = 1 h3 = styleSheet['Heading3'] h3.backColor = colors.cyan h3.keepWithNext = 1 bt = styleSheet['BodyText'] a(Paragraph(""" Subsequent pages test pageBreakBefore, frameBreakBefore and keepTogether attributes. Generated at %s. The number in brackets at the end of each paragraph is its position in the story. (%d)""" % ( time.ctime(time.time()), len(story)), bt)) for i in range(10): a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1)) for j in xrange(3): a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2)) a(Paragraph('Heading1 paragraphs should always' 'have a page break before. Heading 2 on the other hand' 'should always have a FRAME break before (%d)' % len(story), bt)) for j in xrange(3): a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt)) a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3)) a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt)) a(Paragraph('Now we do <br/> tests', h1)) a(Paragraph('First off no br tags',h3)) a(Paragraph(_text1,bt)) a(Paragraph("<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bt)) a(Paragraph("2*<br/> after 'the' in line 4",h3)) a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bt)) a(Paragraph("<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bt)) a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3)) a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bt)) doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf')) doc.multiBuild(story)
| 4,673
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
| 4,674
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
| 4,675
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
| 4,676
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
| 4,677
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
| 4,678
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
|
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
| 4,679
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
| 4,680
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
|
defraiseConfigError(msg):importexceptionsclassConfigError(exceptions.Exception):passraiseConfigError(msg)
| 4,681
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
| 4,682
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
| 4,683
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
|
defraiseConfigError(msg):importexceptionsclassConfigError(exceptions.Exception):passraiseConfigError(msg)
| 4,684
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
|
def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg)
| 4,685
|
def __init__(self,verbose=0): if _xmllib_newStyle: xmllib.XMLParser.__init__(self,verbose=verbose) else: xmllib.XMLParser.__init__(self) # set up handlers for various tags self.elements = { 'b': (self.start_b, self.end_b), 'u': (self.start_u, self.end_u), 'i': (self.start_i, self.end_i), 'super': (self.start_super, self.end_super), 'sub': (self.start_sub, self.end_sub), 'font': (self.start_font, self.end_font), 'greek': (self.start_greek, self.end_greek) }
|
def __init__(self,verbose=0): if _xmllib_newStyle: xmllib.XMLParser.__init__(self,verbose=verbose) else: xmllib.XMLParser.__init__(self) # set up handlers for various tags self.elements = { 'b': (self.start_b, self.end_b), 'u': (self.start_u, self.end_u), 'i': (self.start_i, self.end_i), 'super': (self.start_super, self.end_super), 'sub': (self.start_sub, self.end_sub), 'font': (self.start_font, self.end_font), 'greek': (self.start_greek, self.end_greek), 'para': (self.start_para, self.end_para) }
| 4,686
|
def save(self, formats=['pdf'], verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') % getattr(self,'chartId',0))))
|
def save(self, formats=['pdf'], verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d') % getattr(self,'chartId',0))))
| 4,687
|
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 = self._atTop and 0 or 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
|
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
| 4,688
|
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 = self._atTop and 0 or 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
|
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 = self._atTop and 0 or 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
| 4,689
|
def split(self,flowable,canv): '''Ask the flowable to split using up the available space.''' y = self._y p = self._y1p s = self._atTop and 0 or flowable.getSpaceBefore() flowable.canv = canv #some flowables might need this r = flowable.split(self._aW, y-p-s) del flowable.canv return r
|
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
| 4,690
|
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
|
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
| 4,691
|
def pre(txt): s = layout.Spacer(0.1*inch, 0.1*inch) Elements.append(s) p = layout.Preformatted(txt, PreStyle) Elements.append(p)
|
def pre(txt): s = layout.Spacer(0.1*inch, 0.1*inch) Elements.append(s) p = layout.Preformatted(txt, PreStyle) Elements.append(p)
| 4,692
|
def pre(txt): s = layout.Spacer(0.1*inch, 0.1*inch) Elements.append(s) p = layout.Preformatted(txt, PreStyle) Elements.append(p)
|
def pre(txt): s = layout.Spacer(0.1*inch, 0.1*inch) Elements.append(s) p = layout.Preformatted(txt, PreStyle) Elements.append(p)
| 4,693
|
def BIGENDIAN(macname,value=None): 'define a macro if bigendian' return sys.byteorder=='big' and [(macname,value)] or []
|
def BIGENDIAN(macname,value=None): 'define a macro if bigendian' return sys.byteorder=='big' and [(macname,value)] or []
| 4,694
|
def BIGENDIAN(macname,value=None): 'define a macro if bigendian' return sys.byteorder=='big' and [(macname,value)] or []
|
def BIGENDIAN(macname,value=None): 'define a macro if bigendian' return sys.byteorder=='big' and [(macname,value)] or []
| 4,695
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
| 4,696
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
| 4,697
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
| 4,698
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
|
def pfxJoin(pfx,*N): R=[] for n in N: R.append(pJoin(pfx,n)) return R
| 4,699
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.