Ejemplo n.º 1
0
def run(infilename, outfilename):
    p = yaml.Parser()
    results = p.parseFile(infilename)

    ss = getStyleSheet()

    #now make flowables from the results
    story = []
    for thingy in results:
        typ = thingy[0]
        if typ == 'Paragraph':
            (typ2, stylename, text) = thingy
            if stylename == 'bu':
                bulletText = '\267'
            else:
                bulletText = None
            try:
                style = ss[stylename]
            except KeyError:
                print 'Paragraph style "%s" not found in stylesheet, using Normal instead' % stylename
                style = ss['Normal']
            story.append(Paragraph(text, style, bulletText=bulletText))
        elif typ == 'Preformatted':
            (typ2, stylename, text) = thingy
            try:
                style = ss[stylename]
            except KeyError:
                print 'Preformatted style "%s" not found in stylesheet, using Normal instead' % stylename
                style = ss['Normal']
            story.append(Preformatted(text, style, bulletText=bulletText))
        elif typ == 'Image':
            filename = thingy[1]
            img = Image(filename)
            story.append(img)
        elif typ == 'PageBreak':
            story.append(PageBreak())
        elif typ == 'VSpace':
            height = thingy[1]
            story.append(Spacer(0, height))
        elif typ == 'NextPageTemplate':
            story.append(NextPageTemplate(thingy[1]))
        elif typ == 'Custom':
            # go find it
            searchPath = [os.getcwd() + '\\']
            (typ2, moduleName, funcName) = thingy
            found = imp.find_module(moduleName, searchPath)
            assert found, "Custom object module %s not found" % moduleName
            (file, pathname, description) = found
            mod = imp.load_module(moduleName, file, pathname, description)

            #now get the function
            func = getattr(mod, funcName)
            story.append(func())

        else:
            print 'skipping', typ, 'for now'

    #print it
    doc = RLDocTemplate(outfilename, pagesize=A4)
    doc.build(story)
Ejemplo n.º 2
0
def run(infilename, outfilename):
    p = yaml.Parser()
    results = p.parseFile(infilename)

    ss = getStyleSheet()

    # now make flowables from the results
    story = []
    for thingy in results:
        typ = thingy[0]
        if typ == "Paragraph":
            (typ2, stylename, text) = thingy
            if stylename == "bu":
                bulletText = "\267"
            else:
                bulletText = None
            try:
                style = ss[stylename]
            except KeyError:
                print 'Paragraph style "%s" not found in stylesheet, using Normal instead' % stylename
                style = ss["Normal"]
            story.append(Paragraph(text, style, bulletText=bulletText))
        elif typ == "Preformatted":
            (typ2, stylename, text) = thingy
            try:
                style = ss[stylename]
            except KeyError:
                print 'Preformatted style "%s" not found in stylesheet, using Normal instead' % stylename
                style = ss["Normal"]
            story.append(Preformatted(text, style, bulletText=bulletText))
        elif typ == "Image":
            filename = thingy[1]
            img = Image(filename)
            story.append(img)
        elif typ == "PageBreak":
            story.append(PageBreak())
        elif typ == "VSpace":
            height = thingy[1]
            story.append(Spacer(0, height))
        elif typ == "NextPageTemplate":
            story.append(NextPageTemplate(thingy[1]))
        elif typ == "Custom":
            # go find it
            searchPath = [os.getcwd() + "\\"]
            (typ2, moduleName, funcName) = thingy
            found = imp.find_module(moduleName, searchPath)
            assert found, "Custom object module %s not found" % moduleName
            (file, pathname, description) = found
            mod = imp.load_module(moduleName, file, pathname, description)

            # now get the function
            func = getattr(mod, funcName)
            story.append(func())

        else:
            print "skipping", typ, "for now"

    # print it
    doc = RLDocTemplate(outfilename, pagesize=A4)
    doc.build(story)
Ejemplo n.º 3
0
 def __init__(self, doctree):
     self.styleSheet = getStyleSheet()
     nodes.NodeVisitor.__init__(self, doctree)
     self.language = languages.get_language(doctree.settings.language_code)
     self.head = []
     self.body = []
     self.foot = []
     self.sectionlevel = 0
     self.context = []
     self.topic_class = ''
     self.story = []
     self.bulletText = '\xb7'	# maybe move this into stylesheet.
Ejemplo n.º 4
0
 def __init__(self, doctree):
     self.styleSheet = getStyleSheet()
     nodes.NodeVisitor.__init__(self, doctree)
     self.language = languages.get_language(doctree.settings.language_code)
     self.head = []
     self.body = []
     self.foot = []
     self.sectionlevel = 0
     self.context = []
     self.topic_class = ''
     self.story = []
     self.bulletText = '\xb7'  # maybe move this into stylesheet.
Ejemplo n.º 5
0
#Copyright ReportLab Europe Ltd. 2000-2004
#see license.txt for license details
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/tools/docco/rl_doc_utils.py
__version__=''' $Id: rl_doc_utils.py 3372 2009-01-15 16:59:35Z jonas $ '''


__doc__ = """
This module contains utilities for generating guides
"""

import os, sys, glob
import string

from rltemplate import RLDocTemplate
from stylesheet import getStyleSheet
styleSheet = getStyleSheet()

#from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import letter, A4, A5, A3  # latter two for testing
from reportlab.rl_config import defaultPageSize
from reportlab.platypus import figures
from reportlab.platypus import Paragraph, Spacer, Preformatted,\
            PageBreak, CondPageBreak, Flowable, Table, TableStyle, \
            NextPageTemplate, KeepTogether, Image, XPreformatted
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib import colors
from reportlab.lib.sequencer import getSequencer

import examples
Ejemplo n.º 6
0
#!/bin/env python
#Copyright ReportLab Europe Ltd. 2000-2012
#see license.txt for license details
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/tools/docco/rl_doc_utils.py
__version__ = ''' $Id$ '''

__doc__ = """
This module contains utilities for generating guides
"""

import os, sys, glob
import string

from rltemplate import RLDocTemplate
from stylesheet import getStyleSheet
styleSheet = getStyleSheet()

#from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import letter, A4, A5, A3  # latter two for testing
from reportlab.rl_config import defaultPageSize
from reportlab.platypus import figures
from reportlab.platypus import Paragraph, Spacer, Preformatted,\
            PageBreak, CondPageBreak, Flowable, Table, TableStyle, \
            NextPageTemplate, KeepTogether, Image, XPreformatted
from reportlab.platypus.xpreformatted import PythonPreformatted
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib import colors
from reportlab.lib.sequencer import getSequencer

import examples