Commit 4992dca9 authored by Laszlo Pandy's avatar Laszlo Pandy Committed by Tomeu Vizoso
Browse files

Add a __repr__() method to DynamicModule.

This patch adds a __repr__() method to DynamicModule so that modules provide a
meaningful string with the typelib path included:

>>> from gi.repository import Gtk
>>> Gtk
<gi.module.DynamicModule 'Gtk' from
'/home/laszlo/Dev/gnome-jh-install/lib64/girepository-1.0/Gtk-3.0.typelib'>

https://bugzilla.gnome.org/show_bug.cgi?id=639232
parent 2ffaec59
......@@ -260,3 +260,12 @@ class DynamicModule(object):
result = [info.get_name() for info in namespace_infos]
result.extend(self.__dict__.keys())
return result
def __repr__(self):
repository.require(self._namespace, self._version)
path = repository.get_typelib_path(self._namespace)
return "<%s.%s %r from %r>" % (self.__class__.__module__,
self.__class__.__name__,
self._namespace,
path)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment