dbus/python _dbus.py, 1.13, 1.14 proxies.py, 1.11, 1.12 service.py, 1.12, 1.13

Robert McQueen robot101 at freedesktop.org
Thu Nov 3 08:13:55 PST 2005


Update of /cvs/dbus/dbus/python
In directory gabe:/tmp/cvs-serv29673/python

Modified Files:
	_dbus.py proxies.py service.py 
Log Message:
2005-11-03  Robert McQueen  <robot101 at debian.org>

        * python/_dbus.py, python/proxies.py, python/service.py: Add __repr__
        functions to dbus.Bus, dbus.service.BusName and dbus.service.Object,
        tweak others to be consistent.

        * test/python/test-client.py: Tweak output of testInheritance.


Index: _dbus.py
===================================================================
RCS file: /cvs/dbus/dbus/python/_dbus.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- _dbus.py	18 Oct 2005 04:38:04 -0000	1.13
+++ _dbus.py	3 Nov 2005 16:13:52 -0000	1.14
@@ -68,6 +68,7 @@
     START_REPLY_ALREADY_RUNNING = dbus_bindings.DBUS_START_REPLY_ALREADY_RUNNING 
 
     def __init__(self, bus_type=TYPE_SESSION, use_default_mainloop=True, private=False):
+        self._bus_type = bus_type
         self._connection = dbus_bindings.bus_get(bus_type, private)
 
         self._connection.add_filter(self._signal_func)
@@ -196,6 +197,19 @@
     def start_service_by_name(self, named_service):
         return dbus_bindings.bus_start_service_by_name(self._connection, named_service)
 
+    def __repr__(self):
+        if self._bus_type == self.TYPE_SESSION:
+            name = 'SESSION'
+        elif self._bus_type == self.TYPE_SYSTEM:
+            name = 'SYSTEM'
+        elif self._bus_type == self.TYPE_STARTER:
+            name = 'STARTER'
+        else:
+            assert False, 'Unable to represent unknown bus type.'
+
+        return '<dbus.Bus on %s at %#x>' % (name, id(self))
+    __str__ = __repr__
+
 class SystemBus(Bus):
     """The system-wide message bus
     """
@@ -246,6 +260,6 @@
             return ret
 
     def __repr__(self):
-        return '<Interface %r implementing %r at %x>'%(
+        return '<Interface %r implementing %r at %#x>'%(
         self._obj, self._dbus_interface, id(self))
     __str__ = __repr__

Index: proxies.py
===================================================================
RCS file: /cvs/dbus/dbus/python/proxies.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- proxies.py	29 Oct 2005 19:13:17 -0000	1.11
+++ proxies.py	3 Nov 2005 16:13:52 -0000	1.12
@@ -222,7 +222,7 @@
             return ret
 
     def __repr__(self):
-        return '<ProxyObject wrapping %s %s %s at %x>'%( 
+        return '<ProxyObject wrapping %s %s %s at %#x>'%(
             self._bus, self._named_service, self._object_path , id(self))
     __str__ = __repr__
 

Index: service.py
===================================================================
RCS file: /cvs/dbus/dbus/python/service.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- service.py	29 Oct 2005 22:41:07 -0000	1.12
+++ service.py	3 Nov 2005 16:13:52 -0000	1.13
@@ -28,6 +28,10 @@
         """Get the name of this service"""
         return self._named_service
 
+    def __repr__(self):
+        return '<dbus.service.BusName %s on %r at %#x>' % (self._named_service, self._bus, id(self))
+    __str__ = __repr__
+
 def _dispatch_dbus_method_call(self, argument_list, message):
     """Calls method_to_call using argument_list, but handles
     exceptions, etc, and generates a reply to the DBus Message message
@@ -280,3 +284,6 @@
 
         return reflection_data
 
+    def __repr__(self):
+        return '<dbus.service.Object %s on %r at %#x>' % (self._object_path, self._name, id(self))
+    __str__ = __repr__



More information about the dbus-commit mailing list