diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-02 20:01:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-02 20:01:10 +0000 |
commit | da875fcb62c801b8d19b3d4d984ad963574fb356 (patch) | |
tree | 3d85503747c56c2a387b291524442946f4bebb73 /examples/chaindemo.py | |
parent | Initial commit. (diff) | |
download | pysilfont-upstream.tar.xz pysilfont-upstream.zip |
Adding upstream version 1.6.0.upstream/1.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | examples/chaindemo.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/chaindemo.py b/examples/chaindemo.py new file mode 100644 index 0000000..c832dc2 --- /dev/null +++ b/examples/chaindemo.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +''' Demo of how to chain calls to multiple scripts together. +Running + python chaindemo.py infont outfont --featfile feat.csv --uidsfile uids.csv +will run execute() against psfnormalize, psfsetassocfeat and psfsetassocuids passing the font, parameters +and logger objects from one call to the next. So: +- the font is only opened once and written once +- there is a single log file produced +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2017 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://opensource.org/licenses/MIT)' +__author__ = 'David Raymond' + +from silfont.core import execute, chain +import silfont.scripts.psfnormalize as psfnormalize +import silfont.scripts.psfsetassocfeat as psfsetassocfeat +import silfont.scripts.psfsetassocuids as psfsetassocuids + +argspec = [ + ('ifont',{'help': 'Input font file'}, {'type': 'infont'}), + ('ofont',{'help': 'Output font file','nargs': '?' }, {'type': 'outfont'}), + ('--featfile',{'help': 'Associate features csv'}, {'type': 'filename'}), + ('--uidsfile', {'help': 'Associate uids csv'}, {'type': 'filename'}), + ('-l','--log',{'help': 'Log file'}, {'type': 'outfile', 'def': '_chain.log'})] + +def doit(args) : + + argv = ['psfnormalize', 'dummy'] # 'dummy' replaces input font since font object is being passed. Other parameters could be added. + font = chain(argv, psfnormalize.doit, psfnormalize.argspec, args.ifont, args.paramsobj, args.logger, args.quiet) + + argv = ['psfsetassocfeat', 'dummy', '-i', args.featfile] + font = chain(argv, psfsetassocfeat.doit, psfsetassocfeat.argspec, font, args.paramsobj, args.logger, args.quiet) + + argv = ['psfsetassocuids', 'dummy', '-i', args.uidsfile] + font = chain(argv, psfsetassocuids.doit, psfsetassocuids.argspec, font, args.paramsobj, args.logger, args.quiet) + + return font + +def cmd() : execute("UFO",doit, argspec) + +if __name__ == "__main__": cmd() + |