[scribus] python script result

JLuc jluc at no-log.org
Wed Apr 21 07:33:12 UTC 2021


Le 20/04/2021 à 23:52, Neil Foster a écrit :
 > You could use a basic python script to parse the XML of .sla file rather
 > than running a script from within Scribus.
I'm glad i asked because i discovered that XML parsing and quering ability
... and because you pointed to that search.
Now i can perform that search with a simple shell grep :
	grep -c "\s<PAGE\s[^>]*PAGEXPOS\s*=\s*\""  $file
Thank you !

 > 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.

That's also what i do : PHP and shell work.

Eg the scribus project manager is all shell :
https://github.com/JLuc/scribus-project-manager
As for now one has to declare each chapter's page count
so it computes the start of each chapter.
I now plan to embed a page count feature,
so it computes the startpage automaticaly
-- and in case a pagecount is declared, it would now check
that the declared page count fits the shell-found pagecount.

JLuc



 >
 > 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.
 >
 >
 > 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>
 > ___
 > 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
 >





More information about the scribus mailing list