util/misc.py
author laurent
Sun, 03 Jun 2012 23:53:22 +0200
changeset 755 9f5dbd90e1e0
parent 734 5c42cafaee15
child 781 cdc6393705ce
permissions -rw-r--r--
Removing code related to Topology panel
"""
Misc definitions
"""

import os,sys

# helper func to get path to images
def opjimg(imgname):
    return os.path.join(sys.path[0], "images", imgname+".png")
    
# 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