def _rc_path(): """ Return platform-specific default file path for $HOME/.fabricrc. """ rc_file = '.fabricrc' if not win32: return os.path.expanduser("~/" + rc_file) else: from win32com.shell.shell import SHGetSpecialFolderPath from win32com.shell.shellcon import CSIDL_PROFILE return "%s/%s" % (SHGetSpecialFolderPath(0, CSIDL_PROFILE), rc_file)
def _rc_path(): """ Return platform-specific default file path for $HOME/.fabricrc. """ rc_file = '.fabricrc' rc_path = '~/' + rc_file expanded_rc_path = os.path.expanduser(rc_path) if expanded_rc_path == rc_path and win32: from win32com.shell.shell import SHGetSpecialFolderPath from win32com.shell.shellcon import CSIDL_PROFILE expanded_rc_path = "%s/%s" % (SHGetSpecialFolderPath( 0, CSIDL_PROFILE), rc_file) return expanded_rc_path
def _load_default_settings(): "Load user-default fabric settings from ~/.fabric" if not win32: cfg = os.path.expanduser("~/.fabric") else: from win32com.shell.shell import SHGetSpecialFolderPath from win32com.shell.shellcon import CSIDL_PROFILE cfg = SHGetSpecialFolderPath(0,CSIDL_PROFILE) + "/.fabric" if os.path.exists(cfg): comments = lambda s: s and not s.startswith("#") settings = filter(comments, open(cfg, 'r')) settings = [(k.strip(), v.strip()) for k, _, v in [partition(s, '=') for s in settings]] ENV.update(settings)
if user_dir: folder_path = os.path.join(home, user_dir) if ((folderid != "DESKTOP" and (not user_dir or (not os.path.isdir(folder_path) and not XDG.UserDirs.enabled))) or not waccess(folder_path, os.W_OK)): folder_path = home return folder_path home = expanduseru("~") if sys.platform == "win32": # Always specify create=1 for SHGetSpecialFolderPath so we don't get an # exception if the folder does not yet exist try: library_home = appdata = SHGetSpecialFolderPath(0, CSIDL_APPDATA, 1) except Exception as exception: raise Exception( "FATAL - Could not get/create user application data folder: %s" % exception) try: localappdata = SHGetSpecialFolderPath(0, CSIDL_LOCAL_APPDATA, 1) except Exception as exception: localappdata = os.path.join(appdata, "Local") cache = localappdata # Argyll CMS uses ALLUSERSPROFILE for local system wide app related data # Note: On Windows Vista and later, ALLUSERSPROFILE and COMMON_APPDATA # are actually the same ('C:\ProgramData'), but under Windows XP the former # points to 'C:\Documents and Settings\All Users' while COMMON_APPDATA # points to 'C:\Documents and Settings\All Users\Application Data' allusersprofile = getenvu("ALLUSERSPROFILE")