summaryrefslogtreecommitdiffstats
path: root/lib/silfont/scripts/psfxml2compdef.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/silfont/scripts/psfxml2compdef.py')
-rwxr-xr-xlib/silfont/scripts/psfxml2compdef.py33
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()