예제 #1
0
 def createList(self, itemList, indentDelim, styleName):
     listArray = []
     listItem = ListItem()
     level = 0
     lastLevel = 0
             
     for levCount in range(0,10):
         listArray.append(None)
     listArray[0] = List()
     
     for item in itemList:
         level = 0;
         while (level < len(item) and item[level] == indentDelim):
             level +=1
         item = item[level:]
         
         if (level > lastLevel):    # open the sub-levels
             for levCount in range(lastLevel+1, level+1):
                 listArray[levCount] = List()
         elif (level < lastLevel):    # close off the intervening lists
             for levCount in range(lastLevel, level, -1):
                 listArray[levCount-1].childNodes[-1].addElement(listArray[levCount])
                 
         # now that we are at the proper level, add the item.
         listArray[level].setAttribute( 'stylename', styleName );
         listItem = ListItem()
         para = P(text=item);
         listItem.addElement(para);
         listArray[level].addElement(listItem);
         lastLevel = level;
         
     # close off any remaining open lists
     for levCount in range(lastLevel, 0, -1):
         listArray[levCount-1].childNodes[-1].addElement(listArray[levCount])
     return listArray[0]
예제 #2
0
 def addList(self,elements):
     textList = List(stylename="L1")
     for element in elements:
      item = ListItem()
      item.addElement(P(text=element))
      textList.addElement(item)
     self.textdoc.text.addElement(textList)
예제 #3
0
 def addList(self, content, stylename):        
     liste = List()
     for e in content:
         p = P(stylename=stylename, text=e)
         i = ListItem()
         i.addElement(p)
         liste.addElement(i)
     self.document.text.addElement(liste)
예제 #4
0
    def create_list(item_list, indent_delim, style_name):
        """
        TODO.
        :param item_list: array of list items,
        :param indent_delim: char identifying the nesting depth of list items,
        :param style_name: easyliststyle identifier.
        """
        list_array = []
        last_level = 0

        for _ in range(0, 10):
            list_array.append(None)
        list_array[0] = List()

        for item in item_list:
            level = 0
            while level < len(item) and item[level] == indent_delim:
                level += 1
            item = item[level:]

            if level > last_level:
                for lev_count in range(last_level + 1, level + 1):
                    list_array[lev_count] = List()
            elif level < last_level:
                for lev_count in range(last_level, level, -1):
                    list_array[lev_count - 1].childNodes[-1].addElement(
                        list_array[lev_count])

            list_array[level].setAttribute("stylename", style_name)
            list_item = ListItem()
            para = P(text=item)
            list_item.addElement(para)
            list_array[level].addElement(list_item)
            last_level = level

        for lev_count in range(last_level, 0, -1):
            list_array[lev_count - 1].childNodes[-1].addElement(
                list_array[lev_count])
        return list_array[0]
예제 #5
0
파일: make_odf.py 프로젝트: tsalidis/dune
def do_values(doc, values):
    if values is None:
        return None

    lst = List()

    for v in values.findall('value'):
        p = P(stylename='TextBold')
        bold(p, v.attrib['name'] + ': ')
        p.addText(v.find('doc').text)
        item = ListItem()
        item.addElement(p)
        lst.addElement(item)

    return lst
예제 #6
0
    def __init__(self, path):
        self.nom = basename(path)[:-4] #nom du fichier sans extension
        base = dirname(path)
        #vraiment lié au nom de fichier
        self.classe = ((self.nom).split('Eleve_'))[-1] 
        self.document = OpenDocumentText()
        self.defineStyles()
        # pas de header complet, on reste en A4

        file = open(path, "r", encoding="utf8")
        dialect=csv.Sniffer().sniff(file.readline())
        file.seek(0) # se remettre en début de fichier
        reader = csv.DictReader(file, dialect=dialect)
        
        self.addParagraph("Identifiants ENT élèves: "+self.classe, "heading1")
        self.addParagraph("nom prenom: identifiant -- mot de passe provisoire de chaque élève", "normal")
        L = List()
        for d in reader:
            L.addElement(self.make_eleve_id(d))
        self.document.text.addElement(L)
        file.close()
        self.save(join(base, "ENT_id_Eleve_"+self.classe+".odt"))            
예제 #7
0
p = P(text="The following sections illustrate various possibilities in ODF Text",
      stylename='Text_20_body')
textdoc.text.addElement(p)

textdoc.text.addElement(H(outlinelevel=2,text='A simple series of paragraphs (Heading 2)'))
textdoc.text.addElement(P(text="This section contains a series of paragraphs.", 
stylename='Text_20_body'))
textdoc.text.addElement(P(text="This is a second paragraph.", 
stylename='Text_20_body'))
textdoc.text.addElement(P(text="And a third paragraph.", stylename='Text_20_body'))

textdoc.text.addElement(H(outlinelevel=2,text='A section with lists (Heading 2)'))
textdoc.text.addElement(P(text="Elements to illustrate:"))

# add the first list (unordered list)
textList = List(stylename="L1")
item = ListItem()
item.addElement(P(text='hyperlinks', stylename="P1"))
textList.addElement(item)

item = ListItem()
item.addElement(P(text='italics and bold text', stylename="P1"))
textList.addElement(item)

item = ListItem()
item.addElement(P(text='lists (ordered and unordered)', stylename="P1"))
textList.addElement(item)

textdoc.text.addElement(textList)

# add the second (ordered) list
예제 #8
0
def coursePage(coursename, data, lang):
    coursetitle = H(stylename=h2style, text=coursename, outlinelevel=2)
    textdoc.text.addElement(coursetitle)
    blankline = P(text="")
    textdoc.text.addElement(blankline)

    for diagramtype in [pie, percent]:
        p = P()
        textdoc.text.addElement(p)
        img_path = path + coursename + "-All" + diagramtype
        href = textdoc.addPicture(img_path)
        f = Frame(name=coursename + diagramtype,
                  anchortype="paragraph",
                  width="17cm",
                  height="7.5cm",
                  zindex="0")
        p.addElement(f)
        img = Image(href=href, type="simple", show="embed", actuate="onLoad")
        f.addElement(img)

    if lang == "eu":
        subjectsp = P(text="%70 baino gainditu gutxiago duten ikasgaiak:")
    else:
        subjectsp = P(text="Asignaturas con menos del %70 de aprobados:")
    textdoc.text.addElement(subjectsp)
    blankline = P(text="")
    textdoc.text.addElement(blankline)
    textList = List(stylename="L1")

    file = path + "ehunekoak-" + period + "-" + year + "-" + coursename + "None.csv"
    with open(file, 'r', encoding="UTF-8") as results:
        reader = csv.reader(results)
        headers = next(reader, None)  # get first row with headers
        for row in reader:
            if float(row[1]) < 70 and row[0] != "All":
                item = ListItem()
                if lang == "eu":
                    item.addElement(
                        P(text=row[0] + ": " + "{:.2f}".format(float(row[1])) +
                          "%"))
                else:
                    item.addElement(
                        P(text=ikasgai[row[0]] + ": " +
                          "{:.2f}".format(float(row[1])) + "%"))
                textList.addElement(item)
                textdoc.text.addElement(textList)

    for courselang in data.keys():
        coursetitle = H(stylename=h2style,
                        text=coursename + "-" + courselang,
                        outlinelevel=2)
        textdoc.text.addElement(coursetitle)
        blankline = P(text="")
        textdoc.text.addElement(blankline)

        for diagramtype in [pie, percent]:
            p = P()
            textdoc.text.addElement(p)
            img_path = path + coursename + "-" + courselang + diagramtype
            href = textdoc.addPicture(img_path)
            f = Frame(name=coursename + diagramtype + courselang,
                      anchortype="paragraph",
                      width="17cm",
                      height="7.5cm",
                      zindex="0")
            p.addElement(f)
            img = Image(href=href,
                        type="simple",
                        show="embed",
                        actuate="onLoad")
            f.addElement(img)

        blankline = P(text="")
        textdoc.text.addElement(blankline)

        if lang == "eu":
            subjectsp = P(text="%70 baino gainditu gutxiago duten ikasgaiak:")
        else:
            subjectsp = P(text="Asignaturas con menos del %70 de aprobados:")
        textdoc.text.addElement(subjectsp)
        blankline = P(text="")
        textdoc.text.addElement(blankline)
        textList = List(stylename="L1")

        file = path + "ehunekoak-" + period + "-" + year + "-" + coursename + courselang + ".csv"
        with open(file, 'r', encoding="UTF-8") as results:
            reader = csv.reader(results)
            headers = next(reader, None)  # get first row with headers
            for row in reader:
                if float(row[1]) < 70 and row[0] != "All":
                    item = ListItem()
                    if lang == "eu":
                        item.addElement(
                            P(text=row[0] + ": " +
                              "{:.2f}".format(float(row[1])) + "%"))
                    else:
                        item.addElement(
                            P(text=ikasgai[row[0]] + ": " +
                              "{:.2f}".format(float(row[1])) + "%"))
                    textList.addElement(item)
                    textdoc.text.addElement(textList)

        for group in data[courselang]:
            if group in ["Bil", "Plur"]:
                #1 ESO-AG-AGBil - 2. Ebaluazioa (2019-2020) -percent-es
                g = coursename + "-" + courselang + "-" + courselang + group
                grouptitle = H(stylename=h3style,
                               text=translation[group][lang],
                               outlinelevel=3)
                textdoc.text.addElement(grouptitle)
                blankline = P(text="")
                textdoc.text.addElement(blankline)
                for diagramtype in [mean, percent]:  #,name2]:
                    p = P()
                    textdoc.text.addElement(p)
                    img_path = path + g + diagramtype
                    href = textdoc.addPicture(img_path)
                    f = Frame(name=group + diagramtype,
                              anchortype="paragraph",
                              width="17cm",
                              height="7.5cm",
                              zindex="0")
                    p.addElement(f)
                    img = Image(href=href,
                                type="simple",
                                show="embed",
                                actuate="onLoad")
                    f.addElement(img)
            else:
                groupPage(group, lang)
예제 #9
0
def groupPage(group, lang):
    grouptitle = H(stylename=h3style, text=group, outlinelevel=3)
    textdoc.text.addElement(grouptitle)
    blankline = P(text="")
    textdoc.text.addElement(blankline)

    if td != '':
        table = Table()
        table.addElement(TableColumn(numbercolumnsrepeated=2))
        headers = [
            translation['part'][lang], '2 ' + translation['period'][lang]
        ]  #,"2. Ebaluazioa","Azken Ebaluazioa"]
        tr = TableRow()
        table.addElement(tr)
        for val in headers:
            tc = TableCell(stylename="Table")
            tr.addElement(tc)
            p = P(stylename=tableheaders, text=val)
            tc.addElement(p)
        #f = [["garbitasuna",3,6],["materiala",6,8],["Adostasuna", "Ez konforme","konforme"],["Harremanak1",7,8],["Harremanak2",6,7],["Adostasuna", "konforme","konforme"]]
        g = group.replace(". ", "")
        g = g.replace("º ", "")
        g = g.replace(".", "")
        g = g.replace("º", "")
        g = g.replace("° ", "")
        g = g.replace("°", "")
        g = g.replace(" ", "")
        g = g.replace("Bach1", "5")
        g = g.replace("Bach2", "6")
        g = g.replace("Batx1", "5")
        g = g.replace("Batx2", "6")
        f = td[g]
        for line in f:
            if "group" in line:  #FIXME: If not all group tables contain a row with the group name (also in text header...)
                continue
            tr = TableRow()
            table.addElement(tr)
            for i, val in enumerate(line):
                if i == 0:
                    tc = TableCell(stylename="Table")
                    tr.addElement(tc)
                    p = P(stylename=tablecontents, text=translation[val][lang])
                elif val == "EzKonforme":
                    tc = TableCell(stylename="Table")
                    tr.addElement(tc)
                    p = P(stylename=tablecontentscenterred,
                          text=translation[val][lang])
                elif val == "Konforme":
                    tc = TableCell(stylename="Table")
                    tr.addElement(tc)
                    p = P(stylename=tablecontentscenter,
                          text=translation[val][lang])
                else:
                    tc = TableCell(stylename="Table")
                    tr.addElement(tc)
                    if isinstance(val, numbers.Number):
                        val = round(val, 1)
                    p = P(stylename=tablecontentscenter, text=val)
                tc.addElement(p)

        textdoc.text.addElement(table)

        blankline = P(text="")
        textdoc.text.addElement(blankline)
    if lang == "eu":
        subjectsp = P(text="%70 baino gainditu gutxiago duten ikasgaiak:")
    else:
        subjectsp = P(text="Asignaturas con menos del %70 de aprobados:")
    textdoc.text.addElement(subjectsp)
    blankline = P(text="")
    textdoc.text.addElement(blankline)
    textList = List(stylename="L1")

    file = path + "ehunekoak-" + period + "-" + year + "-" + group + ".csv"
    with open(file, 'r', encoding="UTF-8") as results:
        reader = csv.reader(results)
        headers = next(reader, None)  # get first row with headers
        for row in reader:
            if float(row[1]) < 70 and row[0] != "All":
                item = ListItem()
                if lang == "eu":
                    item.addElement(
                        P(text=row[0] + ": " + "{:.2f}".format(float(row[1])) +
                          "%"))
                else:
                    item.addElement(
                        P(text=ikasgai[row[0]] + ": " +
                          "{:.2f}".format(float(row[1])) + "%"))
                textList.addElement(item)
                textdoc.text.addElement(textList)

    breakpage = P(stylename=withbreak, text="")
    textdoc.text.addElement(breakpage)

    for diagramtype in [pie, percent]:  #,name2]:
        p = P()
        textdoc.text.addElement(p)
        img_path = path + group + diagramtype
        href = textdoc.addPicture(img_path)
        f = Frame(name=group + diagramtype,
                  anchortype="paragraph",
                  width="17cm",
                  height="7.5cm",
                  zindex="0")
        p.addElement(f)
        img = Image(href=href, type="simple", show="embed", actuate="onLoad")
        f.addElement(img)
예제 #10
0
파일: make_odf.py 프로젝트: tsalidis/dune
def do_args(doc, args):
    if args is None:
        return

    table = Table(name="Table 1")
    table.addElement(
        TableColumn(numbercolumnsrepeated='3', stylename='TableAutoWidth'))

    tr = TableRow(stylename='TableAutoWidth')
    table.addElement(tr)

    tc = TableCell(valuetype="string", stylename='Table Heading')
    tc.addElement(P(text='Name'))
    tr.addElement(tc)

    tc = TableCell(valuetype="string", stylename='Table Heading')
    tc.addElement(P(text='Type'))
    tr.addElement(tc)

    tc = TableCell(valuetype="string", stylename='Table Heading')
    tc.addElement(P(text='Description'))
    tr.addElement(tc)

    for t in args.findall('arg'):
        tr = TableRow(stylename='TableAutoWidth')
        table.addElement(tr)

        # Name.
        tc = TableCell(valuetype="string", stylename='Table Contents')
        tc.addElement(P(text=t.attrib['name']))
        tr.addElement(tc)

        # Type.
        tc = TableCell(valuetype="string", stylename='Table Contents')
        tname = t.attrib['type'].strip()
        if tname == 'List':
            refs = []

            for subtype in t.findall('types/type'):
                stname = subtype.attrib['name']
                ref = BookmarkRef(referenceformat='text', refname=stname)
                ref.addText(stname)
                refs.append(ref)

            if len(refs) == 1:
                c = P(text='List of ')
                c.addElement(refs[0])
                tc.addElement(c)
            else:
                c = P(text='List of: ')
                tc.addElement(c)

                lst = List()
                for r in refs:
                    item_p = P()
                    item_p.addElement(r)
                    item = ListItem()
                    item.addElement(item_p)
                    lst.addElement(item)
                tc.addElement(lst)

        else:
            ref = BookmarkRef(referenceformat='text', refname=tname)
            ref.addText(tname)
            c = P()
            c.addElement(ref)
            tc.addElement(c)

        tr.addElement(tc)

        # Description.
        tc = TableCell(valuetype="string", stylename='Table Contents')
        tr.addElement(tc)
        desc = t.find('doc').text
        if 'value' in t.attrib:
            desc += 'This argument has a fixed value of %s.' % t.attrib['value']
        tc.addElement(P(text=desc))

        lst = do_values(doc, t.find('values'))
        if lst is not None:
            tc.addElement(lst)

    doc.text.addElement(table)
예제 #11
0
 def write(self, model):
     self.doc.text.addElement(P(text=model.name, stylename="ResumeH1"))
     self.doc.text.addElement(P(text=model.address, stylename="ResumeH1"))
     self.doc.text.addElement(P(text=", ".join([model.phone, model.email]),
                                stylename="ResumeH1"))
     for contact in model.contacts:
         self.doc.text.addElement(P(text=contact, stylename="ResumeH1"))
     self.nl()
     self.doc.text.addElement(P(text=model.objective_title,
                                stylename="ResumeH1"))
     self.nl()
     for objective in model.objectives:
         self.doc.text.addElement(P(text=objective, stylename="ResumeText"))
     self.nl()
     self.doc.text.addElement(P(text=model.skillarea_title,
                                stylename="ResumeH1"))
     self.nl()
     for i in range(0, len(model.skillset_titles)):
         skillset_line = P(text="")
         skillset_line.addElement(Span(text=model.skillset_titles[i],
                                       stylename="ResumeBoldText"))
         skillset_line.addElement(Span(
             text=": ", stylename="ResumeBoldText"))
         skillset_line.addText(", ".join(model.skillsets[i]))
         self.doc.text.addElement(skillset_line)
     self.nl()
     self.doc.text.addElement(P(
         text=model.jobs_title, stylename="ResumeH1"))
     for i in range(0, len(model.job_titles)):
         self.nl()
         self.doc.text.addElement(P(text=model.job_titles[i],
                                    stylename="ResumeH2"))
         self.doc.text.addElement(P(text=model.job_employers[i],
                                    stylename="ResumeH2"))
         self.doc.text.addElement(P(text=model.job_descriptions[i],
                                    stylename="ResumeText"))
         achievements_list = List(stylename="ResumeTextList")
         for achievement in model.job_achievements[i]:
             achievements_listitem = ListItem()
             achievements_listitem.addElement(P(text=achievement,
                                                stylename="ResumeText"))
             achievements_list.addElement(achievements_listitem)
         self.doc.text.addElement(achievements_list)
     self.nl()
     self.doc.text.addElement(P(text=model.academics_title,
                                stylename="ResumeH1"))
     academics_list = List(stylename="ResumeTextList")
     for academic in model.academics:
         academics_listitem = ListItem()
         academics_listitem.addElement(P(
             text=academic, stylename="ResumeText"))
         academics_list.addElement(academics_listitem)
     self.doc.text.addElement(academics_list)
     self.nl()
     self.doc.text.addElement(P(
         text=model.awards_title, stylename="ResumeH1"))
     awards_list = List(stylename="ResumeTextList")
     for award in model.awards:
         awards_listitem = ListItem()
         awards_listitem.addElement(P(text=award, stylename="ResumeText"))
         awards_list.addElement(awards_listitem)
     self.doc.text.addElement(awards_list)
     self.nl()