source: sasview/sansguiframe/src/sans/guiframe/customdir.py @ f9505c30

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since f9505c30 was f9505c30, checked in by Jae Cho <jhjcho@…>, 12 years ago

more fix for cleaner config folder

  • Property mode set to 100644
File size: 1.1 KB
Line 
1# Setup and find Custom config dir
2import sys
3import os.path
4import shutil
5
6CONF_DIR = 'config' 
7APPLICATION_NAME = 'sansview'
8
9def _find_customconf_dir():
10    """
11    Find path of the config directory.
12    The plugin directory is located in the user's home directory.
13    """
14    dir = os.path.join(os.path.expanduser("~"), ("." + APPLICATION_NAME), CONF_DIR)
15   
16    return dir
17
18def _setup_conf_dir(path):
19    """
20    Setup the custom config dir
21    """
22    dir = _find_customconf_dir()
23    # If the plugin directory doesn't exist, create it
24    if not os.path.isdir(dir):
25        os.makedirs(dir)
26    file = os.path.join(dir, "custom_config.py")
27    # Place example user models as needed
28    if not os.path.isfile(file):
29        shutil.copyfile(os.path.join(path, "custom_config.py"), file)
30       
31    return dir
32 
33       
34class SetupCustom(object):
35    """
36    implement custom config dir
37    """
38    def find_dir(self):
39        return _find_customconf_dir()
40   
41    def setup_dir(self, path):
42        return _setup_conf_dir(path)
43   
44
45   
46   
47 
Note: See TracBrowser for help on using the repository browser.