gdbus-codegen: Use Color's print_* methods

`glib-genmarshal` and `glib-mkenums` use a `Color` class which
implements a number of print_* methods to print colored messages
to the standard error output.

In order to be consistent with those programs' output,
`gdbus-codegen` has also started using that same class and methods.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
This commit is contained in:
Iñigo Martínez
2018-01-12 08:55:36 +01:00
parent e2054240c2
commit dcc1fe09d0
5 changed files with 59 additions and 16 deletions

View File

@@ -24,6 +24,7 @@ import sys
from . import config
from . import utils
from . import dbustypes
from .utils import print_error
LICENSE_STR = '''/*
* Generated by gdbus-codegen {!s}. DO NOT EDIT.
@@ -1156,7 +1157,7 @@ class CodeGenerator:
elif p.writable:
hint = 'Since the D-Bus property for this #GObject property is writable but not readable, it is meaningful to write to it on both the client- and service-side. It is only meaningful, however, to read from it on the service-side.'
else:
raise RuntimeError('Cannot handle property %s that neither readable nor writable'%(p.name))
print_error('Cannot handle property "{}" that neither readable nor writable'.format(p.name))
self.c.write(self.docbook_gen.expand(
' /**\n'
' * %s:%s:\n'
@@ -1202,7 +1203,7 @@ class CodeGenerator:
elif p.arg.signature == 'aay':
s = 'g_param_spec_boxed ("%s", "%s", "%s", G_TYPE_STRV'%(p.name_hyphen, p.name, p.name)
else:
raise RuntimeError('Unsupported gtype %s for GParamSpec'%(p.arg.gtype))
print_error('Unsupported gtype "{}" for GParamSpec'.format(p.arg.gtype))
self.c.write(' %s, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));'%s);
self.c.write('\n')
@@ -1221,7 +1222,7 @@ class CodeGenerator:
elif p.writable:
hint = 'Since this D-Bus property is not readable, it is only meaningful to use this function on the service-side.'
else:
raise RuntimeError('Cannot handle property %s that neither readable nor writable'%(p.name))
print_error('Cannot handle property "{}" that neither readable nor writable'.format(p.name))
self.c.write(self.docbook_gen.expand(
'/**\n'
' * %s_get_%s: (skip)\n'
@@ -1277,7 +1278,7 @@ class CodeGenerator:
elif p.writable:
hint = 'Since this D-Bus property is writable, it is meaningful to use this function on both the client- and service-side.'
else:
raise RuntimeError('Cannot handle property %s that neither readable nor writable'%(p.name))
print_error('Cannot handle property "{}" that neither readable nor writable'.format(p.name))
self.c.write(self.docbook_gen.expand(
'/**\n'
' * %s_set_%s: (skip)\n'
@@ -3397,7 +3398,7 @@ class CodeGenerator:
elif isinstance(obj, dbustypes.Property):
thing = 'The D-Bus property'
else:
raise RuntimeError('Cannot handle object ', obj)
print_error('Cannot handle object "{}"'.format(obj))
f.write(self.docbook_gen.expand(
'%*s *\n'
'%*s * Deprecated: %s has been deprecated.\n'