725
|
1 |
"""
|
|
2 |
Misc definitions
|
|
3 |
"""
|
|
4 |
|
|
5 |
import os,sys
|
|
6 |
|
|
7 |
# helper func to get path to images
|
|
8 |
def opjimg(imgname):
|
734
|
9 |
return os.path.join(sys.path[0], "images", imgname+".png")
|
725
|
10 |
|
|
11 |
# helper func to check path write permission
|
|
12 |
def CheckPathPerm(path):
|
|
13 |
if path is None or not os.path.isdir(path):
|
|
14 |
return False
|
|
15 |
for root, dirs, files in os.walk(path):
|
|
16 |
for name in files:
|
|
17 |
if os.access(root, os.W_OK) is not True or os.access(os.path.join(root, name), os.W_OK) is not True:
|
|
18 |
return False
|
|
19 |
return True
|
|
20 |
|
|
21 |
def GetClassImporter(classpath):
|
|
22 |
if type(classpath)==str:
|
|
23 |
def fac():
|
|
24 |
mod=__import__(classpath.rsplit('.',1)[0])
|
|
25 |
return reduce(getattr, classpath.split('.')[1:], mod)
|
|
26 |
return fac
|
|
27 |
else:
|
731
|
28 |
return classpath
|
725
|
29 |
|