equal
deleted
inserted
replaced
|
1 """ |
|
2 Misc definitions |
|
3 """ |
|
4 |
|
5 import os,sys |
|
6 |
|
7 # helper func to get path to images |
|
8 def opjimg(imgname): |
|
9 return os.path.join(sys.path[0], "images",imgname) |
|
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: |
|
28 return lambda:classpath |
|
29 |