コード例 #1
0
ファイル: uno.py プロジェクト: hanya/pyuno3
    def __getattr__(self, elt):
        value = None

        RuntimeException = pyuno.getClass("com.sun.star.uno.RuntimeException")
        try:
            value = pyuno.getClass(self.__path__ + "." + elt)
        except RuntimeException:
            try:
                value = Enum(self.__path__, elt)
            except RuntimeException:
                try:
                    value = pyuno.getConstantByName(self.__path__ + "." + elt)
                except RuntimeException:
                    if elt.startswith("typeOf"):
                        try:
                            value = pyuno.getTypeByName(self.__path__ + "." + elt[6:])
                        except RuntimeException:
                            raise AttributeError("type {}.{} is unknown".format(self.__path__, elt))
                    elif elt == "__all__":
                        try:
                            module_names = pyuno.getModuleElementNames(self.__path__)
                            self.__all__ = module_names
                            return module_names
                        except RuntimeException:
                            raise AttributeError("__all__")
                    else:
                        raise AttributeError("type {}.{} is unknown".format(self.__path__, elt))
        setattr(self, elt, value)
        return value
コード例 #2
0
ファイル: uno.py プロジェクト: hanya/pyuno3
def getModuleElementNames(name):
    """ Get list of sub element names by name.
    
        Valid elements are module, interface, struct without template, 
        exception, enum and constants. And also list of names in enum and 
        constants can be taken.
    """
    return pyuno.getModuleElementNames(name)
コード例 #3
0
ファイル: uno.py プロジェクト: hanya/pyuno3ext
 def __dir__(self):
     try:
         if hasattr(self, "__all__"):
             module_names = self.__all__
         else:
             module_names = pyuno.getModuleElementNames(self.__path__)
             self.__all__ = list(module_names)
     except:
         module_names = []
     return list(self.__class__.__dict__.keys()) + list(self.__dict__.keys()) + list(module_names)
コード例 #4
0
ファイル: uno.py プロジェクト: hanya/pyuno3ext
 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