util/misc.py
changeset 1920 584ad449ee58
parent 1862 c4ba411f8c89
child 1923 65edbc03fdbf
equal deleted inserted replaced
1919:ccea0fa6ea91 1920:584ad449ee58
    44         for name in files:
    44         for name in files:
    45             if os.access(root, os.W_OK) is not True or os.access(os.path.join(root, name), os.W_OK) is not True:
    45             if os.access(root, os.W_OK) is not True or os.access(os.path.join(root, name), os.W_OK) is not True:
    46                 return False
    46                 return False
    47     return True
    47     return True
    48 
    48 
       
    49 def GetClassImporter(classpath):
       
    50     """
       
    51     is used to resolve library class names in features.py
       
    52     returns a callable that return the class pointed by classpath string
       
    53     if a class is given instead of string, then returns a callable returning it.
       
    54     """
    49 
    55 
    50 def GetClassImporter(classpath):
       
    51     if isinstance(classpath, str):
    56     if isinstance(classpath, str):
    52         def fac():
    57         def factory():
       
    58             # on-demand import, only when using class
    53             mod = __import__(classpath.rsplit('.', 1)[0])
    59             mod = __import__(classpath.rsplit('.', 1)[0])
    54             return reduce(getattr, classpath.split('.')[1:], mod)
    60             return reduce(getattr, classpath.split('.')[1:], mod)
    55         return fac
    61         return factory
    56     else:
    62     else:
    57         return classpath
    63         return classpath
    58 
    64 
    59 
    65 
    60 def InstallLocalRessources(CWD):
    66 def InstallLocalRessources(CWD):