util/misc.py
author laurent
Mon, 02 Jul 2012 12:00:10 +0200
changeset 785 a9bdd7c2f063
parent 781 cdc6393705ce
child 806 abf1afc1f04d
permissions -rw-r--r--
Fix bug when opening deeper ConfTreeNode editors
"""
Misc definitions
"""

import os,sys
    
# helper func to check path write permission
def CheckPathPerm(path):
    if path is None or not os.path.isdir(path):
        return False
    for root, dirs, files in os.walk(path):
         for name in files:
             if os.access(root, os.W_OK) is not True or os.access(os.path.join(root, name), os.W_OK) is not True:
                 return False
    return True

def GetClassImporter(classpath):
    if type(classpath)==str:
        def fac():
            mod=__import__(classpath.rsplit('.',1)[0])
            return reduce(getattr, classpath.split('.')[1:], mod)
        return fac
    else:
        return classpath