diff options
author | John Klug <john.klug@multitech.com> | 2022-05-25 17:12:18 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2022-05-25 17:12:18 -0500 |
commit | 7971cb0aa3e517a53f0ce6d3ee9bc3179041ccb8 (patch) | |
tree | 56e91417e6f937b3956cadcf4973756cebb4a8b0 /scripts/oe-trim-schemas | |
download | mlinux-7971cb0aa3e517a53f0ce6d3ee9bc3179041ccb8.tar.gz mlinux-7971cb0aa3e517a53f0ce6d3ee9bc3179041ccb8.tar.bz2 mlinux-7971cb0aa3e517a53f0ce6d3ee9bc3179041ccb8.zip |
mLinux 6
Diffstat (limited to 'scripts/oe-trim-schemas')
-rwxr-xr-x | scripts/oe-trim-schemas | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/oe-trim-schemas b/scripts/oe-trim-schemas new file mode 100755 index 0000000..29fb3a1 --- /dev/null +++ b/scripts/oe-trim-schemas @@ -0,0 +1,49 @@ +#! /usr/bin/env python + +import sys +try: + import xml.etree.cElementTree as etree +except: + import xml.etree.ElementTree as etree + +def child (elem, name): + for e in elem.getchildren(): + if e.tag == name: + return e + return None + +def children (elem, name=None): + l = elem.getchildren() + if name: + l = [e for e in l if e.tag == name] + return l + +xml = etree.parse(sys.argv[1]) + +for schema in child(xml.getroot(), "schemalist").getchildren(): + e = child(schema, "short") + if e is not None: + schema.remove(e) + + e = child(schema, "long") + if e is not None: + schema.remove(e) + + for locale in children(schema, "locale"): + # One locale must exist so leave C locale... + a = locale.attrib.get("name") + if a == 'C': + continue + e = child(locale, "default") + if e is None: + schema.remove(locale) + else: + e = child(locale, "short") + if e is not None: + locale.remove(e) + e = child(locale, "long") + if e is not None: + locale.remove(e) + +xml.write(sys.stdout, "UTF-8") + |