[glib/new-gsettings] Do not generate nested schemas for the XML format
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/new-gsettings] Do not generate nested schemas for the XML format
- Date: Thu, 15 Apr 2010 00:36:25 +0000 (UTC)
commit dd4dfd53c568c4abfd8a6dbb131c9ba6c665564f
Author: Vincent Untz <vuntz gnome org>
Date: Wed Apr 14 20:32:47 2010 -0400
Do not generate nested schemas for the XML format
gio/gsettings-schema-convert | 48 ++++++++++++++++++++++++++++--------------
1 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/gio/gsettings-schema-convert b/gio/gsettings-schema-convert
old mode 100644
new mode 100755
index 698cdfb..2318dad
--- a/gio/gsettings-schema-convert
+++ b/gio/gsettings-schema-convert
@@ -72,8 +72,7 @@ class GSettingsSchemaRoot:
def get_xml_node(self):
schemalist_node = ET.Element('schemalist')
for schema in self.schemas:
- schema_node = schema.get_xml_node()
- if schema_node is not None:
+ for schema_node in schema.get_xml_nodes():
schemalist_node.append(schema_node)
return schemalist_node
@@ -118,25 +117,36 @@ class GSettingsSchemaDir:
return result
- def get_xml_node(self):
- node = self._get_xml_node_for_content()
- if node is not None:
- node.set('id', self.name)
- return node
+ def get_xml_nodes(self, parent_id, parent_path):
+ id = '%s.%s' % (parent_id, self.name)
+ path = '%s%s/' % (parent_path, self.name)
+
+ (node, children) = self._get_xml_nodes_for_content(id, path)
+ if node is None:
+ return []
+
+ node.set('id', id)
+ node.set('path', path)
+ nodes = [ node ]
+ nodes.extend(children)
- def _get_xml_node_for_content(self):
+ return nodes
+
+ def _get_xml_nodes_for_content(self, id, path):
if not self.keys and not self.dirs:
- return None
+ return (None, None)
+
+ children = []
schema_node = ET.Element('schema')
for key in self.keys:
key_node = key.get_xml_node()
schema_node.append(key_node)
for dir in self.dirs:
- dir_node = dir.get_xml_node()
- schema_node.append(dir_node)
+ dir_nodes = dir.get_xml_nodes(id, path)
+ children.extend(dir_nodes)
- return schema_node
+ return (schema_node, children)
######################################
@@ -171,16 +181,22 @@ class GSettingsSchema(GSettingsSchemaDir):
return result
- def get_xml_node(self):
+ def get_xml_nodes(self):
if not self.dirs and not self.keys:
- return None
+ return []
+
+ (node, children) = self._get_xml_nodes_for_content(self.id, self.path or '')
+ if node is None:
+ return []
- node = self._get_xml_node_for_content()
node.set('id', self.id)
if self.path:
node.set('path', self.path)
- return node
+ nodes = [ node ]
+ nodes.extend(children)
+
+ return nodes
######################################
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]