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