summaryrefslogtreecommitdiff
path: root/poky/scripts/oe-trim-schemas
diff options
context:
space:
mode:
authorDave Cobbley <david.j.cobbley@linux.intel.com>2018-08-14 20:05:37 +0300
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-08-23 04:26:31 +0300
commiteb8dc40360f0cfef56fb6947cc817a547d6d9bc6 (patch)
treede291a73dc37168da6370e2cf16c347d1eba9df8 /poky/scripts/oe-trim-schemas
parent9c3cf826d853102535ead04cebc2d6023eff3032 (diff)
downloadopenbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.tar.xz
[Subtree] Removing import-layers directory
As part of the move to subtrees, need to bring all the import layers content to the top level. Change-Id: I4a163d10898cbc6e11c27f776f60e1a470049d8f Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com> Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'poky/scripts/oe-trim-schemas')
-rwxr-xr-xpoky/scripts/oe-trim-schemas58
1 files changed, 58 insertions, 0 deletions
diff --git a/poky/scripts/oe-trim-schemas b/poky/scripts/oe-trim-schemas
new file mode 100755
index 000000000..7c199ef1d
--- /dev/null
+++ b/poky/scripts/oe-trim-schemas
@@ -0,0 +1,58 @@
+#! /usr/bin/env python3
+
+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
+
+if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'):
+ print('oe-trim-schemas: error: the following arguments are required: schema\n'
+ 'Usage: oe-trim-schemas schema\n\n'
+ 'OpenEmbedded trim schemas - remove unneeded schema locale translations\n'
+ ' from gconf schema files\n\n'
+ 'arguments:\n'
+ ' schema gconf schema file to trim\n')
+ sys.exit(2)
+
+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")
+