示例#1
0
    def convert_text_only(self):
        """Конвертация текста в файле ODT.

        Конвертируется все содерржимое <body>.
        Результат записывается в файл *.cnv.odt
        :return: None
        """

        body = self.doc.body
        new_doc = OpenDocumentText()
        for _body_elem in body.childNodes:
            for _elem in _body_elem.childNodes:
                body_text = teletype.extractText(_elem)
                body_text = self.converter(body_text)
                para = text.P()
                teletype.addTextToElement(para, body_text)
                new_doc.text.addElement(para)
                # print(body_text)

        # Замена шрифта в стилях.
        if self.style_font:
            self.set_font_for_all_styles()

        _suffix = '.all.odt'
        if self.extension:
            _suffix = self.extension

        new_odt = self.p_odt.with_suffix(_suffix)
        new_doc.save(new_odt.as_posix())
示例#2
0
def write_odt(text: str) -> BytesIO:
    """Функция создания odt документа и записи в него данного текста,
    после чего документ возвращается байтовый поток документа"""
    textdoc = OpenDocumentText()
    paragraph_element = P()
    teletype.addTextToElement(paragraph_element, text)
    textdoc.text.addElement(paragraph_element, text)
    target_stream = BytesIO()
    textdoc.write(target_stream)
    target_stream.seek(0)
    return target_stream
示例#3
0
 def test_create(self):
     """ Test that tabs and newlines are converted to elements """
     para = P()
     teletype.addTextToElement(para,
                             u"The boy stood   on the burning deck,\n" +
                             u"\tHis feet\twere\t\tfull of blisters.\n" +
                             u"The captain  stood in\tthe public house\n" +
                             u"         With beer running down his whiskers.   " );
     outfp = io.StringIO()
     para.toXml(1,outfp)
     self.assertEqual(u'''<text:p>The boy stood <text:s text:c="2"/>on the burning deck,<text:line-break/>''' +
       u'''<text:tab/>His feet<text:tab/>were<text:tab/><text:tab/>full of blisters.<text:line-break/>''' +
       u'''The captain <text:s text:c="1"/>stood in<text:tab/>the public house<text:line-break/>''' +
       u''' <text:s text:c="8"/>With beer running down his whiskers. <text:s text:c="2"/></text:p>''', outfp.getvalue())
示例#4
0
    def _addSubSubSection(self, title, text):
        # Adding second heading
        mysecondheading_element = H(outlinelevel=2, stylename=self._h3style)
        mysecondheading_text = title
        teletype.addTextToElement(mysecondheading_element,
                                  mysecondheading_text)
        self._textdoc.text.addElement(mysecondheading_element)

        if text != '':
            # Adding a paragraph
            paragraph_element = P(stylename=self._justifystyle)
            paragraph_text = text
            teletype.addTextToElement(paragraph_element, paragraph_text)
            self._textdoc.text.addElement(paragraph_element, paragraph_text)
示例#5
0
 def test_create(self):
     """ Test that tabs and newlines are converted to elements """
     para = P()
     teletype.addTextToElement(para,
                             "The boy stood   on the burning deck,\n" +
                             "\tHis feet\twere\t\tfull of blisters.\n" +
                             "The captain  stood in\tthe public house\n" +
                             "         With beer running down his whiskers.   " );
     outfp = cStringIO.StringIO()
     para.toXml(1,outfp)
     self.assertEqual('''<text:p>The boy stood <text:s text:c="2"/>on the burning deck,<text:line-break/>''' + 
       '''<text:tab/>His feet<text:tab/>were<text:tab/><text:tab/>full of blisters.<text:line-break/>''' + 
       '''The captain <text:s text:c="1"/>stood in<text:tab/>the public house<text:line-break/>''' +
       ''' <text:s text:c="8"/>With beer running down his whiskers. <text:s text:c="2"/></text:p>''', outfp.getvalue())
示例#6
0
    def _export_odt(self, fname: str):
        doc = odf.opendocument.OpenDocumentText()
        doc.styles.addElement(self.odfstyles["h1"])
        doc.automaticstyles.addElement(self.odfstyles["bold"])

        for index, practice in enumerate(self.practices):
            header = odf.text.H(
                outlinelevel=1,
                stylename=self.odfstyles["h1"],
                text=(
                    f"[{practice.date:%a, %d %B %Y}] Practice #{index + 1} - "
                    f"{practice.instrument.name.title()}"),
            )
            doc.text.addElement(header)
            doc.text.addElement(odf.text.P())

            self._add_bullet_list_odf(doc, "Goals:",
                                      [x.name for x in practice.goals.all()])

            exercises_para = self._bold("Exercises:")
            bulletlist = odf.text.List(stylename=self.odfstyles["bulletlist"])
            for exercise in practice.exercises.all():
                listitem = odf.text.ListItem()
                listitem_p = odf.text.P(
                    text=(f"{exercise.name} - {exercise.bpm_start} to "
                          f"{exercise.bpm_end} bpm - {exercise.minutes}m"))
                listitem.addElement(listitem_p)
                bulletlist.addElement(listitem)
            doc.text.addElement(exercises_para)
            doc.text.addElement(bulletlist)
            doc.text.addElement(odf.text.P())

            self._add_bullet_list_odf(
                doc, "Improvements:",
                [x.name for x in practice.improvements.all()])
            self._add_bullet_list_odf(
                doc, "Positives:", [x.name for x in practice.positives.all()])

            notes = self._bold("Notes: ")
            teletype.addTextToElement(
                notes, practice.notes if practice.notes is not None else "")
            doc.text.addElement(notes)
            doc.text.addElement(odf.text.P())
            doc.text.addElement(odf.text.P())

        doc.save(fname)
示例#7
0
def imprimir(conexion, obra, documento, propiedades=None):
    consulta = QtSql.QSqlQuery(conexion)
    Autor = ""
    Obra = ""
    Listado = u"LISTADO DE PRECIOS AUXILIARES"
    ListadoManoObra = u". MANO DE OBRA"
    ListadoMaquinaria = u".MAQUINARIA"
    ListadoMateriales = u". MATERIALES"
    TextoCodigo = u"Código"
    TextoUd = u"Ud"
    TextoCantidad = u"Cdad."
    TextoResumen = u"Resumen"
    TextoPrecio = u"Precio"
    TextoTotal = u"Total"
    tipo = 0
    if tipo == 1:
        Listado += ListadoManoObra
    elif tipo == 2:
        Listado += ListadoMateriales
    elif tipo == 3:
        Listado += ListadoMaquinaria
    #documento y estilos
    Instancia = modulo.Estilo()
    s = documento.styles
    d = Instancia.ListaEstilos()
    for key in d:
        s.addElement(d[key])
    precision = "%.2f"
    #consultas para el encabezado
    consulta_nombre = "SELECT propiedad->>'Valor' AS \"Valor\" FROM (SELECT jsonb_array_elements(propiedades->'Valor') \
	AS propiedad FROM \"" + obra + "_Propiedades\" \
	WHERE propiedades->>'Propiedad'= 'Proyectista') AS datos WHERE propiedad->>'Variable'='zPryNombre1'"

    consulta.exec_(consulta_nombre)
    while consulta.next():
        Autor = consulta.value(0)
    consulta_obra = "SELECT propiedad->>'Valor' AS \"Valor\" FROM (SELECT jsonb_array_elements(propiedades->'Valor') \
	AS propiedad FROM \"" + obra + "_Propiedades\"  \
	WHERE propiedades->>'Propiedad'= 'Datos generales') AS datos WHERE propiedad->>'Variable'='zNombre'"

    consulta.exec_(consulta_obra)
    while consulta.next():
        Obra = consulta.value(0)
    ###############
    ###Contenido###
    ###############
    #Titulo
    titulo = P(stylename=Instancia.Estilos("Heading 1"))
    teletype.addTextToElement(titulo, Listado)
    documento.text.addElement(titulo)
    #despues un salto de linea
    salto = P()
    lb = LineBreak()
    salto.addElement(lb)
    documento.text.addElement(salto)
    #encabezado
    linea = TextoCodigo + "\t" + TextoCantidad + "\t" + TextoUd + "\t" + TextoResumen + "\t" + TextoPrecio + "\t" + TextoTotal
    encabezado = P(
        stylename=Instancia.Estilos("Tabuladores Hoja Listados Negritas"))
    teletype.addTextToElement(encabezado, linea)
    documento.text.addElement(encabezado)
    #linea horizontal
    linea = " "
    lineahorizontal = P(stylename=Instancia.Estilos("Linea horizontal gruesa"))
    teletype.addTextToElement(lineahorizontal, linea)
    documento.text.addElement(lineahorizontal)
    #consulta
    consulta.exec_("SELECT * FROM ver_conceptos_unitarios('" + obra + "','" +
                   str(tipo) + "')")
    rec = consulta.record()
    codigo = rec.indexOf("codigo")
    cantidad = rec.indexOf("cantidad")
    ud = rec.indexOf("ud")
    resumen = rec.indexOf("resumen")
    precio = rec.indexOf("precio")
    #datos	de la consulta
    while consulta.next():
        linea = consulta.value(codigo)+"\t"+formatear(consulta.value(cantidad))+"\t"+\
         str(consulta.value(ud))+"\t"+consulta.value(resumen)+"\t"+formatear(consulta.value(precio))+"\t"+\
         formatear(consulta.value(cantidad)*consulta.value(precio))
        tabp = P(
            stylename=Instancia.Estilos("Tabuladores Hoja Listados Normal"))
        teletype.addTextToElement(tabp, linea)
        documento.text.addElement(tabp)

    return documento
示例#8
0
def add_str(paragraph_element, string):
    """Add string to paragraph element."""
    teletype.addTextToElement(paragraph_element, string)
示例#9
0
def imprimir(conexion, obra, documento, propiedades=None):
    consulta = QtSql.QSqlQuery(conexion)
    Autor = ""
    Obra = ""
    Listado = u"RESUMEN DE PRESUPUESTO"
    Instancia = modulo.Estilo()
    s = documento.styles
    d = Instancia.ListaEstilos()
    for key in d:
        s.addElement(d[key])
    precision = "%.2f"
    ###############
    ###Contenido###
    ###############
    #Titulo
    consulta.exec_(
        "SELECT resumen FROM \"" + obra + "_Conceptos\" AS C, \"" + obra +
        "_Relacion\" AS R WHERE C.codigo = R.codhijo AND R.codpadre IS NULL")
    resumen = ""
    while consulta.next():
        resumen = consulta.value(0)
    linea = Listado
    parrafo = P(stylename=Instancia.Estilos("Heading 1"))
    teletype.addTextToElement(parrafo, linea)
    documento.text.addElement(parrafo)
    titulo = P(stylename=Instancia.Estilos("Heading 2"))
    teletype.addTextToElement(titulo, resumen)
    documento.text.addElement(titulo)
    #linea horizontal
    linea = " "
    lineahorizontal = P(stylename=Instancia.Estilos("Linea horizontal gruesa"))
    teletype.addTextToElement(lineahorizontal, linea)
    documento.text.addElement(lineahorizontal)
    #consulta
    consulta.exec_("SELECT * FROM ver_resumen_capitulos('" + obra + "')")
    #datos	de la consulta
    rec = consulta.record()
    codigo = rec.indexOf("codigo")
    resumen = rec.indexOf("resumen")
    cantidad = rec.indexOf("cantidad")
    euros = rec.indexOf("total")
    porcentaje = rec.indexOf("porcentaje")
    EM = 0.0
    while consulta.next():
        linea = consulta.value(
            codigo) + "\t" + consulta.value(resumen) + "\t" + formatear(
                consulta.value(euros)) + "\t" + formatear(
                    consulta.value(porcentaje)) + " %"
        print(linea)
        tabp = P(
            stylename=Instancia.Estilos("Normal con tabuladores capitulos"))
        teletype.addTextToElement(tabp, linea)
        documento.text.addElement(tabp)
        EM = EM + consulta.value(euros)
    #EM
    salto = P()
    lb = LineBreak()
    salto.addElement(lb)
    documento.text.addElement(salto)
    lineaEM = "\tTotal Ejecución Material:\t" + formatear(EM)
    parrafo = P(
        stylename=Instancia.Estilos("Normal con tabuladores resumen negritas"))
    teletype.addTextToElement(parrafo, lineaEM)
    documento.text.addElement(parrafo)
    #GG
    GG = 0.0
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'Porcentajes') AS subdatos WHERE datos->>'Variable' = 'zPorGastosGenerales'"
    )
    while consulta.next():
        GG = float(consulta.value(0))
        print("Gastos generales " + str(GG) + "\t")
    GastosGenerales = EM * GG / 100
    lineaGG = "\t\t" + str(GG) + "% Gastos generales\t" + formatear(
        GastosGenerales)
    parrafo = P(stylename=Instancia.Estilos("Normal con tabuladores resumen"))
    teletype.addTextToElement(parrafo, lineaGG)
    documento.text.addElement(parrafo)
    #BI
    BI = 0.0
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'Porcentajes') AS subdatos WHERE datos->>'Variable' = 'zPorBenIndustrial'"
    )
    while consulta.next():
        BI = float(consulta.value(0))
        print("Gastos generales " + str(BI) + "\t")
    BeneficioIndustrial = EM * BI / 100
    lineaBI = "\t\t" + str(BI) + "%Beneficio Industrial\t" + formatear(
        BeneficioIndustrial)
    parrafo = P(stylename=Instancia.Estilos("Normal con tabuladores resumen"))
    teletype.addTextToElement(parrafo, lineaBI)
    documento.text.addElement(parrafo)
    #suma de GG+BI
    lineaGGBI = "\t\tSuma de G.G. + B.I.: \t" + formatear(GastosGenerales +
                                                          BeneficioIndustrial)
    parrafo = P(stylename=Instancia.Estilos("Normal con tabuladores resumen"))
    teletype.addTextToElement(parrafo, lineaGGBI)
    documento.text.addElement(parrafo)
    #PContrata
    importeTPC = EM + GastosGenerales + BeneficioIndustrial
    lineaTPC = "\tTOTAL PRESUPUESTO DE CONTRATA: \t" + formatear(importeTPC)
    parrafo = P(
        stylename=Instancia.Estilos("Normal con tabuladores resumen negritas"))
    teletype.addTextToElement(parrafo, lineaTPC)
    documento.text.addElement(parrafo)
    #IVA
    IVA = 0
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'Porcentajes') AS subdatos WHERE datos->>'Variable' = 'zPorIVAEjecucion'"
    )
    while consulta.next():
        IVA = float(consulta.value(0))
    importeIVA = importeTPC * IVA / 100
    lineaIVA = "\t\t" + str(IVA) + "% IVA\t" + formatear(importeIVA)
    parrafo = P(stylename=Instancia.Estilos("Normal con tabuladores resumen"))
    teletype.addTextToElement(parrafo, lineaIVA)
    documento.text.addElement(parrafo)
    #PGeneral
    importeTPG = importeTPC + (importeTPC * IVA / 100)
    lineaTPC = "\tTOTAL PRESUPUESTO GENERAL: \t" + formatear(importeTPG)
    parrafo = P(
        stylename=Instancia.Estilos("Normal con tabuladores resumen negritas"))
    teletype.addTextToElement(parrafo, lineaTPC)
    documento.text.addElement(parrafo)
    #salto
    salto = P()
    lb = LineBreak()
    salto.addElement(lb)
    documento.text.addElement(salto)
    #cantidad en letra
    consulta.exec_("SELECT numero_en_euro(" + str(importeTPG) + ")")
    print(consulta.lastError().text())
    cantidadenletra = ""
    while consulta.next():
        cantidadenletra = consulta.value(0)
    print("cantidad en letras " + cantidadenletra)
    resumen = P()
    texto_resumen = Span(
        stylename=Instancia.Estilos("Normal"),
        text="Asciende el presupuesto general a la expresada cantidad de ")
    resumen.addElement(texto_resumen)
    texto_cantidad_letra = Span(stylename=Instancia.Estilos("Negritas"),
                                text=cantidadenletra)
    resumen.addElement(texto_cantidad_letra)
    documento.text.addElement(resumen)
    #firmas-datos
    encabezado_firma_proyectista = ""
    nombre_proyectista1 = ""
    nombre_proyectista2 = ""
    encabezado_firma_promotor = ""
    nombre_promotor1 = ""
    nombre_promotor2 = ""
    ciudad = ""
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'Proyectista') AS subdatos WHERE datos->>'Variable' = 'zPryEncabezamiento'"
    )
    while consulta.next():
        encabezado_firma_proyectista = consulta.value(0)
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'Proyectista') AS subdatos WHERE datos->>'Variable' = 'zPryNombre1'"
    )
    while consulta.next():
        nombre_proyectista1 = consulta.value(0)
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'Proyectista') AS subdatos WHERE datos->>'Variable' = 'zPryNombre2'"
    )
    while consulta.next():
        nombre_proyectista2 = consulta.value(0)
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'El promotor') AS subdatos WHERE datos->>'Variable' = 'zProEncabezamiento'"
    )
    while consulta.next():
        encabezado_firma_promotor = consulta.value(0)
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'El promotor') AS subdatos WHERE datos->>'Variable' = 'zProNombre1'"
    )
    while consulta.next():
        nombre_promotor1 = consulta.value(0)
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'El promotor') AS subdatos WHERE datos->>'Variable' = 'zProNombre2'"
    )
    while consulta.next():
        nombre_promotor2 = consulta.value(0)
    consulta.exec_(
        "SELECT datos->>'Valor' FROM (SELECT jsonb_array_elements(propiedades->'Valor') AS datos \
				FROM \"" + obra + "_Propiedades\" \
				WHERE propiedades->>'Propiedad' = 'Datos generales') AS subdatos WHERE datos->>'Variable' = 'zCiudad'"
    )
    while consulta.next():
        ciudad = consulta.value(0)
    #Linea ciudad y fecha
    #salto
    salto = P()
    lb = LineBreak()
    salto.addElement(lb)
    documento.text.addElement(salto)
    fecha = datetime.now()
    dia = fecha.strftime("%d")
    mes = fecha.strftime("%B")
    anno = fecha.strftime("%Y")
    lineaciudadfecha = "En " + ciudad + ", a " + dia + " de " + mes + " de " + anno
    parrafo = P(stylename=Instancia.Estilos("NormalP"))
    teletype.addTextToElement(parrafo, lineaciudadfecha)
    documento.text.addElement(parrafo)
    #salto
    salto = P()
    lb = LineBreak()
    salto.addElement(lb)
    documento.text.addElement(salto)
    #linea 1 firmas
    linea1 = encabezado_firma_proyectista + "\t\t\t" + encabezado_firma_promotor
    parrafo = P(stylename=Instancia.Estilos("NegritasP"))
    teletype.addTextToElement(parrafo, linea1)
    documento.text.addElement(parrafo)
    #saltos de linea
    for n in range(0, 2):
        salto = P()
        lb = LineBreak()
        salto.addElement(lb)
        documento.text.addElement(salto)
    #linea 2 firmas
    linea2 = nombre_proyectista1 + "\t\t\t" + nombre_promotor1
    parrafo = P(stylename=Instancia.Estilos("NormalP"))
    teletype.addTextToElement(parrafo, linea2)
    documento.text.addElement(parrafo)
    #linea 2 firmas
    linea3 = nombre_proyectista2 + "\t\t\t" + nombre_promotor2
    parrafo = P(stylename=Instancia.Estilos("NormalP"))
    teletype.addTextToElement(parrafo, linea3)
    documento.text.addElement(parrafo)

    return documento
示例#10
0
    def generate(self):
        self._textdoc = OpenDocumentText()

        # Creating different style used in the document
        s = self._textdoc.styles

        # For Level-1 Headings that are centerd
        h1style = Style(name="BsHeading 1", family="paragraph")
        h1style.addElement(
            ParagraphProperties(attributes={"textalign": "center"}))
        h1style.addElement(
            TextProperties(attributes={
                "fontsize": "18pt",
                "fontweight": "bold"
            }))

        # For Level-2 Headings that are centered
        self._h2style = Style(name="BsHeading 2", family="paragraph")
        self._h2style.addElement(
            ParagraphProperties(attributes={"textalign": "left"}))
        self._h2style.addElement(
            TextProperties(attributes={
                "fontsize": "15pt",
                "fontweight": "bold"
            }))

        # For Level-3 Headings that are centered
        self._h3style = Style(name="BsHeading 3", family="paragraph")
        self._h3style.addElement(
            ParagraphProperties(attributes={"textalign": "left"}))
        self._h3style.addElement(
            TextProperties(attributes={
                "fontsize": "14pt",
                "fontweight": "bold"
            }))

        # For bold text
        boldstyle = Style(name="Bold", family="text")
        boldstyle.addElement(TextProperties(attributes={"fontweight": "bold"}))

        # For numbered list
        numberedliststyle = ListStyle(name="NumberedList")
        level = 1
        numberedlistproperty = ListLevelStyleNumber(level=str(level),
                                                    numsuffix=".",
                                                    startvalue=1)
        numberedlistproperty.setAttribute('numsuffix', ".")
        numberedlistproperty.addElement(
            ListLevelProperties(minlabelwidth="%fcm" % (level - .2)))
        numberedliststyle.addElement(numberedlistproperty)

        # For Bulleted list
        bulletedliststyle = ListStyle(name="BulletList")
        level = 1
        bulletlistproperty = ListLevelStyleBullet(level=str(level),
                                                  bulletchar=u"•")
        bulletlistproperty.addElement(
            ListLevelProperties(minlabelwidth="%fcm" % level))
        bulletedliststyle.addElement(bulletlistproperty)

        # Justified style
        self._justifystyle = Style(name="justified", family="paragraph")
        self._justifystyle.addElement(
            ParagraphProperties(attributes={"textalign": "justify"}))

        # Creating a tabstop at 10cm
        tabstops_style = TabStops()
        tabstop_style = TabStop(position="10cm")
        tabstops_style.addElement(tabstop_style)
        tabstoppar = ParagraphProperties()
        tabstoppar.addElement(tabstops_style)
        tabparagraphstyle = Style(name="Question", family="paragraph")
        tabparagraphstyle.addElement(tabstoppar)
        s.addElement(tabparagraphstyle)

        # Register created styles to styleset
        s.addElement(h1style)
        s.addElement(self._h2style)
        s.addElement(boldstyle)
        s.addElement(numberedliststyle)
        s.addElement(bulletedliststyle)
        s.addElement(self._justifystyle)
        s.addElement(tabparagraphstyle)

        # Adding main heading
        mymainheading_element = H(outlinelevel=1, stylename=h1style)
        mymainheading_text = "Save the Cat Beat Sheet"
        teletype.addTextToElement(mymainheading_element, mymainheading_text)
        self._textdoc.text.addElement(mymainheading_element)

        self._addSubSection('Name', self._data['movie']['name'])
        self._addSubSection('LogLine', self._data['movie']['logline'])
        self._addSubSection('Theme', self._data['movie']['theme'])
        self._addSubSection('Genre', self._data['movie']['genre'])
        self._addSubSection('Author', '')
        self._addParagraph('Nome: ' + self._data['author']['name'])
        self._addParagraph('e-mail: ' + self._data['author']['email'])
        self._addParagraph('Institute: ' + self._data['author']['institute'])

        self._addSubSection('Synopsis', self._data['synopsis'])
        self._addSubSection('Beat Sheet', '')
        for card in self._data[1]['beat-sheet']:
            self._addSubSubSection(card['title'], card['text'])

        self._addSubSection('Plot', self._data['plot'])
        self._addSubSection('Argumento', self._data['argumento'])
        self._addSubSection('Escaleta', self._data['escaleta'])

        # Adding bulleted list
        #        bulletlist = List(stylename=bulletedliststyle)
        #        listitemelement1 = ListItem()
        #        listitemelement1_paragraph = P()
        #        listitemelement1_content = "My first item"
        #        teletype.addTextToElement(listitemelement1_paragraph, listitemelement1_content)
        #        listitemelement1.addElement(listitemelement1_paragraph)
        #        bulletlist.addElement(listitemelement1)
        #        listitemelement2 = ListItem()
        #        listitemelement2_paragraph = P()
        #        listitemelement2_content = "My second item"
        #        teletype.addTextToElement(listitemelement2_paragraph, listitemelement2_content)
        #        listitemelement2.addElement(listitemelement2_paragraph)
        #        bulletlist.addElement(listitemelement2)
        #
        #        self._textdoc.text.addElement(bulletlist)
        #
        #        # Adding numbered list
        #        numberlist = List(stylename=numberedliststyle)
        #        listitemelement1 = ListItem()
        #        listitemelement1_paragraph = P()
        #        listitemelement1_content = "My first item"
        #        teletype.addTextToElement(listitemelement1_paragraph, listitemelement1_content)
        #        listitemelement1.addElement(listitemelement1_paragraph)
        #        numberlist.addElement(listitemelement1)
        #        listitemelement2 = ListItem()
        #        listitemelement2_paragraph = P()
        #        listitemelement2_content = "My second item"
        #        teletype.addTextToElement(listitemelement2_paragraph, listitemelement2_content)
        #        listitemelement2.addElement(listitemelement2_paragraph)
        ##        numberlist.addElement(listitemelement2)
        ##
        #        self._textdoc.text.addElement(numberlist)

        # Adding a tabbed sentence to check tabstop
        #        newtext = "Testing\tTabstops"
        #        tabp = P(stylename=tabparagraphstyle)
        #        teletype.addTextToElement(tabp, newtext)
        #        self._textdoc.text.addElement(tabp)

        self._textdoc.save(u"/tmp/save-the-cat.odt")
示例#11
0
 def _addParagraph(self, text):
     paragraph_element = P(stylename=self._justifystyle)
     paragraph_text = text
     teletype.addTextToElement(paragraph_element, paragraph_text)
     self._textdoc.text.addElement(paragraph_element, paragraph_text)
示例#12
0
    def Estilos(self, nombre):
        return self.estilos[nombre]

    def UpdateEstilos(self, nombre, estilo):
        self.s.addElement(estilo)
        self.estilos.update({nombre: estilo})

    def ListaEstilos(self):
        return self.estilos


if __name__ == "__main__":
    Instancia = Estilos()
    doc = Instancia.Documento()
    linea = "La prueba definitiva"
    parrafo = P(stylename=Instancia.Estilo("Heading 1"))
    teletype.addTextToElement(parrafo, linea)
    doc.text.addElement(parrafo)

    linea1 = "La prueba definitiva 2"
    parrafo = P(stylename=Instancia.Estilo("Heading 2"))
    teletype.addTextToElement(parrafo, linea1)
    doc.text.addElement(parrafo)

    linea2 = "Hola\tEsto\tson\ttabuladores\taqui\tpuestos"
    parrafo = P(stylename=Instancia.Estilo("Negritas con tabuladores"))
    teletype.addTextToElement(parrafo, linea2)
    doc.text.addElement(parrafo)

    doc.save("kkk.odt")
示例#13
0
def put_text(input_text,style,place):
    p = text.P(stylename=style)
    teletype.addTextToElement(p,input_text)
    place.addElement(p)
示例#14
0
def put_header(input_text, style, place, outlinelevel):
    p = text.H(outlinelevel=outlinelevel, stylename=style)
    teletype.addTextToElement(p, input_text)
    place.addElement(p)
示例#15
0
def imprimir(conexion, obra, documento, propiedades = None):
	consulta_conceptos = QtSql.QSqlQuery (conexion)
	consulta_mediciones = QtSql.QSqlQuery (conexion)
	#documento y estilos
	Instancia = modulo.Estilo()	
	s = documento.styles
	d = Instancia.ListaEstilos()
	for key in d:
		s.addElement(d[key])
	precision = "%.2f"
	Autor = ""
	Obra = ""
	Listado = u"PRESUPUESTOS Y MEDICIONES"
	cadena_consulta_texto = "WITH RECURSIVE tree AS(SELECT codpadre, codhijo, canpres, cancert, 1 AS depth, cast(posicion as text) AS camino, posicion FROM \"" + obra + "_Relacion\" \
		WHERE codpadre is NULL \
		UNION ALL \
		SELECT rel.codpadre, rel.codhijo, rel.canpres, rel.cancert, depth+1, concat(camino,'.',cast(rel.posicion as text)) , rel.posicion \
		FROM \"" + obra + "_Relacion\" rel \
		JOIN tree t ON rel.codpadre = t.codhijo) \
		SELECT C.codigo, C.naturaleza, C.ud, C.resumen, C.descripcion, tree.canpres,tree.cancert, C.preciocert/1 AS \"Porcentaje\", C.preciomed, C.preciocert, \
		C.preciomed*tree.canpres as \"Importe presupuesto\", C.preciocert*tree.cancert as \"Importe certifi.\", tree.depth, tree.camino \
		FROM tree, \"" + obra + "_Conceptos\" AS C \
		WHERE C.codigo=tree.codhijo \
		ORDER BY string_to_array(camino, '.')::int[]"
	contador_linea_total = 0 #se usa para empezar a poner las lineas de total de capitulos. Se pondran cuando hayan pasado dos capitulos.
	linea_total = ""
	tipo_partida_anterior = 0
	contador_capitulos = 0 #usado para descartar la primera partida que es el nodo 0 de la obra
	capitulo_anterior = ""
	resumen_anterior = ""
	precio_anterior = ""
	linea_cabecera_medicion = U"Comentario\tUd.\tLong.\tAnch.\tAlt.\tParc.\tCant.\tPrec.\tImpor."
	consulta_conceptos.exec(cadena_consulta_texto)
	while (consulta_conceptos.next()):
		if consulta_conceptos.value(1) == 6:
			if tipo_partida_anterior == 6 and contador_capitulos > 1:
				#un espacio
				salto = P()
				lb = LineBreak()
				salto.addElement(lb)
				documento.text.addElement(salto)
				#linea de total
				lineatotal = "TOTAL CAPÍTULO " + capitulo_anterior + " " + resumen_anterior + "\t" + precio_anterior
				print (lineatotal)
				parrafo = P(stylename = Instancia.Estilos("Tabuladores Linea Total Capitulo"))
				teletype.addTextToElement(parrafo, lineatotal)
				documento.text.addElement(parrafo)
				#salto de pagina
				linea = ""
				saltopagina = P(stylename = Instancia.Estilos("Salto de Pagina"))				
				teletype.addTextToElement(saltopagina, linea)
				documento.text.addElement(saltopagina)
				
			tipo_partida_anterior = consulta_conceptos.value(1)
			capitulo_anterior = consulta_conceptos.value(0)
			resumen_anterior = consulta_conceptos.value(3)
			precio_anterior = formatear(consulta_conceptos.value(8))
			contador_capitulos = contador_capitulos + 1			
			capitulo = consulta_conceptos.value(0)
		
		if consulta_conceptos.value(1) == 6 and contador_capitulos > 1:			
			linea = "CAPÍTULO " + consulta_conceptos.value(0) + " " +consulta_conceptos.value(3)
			parrafo = P(stylename = Instancia.Estilos("Capitulo"))
			teletype.addTextToElement(parrafo, linea)
			documento.text.addElement(parrafo)
			linea = consulta_conceptos.value(4)
			
		if consulta_conceptos.value(1) == 7: #PARTIDAS
			linea = consulta_conceptos.value(0) + "\t" + consulta_conceptos.value(2) + " " + consulta_conceptos.value(3)
			parrafo = P(stylename = Instancia.Estilos("Negritas"))
			teletype.addTextToElement(parrafo, linea)
			documento.text.addElement(parrafo)
			linea = consulta_conceptos.value(4)
			parrafo = P(stylename = Instancia.Estilos("Texto"))
			teletype.addTextToElement(parrafo, linea)
			documento.text.addElement(parrafo)
			linea = consulta_conceptos.value(4)
			#ahora las mediciones
			#primero un salto
			salto = P()
			lb = LineBreak()
			salto.addElement(lb)
			documento.text.addElement(salto)
			cadena_consulta_mediciones = "SELECT * FROM ver_medcert('" + obra + "','" + capitulo + "','" + consulta_conceptos.value(0) +"')"
			consulta_mediciones.exec(cadena_consulta_mediciones)
			subtotal = 0
			parrafomediciones = P(stylename = Instancia.Estilos("Tabuladores Hoja Listados Negritas"))
			teletype.addTextToElement(parrafomediciones, linea_cabecera_medicion)
			documento.text.addElement(parrafomediciones)
			while (consulta_mediciones.next()):
				linea_medicion = consulta_mediciones.value(1)+ "\t"+ formatear(consulta_mediciones.value(2),1)+ "\t" + \
								formatear(consulta_mediciones.value(3)) + "\t"+ formatear(consulta_mediciones.value(4))+ "\t" + \
								formatear(consulta_mediciones.value(5)) + "\t"+ formatear(consulta_mediciones.value(7))
				parrafomediciones = P(stylename = Instancia.Estilos("Tabuladores Lineas Medicion"))
				teletype.addTextToElement(parrafomediciones, linea_medicion)
				documento.text.addElement(parrafomediciones)
				subtotal = subtotal + consulta_mediciones.value(7)
			#linea de sumatoria
			lineasumatoria = " "
			parrafo = P(stylename = Instancia.Estilos("Linea horizontal sumatoria"))
			teletype.addTextToElement(parrafo, lineasumatoria)
			documento.text.addElement(parrafo)
			#cantidad sumatoria
			sumatoria = "\t\t\t\t\t\t" + formatear(consulta_conceptos.value(5))+ "\t" + formatear(consulta_conceptos.value(8)) + "\t" + formatear(consulta_conceptos.value(10))
			parrafo = P(stylename = Instancia.Estilos("Tabuladores Lineas Medicion"))
			teletype.addTextToElement(parrafo, sumatoria)
			documento.text.addElement(parrafo)
	#ultimo subtotal
	lineatotal = "TOTAL CAPÍTULO " + capitulo_anterior + " " + resumen_anterior + "\t" + precio_anterior
	print (lineatotal)
	parrafo = P(stylename = Instancia.Estilos("Tabuladores Linea Total Capitulo"))
	teletype.addTextToElement(parrafo, lineatotal)
	documento.text.addElement(parrafo)	
	
	return documento