diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-08-28 17:11:57 +0100 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-08-28 17:11:57 +0100 |
commit | d5341fb7968108615da58d127655c8238a3e19b0 (patch) | |
tree | 0c5f9463a34d378c3da3e40ed81baa66b0785997 /scripts/poky-trim-schemas | |
parent | 1937c08705b2e9fb209b2d703fec63b8c4421083 (diff) | |
download | openembedded-core-d5341fb7968108615da58d127655c8238a3e19b0.tar.gz openembedded-core-d5341fb7968108615da58d127655c8238a3e19b0.tar.bz2 openembedded-core-d5341fb7968108615da58d127655c8238a3e19b0.zip |
Add poky-trim-schemas post install script to remove unneeded schema locale translations from images (credit to Ross Burton for the initial script)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'scripts/poky-trim-schemas')
-rwxr-xr-x | scripts/poky-trim-schemas | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/poky-trim-schemas b/scripts/poky-trim-schemas new file mode 100755 index 0000000000..29fb3a1b67 --- /dev/null +++ b/scripts/poky-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") + |