util/misc.py
changeset 1736 7e61baa047f0
parent 1735 c02818d7e29f
child 1740 b789b695b5c6
equal deleted inserted replaced
1735:c02818d7e29f 1736:7e61baa047f0
    27 """
    27 """
    28 
    28 
    29 import os
    29 import os
    30 import sys
    30 import sys
    31 
    31 
    32 # helper func to check path write permission
    32 
    33 def CheckPathPerm(path):
    33 def CheckPathPerm(path):
       
    34     """ Helper func to check path write permission """
    34     if path is None or not os.path.isdir(path):
    35     if path is None or not os.path.isdir(path):
    35         return False
    36         return False
    36     for root, dirs, files in os.walk(path):
    37     for root, dirs, files in os.walk(path):
    37         files = [f for f in files if not f[0] == '.']
    38         files = [f for f in files if not f[0] == '.']
    38         dirs[:] = [d for d in dirs if not d[0] == '.']
    39         dirs[:] = [d for d in dirs if not d[0] == '.']
    39         for name in files:
    40         for name in files:
    40             if os.access(root, os.W_OK) is not True or os.access(os.path.join(root, name), os.W_OK) is not True:
    41             if os.access(root, os.W_OK) is not True or os.access(os.path.join(root, name), os.W_OK) is not True:
    41                 return False
    42                 return False
    42     return True
    43     return True
    43 
    44 
       
    45 
    44 def GetClassImporter(classpath):
    46 def GetClassImporter(classpath):
    45     if type(classpath)==str:
    47     if type(classpath)==str:
    46         def fac():
    48         def fac():
    47             mod=__import__(classpath.rsplit('.',1)[0])
    49             mod=__import__(classpath.rsplit('.',1)[0])
    48             return reduce(getattr, classpath.split('.')[1:], mod)
    50             return reduce(getattr, classpath.split('.')[1:], mod)
    49         return fac
    51         return fac
    50     else:
    52     else:
    51         return classpath
    53         return classpath
       
    54 
    52 
    55 
    53 def InstallLocalRessources(CWD):
    56 def InstallLocalRessources(CWD):
    54     from BitmapLibrary import AddBitmapFolder
    57     from BitmapLibrary import AddBitmapFolder
    55     from TranslationCatalogs import AddCatalog
    58     from TranslationCatalogs import AddCatalog
    56     import wx
    59     import wx