Python introspection to enlightenment?

Brendan Scott disposableemail at apps.opensourcelaw.biz
Tue Jun 13 12:31:50 UTC 2017


I'm trying to query the attributes of the krita module, krita.Krita and krita.Krita.instance() objects to get them to tell me a bit about themselves (actually, it looks like I'm inspecting krita.krita.Krita?!). However, they all tell me that they are pyqtWrapperType classes and have a standard set of methods:

standard_methods = ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

and standard doc strings:

standard__doc__ = """str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.
""".strip()


Many of them seem callable, but callable(attribute) returns False for all of them. The dumpObjectInfo method of krita.Krita.instance returns None. Does it write something somewhere?

I assume that pyqtWrapperType will be created by wrapping some c++ code somewhere? How do I discover (other than by looking at the source code/existing scripts and making an educated guess?) eg:
* that the Extension class has a method called setup() that I'm supposed to override?
* whether Extension has any other special methods?
* what parameters each of the methods of these objects takes?

The docs say:
   All classes are based on QObject, so QMetaObject introspection can
   be used to discover properties, slots and signals and automatically
expose all functionality to the client.

It's not clear how to make use of these through Python.

Thanks


Brendan






More information about the kimageshop mailing list