def init_wx(appname='Digsby'): if config.platform != 'win': # on windows we don't use wxStandardPaths at all to avoid having to have # the app created. return init_wx_old() paths = \ [('GetConfigDir', CSIDL.COMMON_APPDATA, True), ('GetDataDir', GetAppDir), ('GetDocumentsDir', CSIDL.PERSONAL, False), ('GetExecutablePath', lambda: sys.executable), ('GetLocalDataDir', GetAppDir), ('GetUserConfigDir', CSIDL.APPDATA, False), ('GetUserDataDir', CSIDL.APPDATA, True), ('GetUserLocalDataDir', CSIDL.LOCAL_APPDATA, True), ('GetUserLocalConfigDir', CSIDL.LOCAL_APPDATA, False), ('GetTempDir', GetTempDir) ] from util.primitives.mapping import Storage s = Storage() for p in paths: name = p[0] if hasattr(p[1], '__call__'): s[name] = p[1] else: csidl, append_app_name = p[1], p[2] if append_app_name: method = lambda id=csidl: GetFolderLocation(id) + '\\' + appname else: method = lambda id=csidl: GetFolderLocation(id) setattr(s, name, method) paths_dict = dict(config = s.GetConfigDir(), data = s.GetDataDir(), documents = s.GetDocumentsDir(), executablepath = s.GetExecutablePath(), localdata = s.GetLocalDataDir(), userconfig = s.GetUserConfigDir(), userdata = s.GetUserDataDir(), userlocaldata = s.GetUserLocalDataDir(), userlocalconfig = s.GetUserLocalConfigDir(), temp = s.GetTempDir()) _winpaths = [ ('GetUserStartupDir', CSIDL.STARTUP), ('GetStartupDir', CSIDL.COMMON_STARTUP), ('GetUserDesktopDir', CSIDL.DESKTOP), ('GetDesktopDir', CSIDL.COMMON_DESKTOPDIRECTORY) ] for method_name, csidl in _winpaths: setattr(s, method_name, lambda id=csidl: GetFolderLocation(id)) # extended wxStandardPaths folders paths_dict.update(userstartup = s.GetUserStartupDir(), startup = s.GetStartupDir(), userdesktop = s.GetUserDesktopDir(), desktop = s.GetDesktopDir()) _set_paths(**paths_dict) return paths_dict