source: sasview/src/sas/__init__.py @ d1520fc

Last change on this file since d1520fc was b963b20, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

pull config out of sas.sasgui so it can be used without reference to wx

  • Property mode set to 100644
File size: 1.6 KB
Line 
1__all__ = ['get_app_dir', 'get_user_dir',
2           'get_local_config', 'get_custom_config']
3
4_APP_DIR = None
5def get_app_dir():
6    """
7    The directory where the sasview application is found.
8
9    Returns the path to sasview if running in place or installed with setup.
10    If the application is frozen, returns the parent directory of the
11    application resources such as test files and images.
12    """
13    global _APP_DIR
14    if not _APP_DIR:
15        from ._config import find_app_dir
16        _APP_DIR = find_app_dir()
17    return _APP_DIR
18
19_USER_DIR = None
20def get_user_dir():
21    """
22    The directory where the per-user configuration is stored.
23
24    Returns ~/.sasview, creating it if it does not already exist.
25    """
26    global _USER_DIR
27    if not _USER_DIR:
28        from ._config import make_user_dir
29        _USER_DIR = make_user_dir()
30    return _USER_DIR
31
32def make_custom_config_path():
33    from ._config import make_custom_config_path as _make_path
34    return _make_path(get_user_dir())
35
36_CUSTOM_CONFIG = None
37def get_custom_config():
38    """
39    Setup the custom config dir and cat file
40    """
41    global _CUSTOM_CONFIG
42    if not _CUSTOM_CONFIG:
43        from ._config import setup_custom_config
44        _CUSTOM_CONFIG = setup_custom_config(get_app_dir(), get_user_dir())
45    return _CUSTOM_CONFIG
46
47
48_LOCAL_CONFIG = None
49def get_local_config():
50    """
51    Loads the local config file.
52    """
53    global _LOCAL_CONFIG
54    if not _LOCAL_CONFIG:
55        from ._config import load_local_config
56        _LOCAL_CONFIG = load_local_config(get_app_dir())
57    return _LOCAL_CONFIG
Note: See TracBrowser for help on using the repository browser.