[scribus] python script result

Neil Foster ntfoster at gmail.com
Tue Apr 20 21:52:08 UTC 2021


You could use a basic python script to parse the XML of .sla file rather
than running a script from within Scribus.

E.g. 'countpages.py':

import xml.etree.ElementTree as ET
import sys

def main(args):
    filename = args[1]

    tree = ET.parse(filename)
    root = tree.getroot()

    pages =  root.findall('./DOCUMENT/PAGE')

    print(len(pages))

if __name__ == '__main__':
    main(sys.argv)

Then use it with:
python .\countpages.py "filename.sla"

And pipe that output into whatever you want.

Might be better ways, but I've been doing a lot of manipulating the .sla
files directly rather than using scribus recently so it's what came to mind.

Regards, Neil.







On Tue, 20 Apr 2021 at 22:17, JLuc <jluc at no-log.org> wrote:

> Hello,
>
> I'd like to use the page count of a document in a shell script (linux)
> A python script can access that count with `scribus.pageCount()`
>
> How can scribus script can output this as a string,
> so it's used in a shell script afterward ?
>
> I imagine doing it via writing the result in a text file.
> Is there maybe a better way ?
>
> JLuc
>
>
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20210420/e29c5157/attachment.htm>


More information about the scribus mailing list