Example #1
0
 def getter(self, propname):
     def get(self):
         try:
             return getattr(self, propname)
         except AttributeError:
             raise E_NotImplemented()
     return instancemethod(get, self.inst, type(self.inst))
 def getter(self, propname):
     def get(self):
         try:
             return getattr(self, propname)
         except AttributeError:
             raise E_NotImplemented()
     return instancemethod(get, self.inst, type(self.inst))
Example #3
0
 def __getattr__(self, name):
     "Create event handler methods on demand"
     if name.startswith("__") and name.endswith("__"):
         raise AttributeError(name)
     print("# event found:", name)
     def handler(self, this, *args, **kw):
         # XXX handler is called with 'this'.  Should we really print "None" instead?
         args = (None,) + args
         print("Event %s(%s)" % (name, ", ".join([repr(a) for a in args])))
     return comtypes.instancemethod(handler, self, EventDumper)
Example #4
0
 def setter(self, propname):
     #
     def set(self, value):
         try:
             # XXX this may not be correct is the object implements
             # _get_PropName but not _set_PropName
             setattr(self, propname, value)
         except AttributeError:
             raise E_NotImplemented()
     return instancemethod(set, self.inst, type(self.inst))
Example #5
0
 def __getattr__(self, name):
     "Create event handler methods on demand"
     if name.startswith("__") and name.endswith("__"):
         raise AttributeError(name)
     print("# event found:", name)
     def handler(self, this, *args, **kw):
         # XXX handler is called with 'this'.  Should we really print "None" instead?
         args = (None,) + args
         print("Event %s(%s)" % (name, ", ".join([repr(a) for a in args])))
     return comtypes.instancemethod(handler, self, EventDumper)
Example #6
0
 def setter(self, propname):
     #
     def set(self, value):
         try:
             # XXX this may not be correct is the object implements
             # _get_PropName but not _set_PropName
             setattr(self, propname, value)
         except AttributeError:
             raise E_NotImplemented()
     return instancemethod(set, self.inst, type(self.inst))
Example #7
0
 def find_method(self, fq_name, mthname):
     impl = self._find_method(fq_name, mthname)
     # Caller of this method catches AttributeError,
     # so we need to be careful in the following code
     # not to raise one...
     try:
         # impl is a bound method, dissect it...
         im_self, im_func = impl.im_self, impl.im_func
         # decorate it with an error printer...
         method = report_errors(im_func)
         # and make a new bound method from it again.
         return comtypes.instancemethod(method, im_self, type(im_self))
     except AttributeError, details:
         raise RuntimeError(details)
Example #8
0
 def find_method(self, fq_name, mthname):
     impl = self._find_method(fq_name, mthname)
     # Caller of this method catches AttributeError,
     # so we need to be careful in the following code
     # not to raise one...
     try:
         # impl is a bound method, dissect it...
         im_self, im_func = impl.__self__, impl.__func__
         # decorate it with an error printer...
         method = report_errors(im_func)
         # and make a new bound method from it again.
         return comtypes.instancemethod(method,
                                        im_self,
                                        type(im_self))
     except AttributeError as details:
         raise RuntimeError(details)