tests/test_platypus_general.py
branchpy33
changeset 3794 398ea04239b5
parent 3721 0c93dd8ff567
child 3849 8ff9b1fb92cd
equal deleted inserted replaced
3793:cc3f9cc828f7 3794:398ea04239b5
    11 builds a special "document model" in which the frames are added to each page
    11 builds a special "document model" in which the frames are added to each page
    12 and drawn into.
    12 and drawn into.
    13 """
    13 """
    14 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
    14 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
    15 setOutDir(__name__)
    15 setOutDir(__name__)
    16 import string, copy, sys, os
    16 import copy, sys, os
    17 from reportlab.pdfgen import canvas
    17 from reportlab.pdfgen import canvas
    18 from reportlab import platypus
    18 from reportlab import platypus
    19 from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
    19 from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
    20 from reportlab.platypus import Paragraph, Preformatted
    20 from reportlab.platypus import Paragraph, Preformatted
    21 from reportlab.lib.units import inch, cm
    21 from reportlab.lib.units import inch, cm
    69 
    69 
    70 def getParagraphs(textBlock):
    70 def getParagraphs(textBlock):
    71     """Within the script, it is useful to whack out a page in triple
    71     """Within the script, it is useful to whack out a page in triple
    72     quotes containing separate paragraphs. This breaks one into its
    72     quotes containing separate paragraphs. This breaks one into its
    73     constituent paragraphs, using blank lines as the delimiter."""
    73     constituent paragraphs, using blank lines as the delimiter."""
    74     lines = string.split(textBlock, '\n')
    74     lines = textBlock.split('\n')
    75     paras = []
    75     paras = []
    76     currentPara = []
    76     currentPara = []
    77     for line in lines:
    77     for line in lines:
    78         if len(string.strip(line)) == 0:
    78         if len(line.strip()) == 0:
    79             #blank, add it
    79             #blank, add it
    80             if currentPara != []:
    80             if currentPara != []:
    81                 paras.append(string.join(currentPara, '\n'))
    81                 paras.append('\n'.join(currentPara))
    82                 currentPara = []
    82                 currentPara = []
    83         else:
    83         else:
    84             currentPara.append(line)
    84             currentPara.append(line)
    85     #...and the last one
    85     #...and the last one
    86     if currentPara != []:
    86     if currentPara != []:
    87         paras.append(string.join(currentPara, '\n'))
    87         paras.append('\n'.join(currentPara))
    88 
    88 
    89     return paras
    89     return paras
    90 
    90 
    91 def getCommentary():
    91 def getCommentary():
    92     """Returns the story for the commentary - all the paragraphs."""
    92     """Returns the story for the commentary - all the paragraphs."""