def test_hasModule(self): import pyuno self.assertTrue(pyuno.hasModule("com")) self.assertTrue(pyuno.hasModule("com.sun")) self.assertTrue(pyuno.hasModule("com.sun.star.awt.FontWeight")) self.assertTrue(pyuno.hasModule("com.sun.star.awt.FontSlant")) self.assertFalse(pyuno.hasModule("foo"))
def __getattr__(self, name): try: value = pyuno.importValue(self.__path__, name) except: if pyuno.hasModule(self.__path__ + "." + name): value = _UNOModuleLoader().load_module(self.__path__ + "." + name) elif name == "__all__" or name == "*": try: module_names = pyuno.getModuleElementNames(self.__path__) self.__all__ = module_names return module_names except: raise AttributeError(name) elif name.startswith("typeOf"): try: value = pyuno.getTypeByName(self.__path__ + "." + name[6:]) except: raise AttributeError( "type {}.{} is unknown".format(self.__path__, name)) else: raise AttributeError(name) setattr(self, name, value) return value
def find_module(self, fullname, path=None): if pyuno.hasModule(fullname): return self.__class__.LOADER return None
def hasModule(name): """ Check UNO module is there by its name. Valid modules are module, constants and enum. """ return pyuno.hasModule(name)