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

@@ -23,6 +23,7 @@ import sys
import xml.parsers.expat
from . import dbustypes
from .utils import print_error
class DBusXMLParser:
STATE_TOP = 'top'
@@ -203,7 +204,7 @@ class DBusXMLParser:
elif direction == 'out':
self._cur_object.out_args.append(arg)
else:
raise RuntimeError('Invalid direction "%s"'%(direction))
print_error('Invalid direction "{}"'.format(direction))
self._cur_object = arg
elif name == DBusXMLParser.STATE_ANNOTATION:
self.state = DBusXMLParser.STATE_ANNOTATION
@@ -278,7 +279,7 @@ class DBusXMLParser:
self.state = DBusXMLParser.STATE_IGNORED
else:
raise RuntimeError('Unhandled state "%s" while entering element with name "%s"'%(self.state, name))
print_error('Unhandled state "{}" while entering element with name "{}"'.format(self.state, name))
self.state_stack.append(old_state)
self._cur_object_stack.append(old_cur_object)