bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def breakLines(self, width): """ Returns a broken line structure. There are two cases
def breakLines(self, width): """ Returns a broken line structure. There are two cases
4,800
def breakLines(self, width): """ Returns a broken line structure. There are two cases
def breakLines(self, width): """ Returns a broken line structure. There are two cases
4,801
def breakLines(self, width): """ Returns a broken line structure. There are two cases
def breakLines(self, width): """ Returns a broken line structure. There are two cases
4,802
def dumpParagraphFrags(P): print 'dumpParagraphFrags(<Paragraph @ %d>) minWidth() = %.2f' % (id(P), P.minWidth()) frags = P.frags n =len(frags) for l in range(n): print "frag%d: '%s'" % (l, frags[l].text)
def dumpParagraphFrags(P): print 'dumpParagraphFrags(<Paragraph @ %d>) minWidth() = %.2f' % (id(P), P.minWidth()) frags = P.frags n =len(frags) for l in range(n): print "frag%d: '%s'" % (l, frags[l].text)
4,803
def getActualLineWidths0(self): """Convenience function; tells you how wide each line actually is. For justified styles, this will be the same as the wrap width; for others it might be useful for seeing if paragraphs will fit in spaces.""" assert hasattr(self, 'width'), "Cannot call this method before wrap()" w = [] for frag in self.blPara.lines: w.append(self.width - frag.extraSpace) return w
def getActualLineWidths0(self): """Convenience function; tells you how wide each line actually is. For justified styles, this will be the same as the wrap width; for others it might be useful for seeing if paragraphs will fit in spaces.""" assert hasattr(self, 'width'), "Cannot call this method before wrap()" w = [] for frag in self.blPara.lines: w.append(self.width - frag.extraSpace) return w
4,804
def _py_unicode2T1(utext,fonts): '''return a list of (font,string) pairs representing the unicode text''' #print 'unicode2t1(%s, %s): %s' % (utext, fonts, type(utext)) #if type(utext) R = [] font, fonts = fonts[0], fonts[1:] enc = font.encName if 'UCS-2' in enc: enc = 'UTF16' while utext: try: R.append((font,utext.encode(enc))) break except UnicodeEncodeError, e: i0, il = e.args[2:4] if i0: R.append((font,utext[:i0].encode(enc))) if fonts: R.extend(unicode2T1(utext[i0:il],fonts)) else: R.append((_notdefFont,_notdefChar*(il-i0))) utext = utext[il:] return R
def _py_unicode2T1(utext,fonts): '''return a list of (font,string) pairs representing the unicode text''' #print 'unicode2t1(%s, %s): %s' % (utext, fonts, type(utext)) #if type(utext) R = [] font, fonts = fonts[0], fonts[1:] enc = font.encName if 'UCS-2' in enc: enc = 'UTF16' while utext: try: R.append((font,utext.encode(enc))) break except UnicodeEncodeError, e: i0, il = e.args[2:4] if i0: R.append((font,utext[:i0].encode(enc))) if fonts: R.extend(_py_unicode2T1(utext[i0:il],fonts)) else: R.append((_notdefFont,_notdefChar*(il-i0))) utext = utext[il:] return R
4,805
def _py_getFont(fontName): """Lazily constructs known fonts if not found. Names of form 'face-encoding' will be built if face and encoding are known. Also if the name is just one of the standard 14, it will make up a font in the default encoding.""" try: return _fonts[fontName] except KeyError: return findFontAndRegister(fontName)
def _py_getFont(fontName): """Lazily constructs known fonts if not found. Names of form 'face-encoding' will be built if face and encoding are known. Also if the name is just one of the standard 14, it will make up a font in the default encoding.""" try: return _fonts[fontName] except KeyError: return findFontAndRegister(fontName)
4,806
def makeBars(self): g = Group()
def makeBars(self): g = Group()
4,807
def makeBars(self): g = Group()
def makeBars(self): g = Group()
4,808
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
4,809
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
4,810
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
deftest0(self):"Testifpythonpoint.pdfcanbecreatedfrompythonpoint.xml."
4,811
def makeSuite(): return makeSuiteForClasses(PythonPointTestCase)
def makeSuite(): return makeSuiteForClasses(PythonPointTestCase)
4,812
def __setattr__(self, key, value): if self.defaults.has_key(key): self.attributes[key] = value else: self.__dict__[key] = value
def __setattr__(self, key, value): if self.defaults.has_key(key): self.attributes[key] = value else: self.__dict__[key] = value
4,813
def __repr__(self): return "<%s '%s'>" % (self.__class__.__name__, self.name)
def __repr__(self): return "<%s '%s'>" % (self.__class__.__name__, self.name)
4,814
def listAttrs(self): print 'name =', self.name print 'parent =', self.parent keylist = self.defaults.keys() keylist.sort() for key in keylist: value = self.attributes.get(key, None) if value: print '%s = %s (direct)' % (key, value) else: #try for inherited value = getattr(self.parent, key, None) if value: print '%s = %s (inherited)' % (key, value) else: value = self.defaults[key] print '%s = %s (class default)' % (key, value)
def listAttrs(self): print 'name =', self.name print 'parent =', self.parent keylist = self.defaults.keys() keylist.sort() for key in keylist: value = self.attributes.get(key, None) if value: print '%s = %s (direct)' % (key, value) else: #try for inherited value = getattr(self.parent, key, None) if value: print '%s = %s (inherited)' % (key, value) else: value = self.defaults[key] print '%s = %s (class default)' % (key, value)
4,815
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
4,816
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
4,817
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
4,818
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
def getSampleStyleSheet(): """Returns a dictionary of styles to get you started. Should be usable for fairly basic word processing tasks. We should really have a class for StyleSheets, which can list itself and avoid the duplication of item names seen below.""" stylesheet = {} para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Times-Roman' para.fontSize = 10 para.leading = 12 stylesheet['Normal'] = para para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 6 stylesheet['BodyText'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Times-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 18 para.spaceAfter = 6 stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Times-Bold' para.fontSize = 14 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Times-BoldItalic' para.fontSize = 12 para.spaceBefore = 12 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 36 para.leftIndent = 36 para.spaceBefore = 3 stylesheet['Bullet'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 36 para.leftIndent = 36 para.bulletIndent = 0 para.spaceBefore = 6 para.bulletFontName = 'Times-BoldItalic' stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 8 para.leading = 8.8 para.leftIndent = 36 stylesheet['Code'] = para return stylesheet
4,819
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
def cleanBlockQuotedText(text): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" stripped = string.strip(text) lines = string.split(stripped, '\n') trimmed_lines = map(string.lstrip, lines) return string.join(trimmed_lines, ' ')
4,820
def __init__(self): self.width = 0 self.height = 0 self.wrapped = 0
def __init__(self): self.width = 0 self.height = 0 self.wrapped = 0
4,821
def drawOn(self, canvas, x, y): "Tell it to draw itself on the canvas. Do not override" self.canv = canvas self.canv.saveState() self.canv.translate(x, y)
def drawOn(self, canvas, x, y): "Tell it to draw itself on the canvas. Do not override" self.canv = canvas self.canv.saveState() self.canv.translate(x, y)
4,822
def draw(self): self.canv.rect(0, 0, self.width, self.height) self.canv.line(0, 0, self.width, self.height) self.canv.line(0, self.height, self.width, 0)
def draw(self): self.canv.rect(0, 0, self.width, self.height) self.canv.line(0, 0, self.width, self.height) self.canv.line(0, self.height, self.width, 0)
4,823
def __init__(self, text, style, bulletText = None): self.text = cleanBlockQuotedText(text) self.style = style self.bulletText = bulletText self.debug = 0 #turn this on to see a pretty one with all the margins etc.
def __init__(self, text, style, bulletText = None): self.text = cleanBlockQuotedText(text) self.style = style self.bulletText = bulletText self.debug = 0 #turn this on to see a pretty one with all the margins etc.
4,824
def wrap(self, availWidth, availHeight): # work out widths array for breaking self.width = availWidth first_line_width = availWidth - self.style.firstLineIndent - self.style.rightIndent later_widths = availWidth - self.style.leftIndent - self.style.rightIndent wrap_widths = [first_line_width, later_widths]
def wrap(self, availWidth, availHeight): # work out widths array for breaking self.width = availWidth first_line_width = availWidth - self.style.firstLineIndent - self.style.rightIndent later_widths = availWidth - self.style.leftIndent - self.style.rightIndent wrap_widths = [first_line_width, later_widths]
4,825
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
4,826
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
4,827
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
4,828
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
def breakLines(self, text, width, fontName, fontSize): """Returns a structure broken into lines. Each line has two items. Item one is the extra points of space available on that line; item two is the list of words themselves. This structure can be used to easily draw paragraphs with the various alignments. You can supply either a single width or a list of widths; the latter will have its last item repeated until necessary. A 2-element list is useful when there is a different first line indent; a longer list could be created to facilitate custom wraps around irregular objects.""" if type(width) <> types.ListType: maxwidths = [width] else: maxwidths = width lines = [] spacewidth = pdfmetrics.stringwidth(' ', fontName) * 0.001 * fontSize words = string.split(text, ' ') currentline = [] lineno = 0 maxwidth = maxwidths[lineno] currentwidth = - spacewidth # hack to get around extra space for word 1
4,829
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,830
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,831
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,832
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,833
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,834
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,835
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,836
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,837
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,838
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,839
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,840
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,841
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,842
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,843
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,844
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
def drawPara(self,debug=0): """Draws a paragraph according to the given style. Returns the final y position at the bottom. Not safe for paragraphs without spaces e.g. Japanese; wrapping algorithm will go infinite.""" text = cleanBlockQuotedText(self.text)
4,845
def __init__(self, text, style, bulletText = None, dedent=0): self.style = style self.bulletText = bulletText
def __init__(self, text, style, bulletText = None, dedent=0): self.style = style self.bulletText = bulletText
4,846
def __init__(self, text, style, bulletText = None, dedent=0): self.style = style self.bulletText = bulletText
def __init__(self, text, style, bulletText = None, dedent=0): self.style = style self.bulletText = bulletText
4,847
def wrap(self, availWidth, availHeight): self.width = availWidth self.height = (self.style.spaceBefore + self.style.leading * len(self.lines) + self.style.spaceAfter) return (self.width, self.height)
def wrap(self, availWidth, availHeight): self.width = availWidth self.height = (self.style.spaceBefore + self.style.leading * len(self.lines) + self.style.spaceAfter) return (self.width, self.height)
4,848
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
4,849
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
4,850
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
4,851
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
def draw(self): #call another method for historical reasons. Besides, I #suspect I will be playing with alternate drawing routines #so not doing it here makes it easier to switch. cur_x = self.style.leftIndent cur_y = self.height - self.style.spaceBefore - self.style.fontSize self.canv.addLiteral('%PreformattedPara')
4,852
def __init__(self, filename, width=None, height=None): """If size to draw at not specified, get it from the image.""" import Image #this will raise an error if they do not have PIL. self.filename = filename img = Image.open(filename) (self.imageWidth, self.imageHeight) = img.size if width: self.drawWidth = width else: self.drawWidth = self.imageWidth if height: self.drawHeight = height else: self.drawHeight = self.imageHeight
def __init__(self, filename, width=None, height=None): """If size to draw at not specified, get it from the image.""" import Image #this will raise an error if they do not have PIL. self.filename = filename img = Image.open(filename) (self.imageWidth, self.imageHeight) = img.size if width: self.drawWidth = width else: self.drawWidth = self.imageWidth if height: self.drawHeight = height else: self.drawHeight = self.imageHeight
4,853
## def __init__(self, colWidths, rowHeights):
## def __init__(self, colWidths, rowHeights):
4,854
## def __init__(self, colWidths, rowHeights):
## def __init__(self, colWidths, rowHeights):
4,855
## def __init__(self, colWidths, rowHeights):
## def __init__(self, colWidths, rowHeights):
4,856
## def wrap(self, availWidth, availHeight):
## def wrap(self, availWidth, availHeight):
4,857
## def __init__(self, colWidths, rowHeights, data):
## def __init__(self, colWidths, rowHeights, data):
4,858
## def addLines(self, col1, row1, col2, row2, width=1):
## def addLines(self, col1, row1, col2, row2, width=1):
4,859
## def addLines(self, col1, row1, col2, row2, width=1):
## def addLines(self, col1, row1, col2, row2, width=1):
4,860
## def draw(self):
## def draw(self):
4,861
## def drawLines(self):
## def drawLines(self):
4,862
## def drawLines(self):
## def drawLines(self):
4,863
## def getCellRect(self, col, row):
## def getCellRect(self, col, row):
4,864
## def drawText(self):
## def drawText(self):
4,865
## def drawText(self):
## def drawText(self):
4,866
def wrap(self, availWidth, availHeight): self.width = availWidth self.height = availHeight return (availWidth,availHeight) #step back a point
def wrap(self, availWidth, availHeight): self.width = availWidth self.height = availHeight return (availWidth,availHeight) #step back a point
4,867
def draw(self): pass # #self.canv.drawRect(0, 0, self.width, self.height) #self.canv.drawLine(0, 0, self.width, self.height) #self.canv.drawLine(0, self.height, self.width, 0) #self.text = 'Page Break Object (%d x %d)' % (self.width, self.height) ##centre the text #self.canv._currentFont = self.canv.defaultFont #f = Font(size=24,bold=1) #w = self.canv.stringWidth(self.text, f) #x = 0.5 * (self.width - w) #y = 0.33 * (self.height + f.size) #self.canv.drawString(self.text, x, y, font=f)
def draw(self): pass # #self.canv.drawRect(0, 0, self.width, self.height) #self.canv.drawLine(0, 0, self.width, self.height) #self.canv.drawLine(0, self.height, self.width, 0) #self.text = 'Page Break Object (%d x %d)' % (self.width, self.height) ##centre the text #self.canv._currentFont = self.canv.defaultFont #f = Font(size=24,bold=1) #w = self.canv.stringWidth(self.text, f) #x = 0.5 * (self.width - w) #y = 0.33 * (self.height + f.size) #self.canv.drawString(self.text, x, y, font=f)
4,868
def draw(self): exec self.command in globals(), {'canvas':self.canv}
def draw(self): exec self.command in globals(), {'canvas':self.canv}
4,869
def __init__(self, canvas, x1, y1, width,height): self.canvas = canvas
def __init__(self, canvas, x1, y1, width,height): self.canvas = canvas
4,870
def __init__(self, canvas, x1, y1, width,height): self.canvas = canvas
def __init__(self, canvas, x1, y1, width,height): self.canvas = canvas
4,871
def __init__(self, canvas, x1, y1, width,height): self.canvas = canvas
def __init__(self, canvas, x1, y1, width,height): self.canvas = canvas
4,872
def addFromList(self, drawlist): """Consumes objects from the front of the list until the frame is full. If it cannot fit one object, raises an exception."""
def addFromList(self, drawlist): """Consumes objects from the front of the list until the frame is full. If it cannot fit one object, raises an exception."""
4,873
def __init__(self): self.dict = {}
def __init__(self): self.dict = {}
4,874
def next(self, category): if self.dict.has_key(category): self.dict[category] = self.dict[category] + 1 else: self.dict[category] = 1 return self.dict[category]
def next(self, category): if self.dict.has_key(category): self.dict[category] = self.dict[category] + 1 else: self.dict[category] = 1 return self.dict[category]
4,875
def reset(self, category): self.dict[category] = 0
def reset(self, category): self.dict[category] = 0
4,876
def __init__(self, filename, pagesize, showBoundary=0): self.filename = filename self.pagesize = pagesize self.showBoundary=showBoundary #sensibel defaults; override if you wish self.leftMargin = inch self.bottomMargin = inch self.rightMargin = self.pagesize[0] - inch self.topMargin = self.pagesize[1] - inch
def __init__(self, filename, pagesize, showBoundary=0): self.filename = filename self.pagesize = pagesize self.showBoundary=showBoundary #sensibel defaults; override if you wish self.leftMargin = inch self.bottomMargin = inch self.rightMargin = self.pagesize[0] - inch self.topMargin = self.pagesize[1] - inch
4,877
def __init__(self, filename, pagesize, showBoundary=0): self.filename = filename self.pagesize = pagesize self.showBoundary=showBoundary #sensibel defaults; override if you wish self.leftMargin = inch self.bottomMargin = inch self.rightMargin = self.pagesize[0] - inch self.topMargin = self.pagesize[1] - inch
def __init__(self, filename, pagesize, showBoundary=0): self.filename = filename self.pagesize = pagesize self.showBoundary=showBoundary #sensibel defaults; override if you wish self.leftMargin = inch self.bottomMargin = inch self.rightMargin = self.pagesize[0] - inch self.topMargin = self.pagesize[1] - inch
4,878
def __init__(self, filename, pagesize, showBoundary=0): self.filename = filename self.pagesize = pagesize self.showBoundary=showBoundary #sensibel defaults; override if you wish self.leftMargin = inch self.bottomMargin = inch self.rightMargin = self.pagesize[0] - inch self.topMargin = self.pagesize[1] - inch
def __init__(self, filename, pagesize, showBoundary=0): self.filename = filename self.pagesize = pagesize self.showBoundary=showBoundary #sensibel defaults; override if you wish self.leftMargin = inch self.bottomMargin = inch self.rightMargin = self.pagesize[0] - inch self.topMargin = self.pagesize[1] - inch
4,879
def build(self, drawables): canv = canvas.Canvas(self.filename) #canv.setPageTransition('Dissolve')
def build(self, drawables): canv = canvas.Canvas(self.filename) #canv.setPageTransition('Dissolve')
4,880
def build(self, drawables): canv = canvas.Canvas(self.filename) #canv.setPageTransition('Dissolve')
def build(self, drawables): canv = canvas.Canvas(self.filename) #canv.setPageTransition('Dissolve')
4,881
def build(self, drawables): canv = canvas.Canvas(self.filename) #canv.setPageTransition('Dissolve')
def build(self, drawables): canv = canvas.Canvas(self.filename) #canv.setPageTransition('Dissolve')
4,882
def randomText(): #this may or may not be appropriate in your company from random import randint, choice RANDOMWORDS = ['strategic','direction','proactive', 'reengineering','forecast','resources', 'forward-thinking','profit','growth','doubletalk', 'venture capital','IPO'] sentences = 5 output = "" for sentenceno in range(randint(1,5)): output = output + 'Blah' for wordno in range(randint(10,25)): if randint(0,4)==0: word = choice(RANDOMWORDS) else: word = 'blah' output = output + ' ' +word output = output+'.' return output
def randomText(): #this may or may not be appropriate in your company from random import randint, choice RANDOMWORDS = ['strategic','direction','proactive', 'reengineering','forecast','resources', 'forward-thinking','profit','growth','doubletalk', 'venture capital','IPO'] sentences = 5 output = "" for sentenceno in range(randint(1,5)): output = output + 'Blah' for wordno in range(randint(10,25)): if randint(0,4)==0: word = choice(RANDOMWORDS) else: word = 'blah' output = output + ' ' +word output = output+'.' return output
4,883
def myFirstPage(canvas, doc): canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Bold',24) canvas.drawString(108, PAGE_HEIGHT-108, "PLATYPUS") canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "First Page") canvas.restoreState()
def myFirstPage(canvas, doc): canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Bold',24) canvas.drawString(108, PAGE_HEIGHT-108, "PLATYPUS") canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "First Page") canvas.restoreState()
4,884
def myLaterPages(canvas, doc): #canvas.drawImage("snkanim.gif", 36, 36) canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page) canvas.restoreState()
def myLaterPages(canvas, doc): #canvas.drawImage("snkanim.gif", 36, 36) canvas.saveState() canvas.setStrokeColorRGB(1,0,0) canvas.setLineWidth(5) canvas.line(66,72,66,PAGE_HEIGHT-72) canvas.setFont('Times-Roman',12) canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page) canvas.restoreState()
4,885
def run(): objects_to_draw = [] #need a style normal = ParagraphStyle('normal') normal.firstLineIndent = 18 normal.spaceBefore = 6 import random for i in range(15): height = 0.5 + (2*random.random()) box = XBox(6 * inch, height * inch, 'Box Number %d' % i) objects_to_draw.append(box) para = Paragraph(randomText(), normal) objects_to_draw.append(para) doc = SimpleFlowDocument('platypus.pdf',DEFAULT_PAGE_SIZE) doc.onFirstPage = myFirstPage doc.onNewPage = myLaterPages doc.build(objects_to_draw)
def run(): objects_to_draw = [] #need a style normal = ParagraphStyle('normal') normal.firstLineIndent = 18 normal.spaceBefore = 6 import random for i in range(15): height = 0.5 + (2*random.random()) box = XBox(6 * inch, height * inch, 'Box Number %d' % i) objects_to_draw.append(box) para = Paragraph(randomText(), normal) objects_to_draw.append(para) doc = SimpleFlowDocument('platypus.pdf',DEFAULT_PAGE_SIZE) doc.onFirstPage = myFirstPage doc.onNewPage = myLaterPages doc.build(objects_to_draw)
4,886
def __init__(self): assert self.__class__.__name__!='ValueAxis', 'Abstract Class ValueAxis Instantiated' self._configured = 0 # private properties set by methods. The initial values # here are to make demos easy; they would always be # overridden in real life. self._x = 50 self._y = 50 self._length = 100
def __init__(self): assert self.__class__.__name__!='ValueAxis', 'Abstract Class ValueAxis Instantiated' self._configured = 0 # private properties set by methods. The initial values # here are to make demos easy; they would always be # overridden in real life. self._x = 50 self._y = 50 self._length = 100
4,887
def availableFlagNames(self): '''return a list of the things we can display''' return filter(lambda x: x is not None, self._attrMap['kind']._enum)
def availableFlagNames(self): '''return a list of the things we can display''' return filter(lambda x: x is not None, self._attrMap['kind']._enum)
4,888
def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile)
def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: pdir = py2pdf_dir cvsdir = os.path.join(groupdir,pdir) else: pdir = projdir tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile)
4,889
def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile)
def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, pdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile)
4,890
def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, projdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile)
def do_zip(d): 'create .tgz and .zip file archives of d/reportlab' os.chdir(d) if release: b = tagname else: b = py2pdf and "py2pdf" or "current" tarfile = '%s/%s.tgz' % (groupdir,b) zipfile = '%s/%s.zip' % (groupdir,b) if py2pdf: projdir = py2pdf_dir cvsdir = os.path.join(groupdir,projdir) tar = find_exe('tar') if tar is not None: safe_remove(tarfile) do_exec('%s czvf %s %s' % (tar, tarfile, projdir), 'tar creation') zip = find_exe('zip') if zip is not None: safe_remove(zipfile) do_exec('%s -ur %s %s' % (zip, zipfile, pdir), 'zip creation') recursive_rmdir(cvsdir) if release: # make links to the latest outcome for b in ['reportlab','current']: ltarfile = '%s/%s.tgz' % (groupdir,b) lzipfile = '%s/%s.zip' % (groupdir,b) safe_remove(lzipfile) safe_remove(ltarfile) os.symlink(zipfile,lzipfile) os.symlink(tarfile,ltarfile)
4,891
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
def split(self,flowable,canv): '''Ask the flowable to split using up the available space.''' y = self._y p = self._y1p s = 0 if not 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,892
def addFromList(self, drawlist, canv): """Consumes objects from the front of the list until the frame is full. If it cannot fit one object, raises an exception."""
def addFromList(self, drawlist, canv): """Consumes objects from the front of the list until the frame is full. If it cannot fit one object, raises an exception."""
4,893
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,894
def _copyNamedContents(self,obj,aKeys=None,noCopy=('contents',)): from copy import copy self_contents = self.contents if not aKeys: aKeys = self._attrMap.keys() for (k, v) in self.__dict__.items(): if k in self_contents: pos = self_contents.index(v) setattr(obj, oldKey, obj.contents[pos]) elif k in aKeys and k not in noCopy: setattr(obj, k, copy(v))
def _copyNamedContents(self,obj,aKeys=None,noCopy=('contents',)): from copy import copy self_contents = self.contents if not aKeys: aKeys = self._attrMap.keys() for (k, v) in self.__dict__.items(): if v in self_contents: pos = self_contents.index(v) setattr(obj, oldKey, obj.contents[pos]) elif k in aKeys and k not in noCopy: setattr(obj, k, copy(v))
4,895
def _copyNamedContents(self,obj,aKeys=None,noCopy=('contents',)): from copy import copy self_contents = self.contents if not aKeys: aKeys = self._attrMap.keys() for (k, v) in self.__dict__.items(): if k in self_contents: pos = self_contents.index(v) setattr(obj, oldKey, obj.contents[pos]) elif k in aKeys and k not in noCopy: setattr(obj, k, copy(v))
def _copyNamedContents(self,obj,aKeys=None,noCopy=('contents',)): from copy import copy self_contents = self.contents if not aKeys: aKeys = self._attrMap.keys() for (k, v) in self.__dict__.items(): if k in self_contents: pos = self_contents.index(v) setattr(obj, k, obj.contents[pos]) elif k in aKeys and k not in noCopy: setattr(obj, k, copy(v))
4,896
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t)
4,897
def findT1File(self,ext='.pfb'): possible_exts = (string.lower(ext), string.upper(ext)) if hasattr(self,'pfbFileName'): r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if ext == '.pfb': for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r
def findT1File(self, ext='.pfb'): possible_exts = (string.lower(ext), string.upper(ext)) if hasattr(self,'pfbFileName'): r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if ext == '.pfb': for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r
4,898
def findT1File(self,ext='.pfb'): possible_exts = (string.lower(ext), string.upper(ext)) if hasattr(self,'pfbFileName'): r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if ext == '.pfb': for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r
def findT1File(self,ext='.pfb'): possible_exts = (string.lower(ext), string.upper(ext)) if hasattr(self,'pfbFileName'): r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if string.lower(ext) == '.pfb': for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r
4,899