Changeset b963b20 in sasview for src/sas/__init__.py


Ignore:
Timestamp:
Sep 24, 2017 11:29:13 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
b277220, fca1f50
Parents:
d3b0c77
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/__init__.py

    r79492222 rb963b20  
     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 TracChangeset for help on using the changeset viewer.