mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-04 20:59:21 +02:00
Add --schema-id option to gsettings-schema-convert
This is useful for easier migration of gconf schemas.
This commit is contained in:
@@ -580,9 +580,11 @@ def read_simple_schema(simple_schema_file):
|
|||||||
######################################
|
######################################
|
||||||
|
|
||||||
|
|
||||||
def read_gconf_schema(gconf_schema_file):
|
def read_gconf_schema(gconf_schema_file, default_schema_id):
|
||||||
gsettings_schema_root = GSettingsSchemaRoot()
|
gsettings_schema_root = GSettingsSchemaRoot()
|
||||||
|
|
||||||
|
default_schema_id_count = 0
|
||||||
|
|
||||||
gconfschemafile_node = ET.parse(gconf_schema_file).getroot()
|
gconfschemafile_node = ET.parse(gconf_schema_file).getroot()
|
||||||
for schemalist_node in gconfschemafile_node.findall('schemalist'):
|
for schemalist_node in gconfschemafile_node.findall('schemalist'):
|
||||||
for schema_node in schemalist_node.findall('schema'):
|
for schema_node in schemalist_node.findall('schema'):
|
||||||
@@ -621,7 +623,13 @@ def read_gconf_schema(gconf_schema_file):
|
|||||||
break
|
break
|
||||||
if not gsettings_schema:
|
if not gsettings_schema:
|
||||||
gsettings_schema = GSettingsSchema()
|
gsettings_schema = GSettingsSchema()
|
||||||
gsettings_schema.id = 'FIXME'
|
if default_schema_id:
|
||||||
|
gsettings_schema.id = default_schema_id
|
||||||
|
if default_schema_id_count > 0:
|
||||||
|
gsettings_schema.id += '.FIXME-%s' % default_schema_id_count
|
||||||
|
default_schema_id_count += 1
|
||||||
|
else:
|
||||||
|
gsettings_schema.id = 'FIXME'
|
||||||
if schemas_only:
|
if schemas_only:
|
||||||
gsettings_schema.path = '/' + hierarchy[0] + '/'
|
gsettings_schema.path = '/' + hierarchy[0] + '/'
|
||||||
else:
|
else:
|
||||||
@@ -660,6 +668,8 @@ def main(args):
|
|||||||
help="output file")
|
help="output file")
|
||||||
parser.add_option("-g", "--gconf", action="store_true", dest="gconf",
|
parser.add_option("-g", "--gconf", action="store_true", dest="gconf",
|
||||||
default=False, help="convert a gconf schema file")
|
default=False, help="convert a gconf schema file")
|
||||||
|
parser.add_option("-i", "--schema-id", dest="schema_id",
|
||||||
|
help="schema ID to use by default when converting gconf schema file")
|
||||||
parser.add_option("-s", "--simple", action="store_true", dest="simple",
|
parser.add_option("-s", "--simple", action="store_true", dest="simple",
|
||||||
default=False, help="use the simple schema format as output (only for gconf schema conversion)")
|
default=False, help="use the simple schema format as output (only for gconf schema conversion)")
|
||||||
parser.add_option("-x", "--xml", action="store_true", dest="xml",
|
parser.add_option("-x", "--xml", action="store_true", dest="xml",
|
||||||
@@ -685,6 +695,10 @@ def main(args):
|
|||||||
else:
|
else:
|
||||||
options.xml = True
|
options.xml = True
|
||||||
|
|
||||||
|
if not options.gconf and options.schema_id:
|
||||||
|
print >> sys.stderr, 'Default chema ID can only be specified when converting a gconf schema.'
|
||||||
|
return 1
|
||||||
|
|
||||||
argfile = os.path.expanduser(args[0])
|
argfile = os.path.expanduser(args[0])
|
||||||
if not os.path.exists(argfile):
|
if not os.path.exists(argfile):
|
||||||
print >> sys.stderr, '%s does not exist.' % argfile
|
print >> sys.stderr, '%s does not exist.' % argfile
|
||||||
@@ -699,7 +713,7 @@ def main(args):
|
|||||||
|
|
||||||
if options.gconf:
|
if options.gconf:
|
||||||
try:
|
try:
|
||||||
schema_root = read_gconf_schema(argfile)
|
schema_root = read_gconf_schema(argfile, options.schema_id)
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
raise GSettingsSchemaConvertException('%s does not look like a gconf schema file: %s' % (argfile, e))
|
raise GSettingsSchemaConvertException('%s does not look like a gconf schema file: %s' % (argfile, e))
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user