#!/usr/bin/python3
# -*- coding:Utf-8 -*-

"""
Test loading styles of an existing SLA and applying them to a new SLA file.
"""

import pyscribus.sla as sla
import pyscribus.styles as styles

if __name__ == "__main__":
    # Import the styles of a existing file

    s = styles.fromSLA("tests/styles.sla")

    # Create a SLA file from scratch
    testfile = sla.SLA(version="1.5.5")
    testfile.fromdefault()

    # Add the imported files to it
    testfile.documents.styles = s

    # Save the new file
    testfile.save("tests-outputs/test-styles-import.sla")

# vim:set shiftwidth=4 softtabstop=4:
Exemplo n.º 2
0
"""
Templating system test for PyScribus.

Produce test-templated.sla using tests/templating.sla
as template document.
"""

import pyscribus.sla as sla

if __name__ == "__main__":
    # templating=True activate templating functions

    template = sla.SLA(
        "tests/templating.sla",
        "1.5.5",
        templating=True
    )

    # The data that will be injected into the document

    datas = [
        {
            "%Title%": "An editorial",
            "%Lead%": "I know better than everyone of you",
            "%Text%": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
            "%Following%": "p. 4"
        },
        {
            "%Title%": "First article title",
            "%Lead%": "This article is about stuff.",
#!/usr/bin/python3
# -*- coding:Utf-8 -*-
"""
"""

import pyscribus.sla as sla

if __name__ == "__main__":
    slafile = sla.SLA("tests/images.sla")

    print(slafile.pageobjects("image"))

# vim:set shiftwidth=4 softtabstop=4:
Exemplo n.º 4
0
#!/usr/bin/python3
# -*- coding:Utf-8 -*-

"""
Loads and immediatly exports to another file to check differences
between Scribus and PyScribus SLAs.
"""

import pyscribus.sla as sla

if __name__ == "__main__":
    slafile = sla.SLA("tests/images.sla", "1.5.5")
    slafile.save("tests-outputs/test-load-export.sla")

# vim:set shiftwidth=4 softtabstop=4:
#!/usr/bin/python3
# -*- coding:Utf-8 -*-
"""
Draw a wireframe representation of a SLA file into "test_wireframe.png".
"""

import pyscribus.sla as sla
import pyscribus.extra.wireframe as wire

if __name__ == "__main__":
    slafile = sla.SLA("tests/wireframe.sla", "1.5.5")

    wireframe = wire.Wireframe()
    wireframe.from_sla(slafile)

    wireframe.draw(output="tests-outputs/test_wireframe.png",
                   stylesheet=True,
                   margins=[10, 10])

# vim:set shiftwidth=4 softtabstop=4:
Exemplo n.º 6
0
#!/usr/bin/python3
# -*- coding:Utf-8 -*-

"""
Testing tables objects
"""

import pyscribus.sla as sla
import pyscribus.pageobjects as pageobjects

if __name__ == "__main__":
    # ---------------------------------------------------------------

    # Import the SLA file

    slafile = sla.SLA("tests/tables.sla", "1.5.5")

    # Gets all tables frames in the document
    tables = slafile.pageobjects("table")

    # ---------------------------------------------------------------

    print("Cells :")

    # Selects the last table frame in the document
    last = tables[-1]

    # Shows each cell information
    for c in last.cells:
        print(c.row, c.column, c.story.rawtext(), "|", c.box)