def __init__(self, intf, dict=None, inst=None): # Convert the interfaces actualIntf = _convertInterfaces([intf]) # Verify that one of the options has been selected if dict is not None and inst is not None: raise RuntimeError("Specify only one of dict and inst") if dict is not None: # Define the lookup function based for a dict def lookup(d, name): return d[name] # create a proxy self.__javaproxy__ = _jpype.PyJPProxy(dict, lookup, actualIntf) return if inst is not None: # Define the lookup function based for a object instance def lookup(d, name): return getattr(d, name) # create a proxy self.__javaproxy__ = _jpype.PyJPProxy(inst, lookup, actualIntf) return raise TypeError("a dict or inst must be specified")
def testProxyNoInterfaces(self): with self.assertRaises(TypeError): proxy = _jpype.PyJPProxy(None, None, tuple())
def testProxyInitBad3(self): with self.assertRaises(TypeError): _jpype.PyJPProxy(None, None, tuple([None, None]))
def testProxyInitBad2(self): with self.assertRaises(TypeError): _jpype.PyJPProxy(None, None, None)
def init2(self, *args, **kwargs): self.__javaproxy__ = _jpype.PyJPProxy(self, lookup, actualIntf)