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 /lib/silfont/scripts/psfxml2compdef.py | |
parent | Initial commit. (diff) | |
download | pysilfont-1f9ed76662986bf6e3802e9fb3080d61e5797532.tar.xz pysilfont-1f9ed76662986bf6e3802e9fb3080d61e5797532.zip |
Adding upstream version 1.6.0.upstream/1.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | lib/silfont/scripts/psfxml2compdef.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/silfont/scripts/psfxml2compdef.py b/lib/silfont/scripts/psfxml2compdef.py new file mode 100755 index 0000000..f5b5b35 --- /dev/null +++ b/lib/silfont/scripts/psfxml2compdef.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +__doc__ = 'convert composite definition file from XML format' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2015 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://opensource.org/licenses/MIT)' +__author__ = 'David Rowe' + +from silfont.core import execute +from silfont.comp import CompGlyph +from xml.etree import ElementTree as ET + +# specify two parameters: input file (XML format), output file (single line format). +argspec = [ + ('input',{'help': 'Input file of CD in XML format'}, {'type': 'infile'}), + ('output',{'help': 'Output file of CD in single line format'}, {'type': 'outfile'}), + ('-l', '--log', {'help': 'Optional log file'}, {'type': 'outfile', 'def': '_xml2compdef.log', 'optlog': True})] + +def doit(args) : + cgobj = CompGlyph() + glyphcount = 0 + for g in ET.parse(args.input).getroot().findall('glyph'): + glyphcount += 1 + cgobj.CDelement = g + cgobj.CDline = None + cgobj.parsefromCDelement() + if cgobj.CDline != None: + args.output.write(cgobj.CDline+'\n') + else: + pass # error in glyph number glyphcount message + return + +def cmd() : execute(None,doit,argspec) +if __name__ == "__main__": cmd() |