util/misc.py
author Laurent Bessard
Fri, 05 Apr 2013 00:05:40 +0200
changeset 1015 50bb7cc12a84
parent 815 e4f24593a758
child 1388 67c9a9482d24
permissions -rw-r--r--
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
"""
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