diff -r e0630d262ac3 -r 31dade089db5 util/misc.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util/misc.py Wed May 09 00:00:50 2012 +0200 @@ -0,0 +1,29 @@ +""" +Misc definitions +""" + +import os,sys + +# helper func to get path to images +def opjimg(imgname): + return os.path.join(sys.path[0], "images",imgname) + +# 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 lambda:classpath +