]>
git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/blob - scripts/oe-trim-schemas
1 #! /usr/bin/env python3
3 # SPDX-License-Identifier: GPL-2.0-only
8 import xml
.etree
.cElementTree
as etree
10 import xml
.etree
.ElementTree
as etree
12 def child (elem
, name
):
13 for e
in elem
.getchildren():
18 def children (elem
, name
=None):
19 l
= elem
.getchildren()
21 l
= [e
for e
in l
if e
.tag
== name
]
24 if len(sys
.argv
) < 2 or sys
.argv
[1] in ('-h', '--help'):
25 print('oe-trim-schemas: error: the following arguments are required: schema\n'
26 'Usage: oe-trim-schemas schema\n\n'
27 'OpenEmbedded trim schemas - remove unneeded schema locale translations\n'
28 ' from gconf schema files\n\n'
30 ' schema gconf schema file to trim\n')
33 xml
= etree
.parse(sys
.argv
[1])
35 for schema
in child(xml
.getroot(), "schemalist").getchildren():
36 e
= child(schema
, "short")
40 e
= child(schema
, "long")
44 for locale
in children(schema
, "locale"):
45 # One locale must exist so leave C locale...
46 a
= locale
.attrib
.get("name")
49 e
= child(locale
, "default")
53 e
= child(locale
, "short")
56 e
= child(locale
, "long")
60 xml
.write(sys
.stdout
, "UTF-8")