Exemplo n.º 1
0
    def make_paraIndents():
        doc, section, styles = RTFTestCase.initializeDoc()
        section.append(
            'The paragraphs below demonstrate the flexibility , the following is all at the '
            'same indent level and the one after it has the first line at a '
            'different indent to the rest. The third has the first line '
            'going in the other direction and is also separated by a page '
            'break. Note that the FirstLineIndent is defined as being the '
            'difference from the LeftIndent.')
        creditURL = 'http://www.shakespeare-online.com/plots/1kh4ps.html'
        section.append('(Paragraph text from %s.)' % creditURL)

        sampleParagraph = """The play opens one year after the death of Richard
            II, and King Henry is making plans for a crusade to the
            Holy Land to cleanse himself of the guilt he feels over the
            usurpation of Richard's crown. But the crusade must be postponed
            when Henry learns that Welsh rebels, led by Owen Glendower, have
            defeated and captured Mortimer. Although the brave Henry Percy,
            nicknamed Hotspur, has quashed much of the uprising, there is still
            much trouble in Scotland. King Henry has a deep admiration for
            Hotspur and he longs for his own son, Prince Hal, to
            display some of Hotspur's noble qualities. Hal is more comfortable
            in a tavern than on the battlefield, and he spends his days
            carousing with riff-raff in London. But King Henry also has his
            problems with the headstrong Hotspur, who refuses to turn over his
            prisoners to the state as he has been so ordered.
            Westmoreland tells King Henry that Hotspur has many of
            the traits of his uncle, Thomas Percy, the Earl of Worcester, and
            defying authority runs in the family."""
        sampleParagraph = re.sub('\s+', ' ', sampleParagraph)
        para_props = ParagraphPropertySet()
        para_props.SetLeftIndent(TabPropertySet.DEFAULT_WIDTH * 3)
        p = Paragraph(styles.ParagraphStyles.Normal, para_props)
        p.append(sampleParagraph)
        section.append(p)

        para_props = ParagraphPropertySet()
        para_props.SetFirstLineIndent(TabPropertySet.DEFAULT_WIDTH * -2)
        para_props.SetLeftIndent(TabPropertySet.DEFAULT_WIDTH * 3)
        p = Paragraph(styles.ParagraphStyles.Normal, para_props)
        p.append(sampleParagraph)
        section.append(p)

        para_props = ParagraphPropertySet()
        para_props.SetFirstLineIndent(TabPropertySet.DEFAULT_WIDTH)
        para_props.SetLeftIndent(TabPropertySet.DEFAULT_WIDTH)
        p = Paragraph(styles.ParagraphStyles.Normal, para_props)
        p.append(sampleParagraph)
        section.append(p)
        return doc
    p. append(title)
    section.append(p)
    p = Paragraph(ss.ParagraphStyles.Heading4)
    p. append(name)
    section.append(p)

    if len(person['grants']) > 0:
        for grant in person['grants']:
            try:
                print 'grant',\
                      int(grant['start_date']['date']['year']), int(year)
            except:
                continue
            if int(grant['start_date']['date']['year']) >= int(year):
                para_props = ParagraphPropertySet()
                para_props.SetFirstLineIndent(TabPropertySet.DEFAULT_WIDTH*-1)
                para_props.SetLeftIndent(TabPropertySet.DEFAULT_WIDTH*2)
                p = Paragraph(ss.ParagraphStyles.Normal, para_props)
                p.append(vt.string_from_grant(grant))
                section.append(p)

    if len(person['publications']) > 0:
        for publication in person['publications']:
            try:
                print 'pub', int(publication['date']['year']), int(year)
            except:
                continue
            if int(publication['date']['year']) >= int(year):
                para_props = ParagraphPropertySet()
                para_props.SetFirstLineIndent(TabPropertySet.DEFAULT_WIDTH*-1)
                para_props.SetLeftIndent(TabPropertySet.DEFAULT_WIDTH*2)
Exemplo n.º 3
0
    if 'start_date' in position and 'position_label' in position:
        key = position['start_date']['date']['year'] + position[
            'position_label']
        positions[key] = position
last_position = min(20, len(positions))
npos = 0
for key in sorted(positions.keys(), reverse=True):
    npos = npos + 1
    if npos > last_position:
        break
    position = positions[key]
    para_props = ParagraphPropertySet(
        tabs=[TabPropertySet(550),
              TabPropertySet(125),
              TabPropertySet(600)])
    para_props.SetFirstLineIndent(-1275)
    para_props.SetLeftIndent(1275)
    p = Paragraph(ss.ParagraphStyles.Normal, para_props)
    if 'end_date' in position:
        p.append(position['start_date']['date']['year'], TAB, '-', TAB,
                 position['end_date']['date']['year'], TAB,
                 position['position_label'], ', ', position['org_name'])
    else:
        p.append(position['start_date']['date']['year'], TAB, '-', TAB, TAB,
                 position['position_label'], ', ', position['org_name'])
    section.append(p)

# Section C -- Selected Peer-reviewed Publications

p = Paragraph(ss.ParagraphStyles.Heading3)
p.append("C.", TAB, "Selected Peer-reviewed Publications")