ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change
on this file since 412e069e 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
|
Rev | Line | |
---|
[b963b20] | 1 | __all__ = ['get_app_dir', 'get_user_dir', |
---|
| 2 | 'get_local_config', 'get_custom_config'] |
---|
| 3 | |
---|
| 4 | _APP_DIR = None |
---|
| 5 | def 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 |
---|
| 20 | def 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 | |
---|
| 32 | def 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 |
---|
| 37 | def 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 |
---|
| 49 | def 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.