From 612f1bca84eb646c559f1b9058f7bc4fec5add6c Mon Sep 17 00:00:00 2001 From: Serge Rehbinder Date: Wed, 16 Mar 2016 11:17:37 +0100 Subject: [PATCH] rename 'dataDir' to 'datadir' and 'workDir' to 'workdir' --- commands/config.py | 28 ++++++++++++++-------------- commands/log.py | 2 -- data/site.pyconf | 2 +- salomeTools.py | 10 +++++----- test/prepare/test_prepare.py | 3 --- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/commands/config.py b/commands/config.py index 4c98687..f12e724 100644 --- a/commands/config.py +++ b/commands/config.py @@ -77,16 +77,16 @@ class ConfigOpener: class ConfigManager: '''Class that manages the read of all the configuration files of salomeTools ''' - def __init__(self, dataDir=None): + def __init__(self, datadir=None): pass - def _create_vars(self, application=None, command=None, dataDir=None): + def _create_vars(self, application=None, command=None, datadir=None): '''Create a dictionary that stores all information about machine, user, date, repositories, etc... :param application str: The application for which salomeTools is called. :param command str: The command that is called. - :param dataDir str: The repository that contain external data + :param datadir str: The repository that contain external data for salomeTools. :return: The dictionary that stores all information. :rtype: dict @@ -98,10 +98,10 @@ class ConfigManager: var['srcDir'] = os.path.join(var['salometoolsway'], 'src') var['sep']= os.path.sep - # dataDir has a default location - var['dataDir'] = os.path.join(var['salometoolsway'], 'data') - if dataDir is not None: - var['dataDir'] = dataDir + # datadir has a default location + var['datadir'] = os.path.join(var['salometoolsway'], 'data') + if datadir is not None: + var['datadir'] = datadir var['personalDir'] = os.path.join(os.path.expanduser('~'), '.salomeTools') @@ -167,14 +167,14 @@ class ConfigManager: return over def get_config(self, application=None, options=None, command=None, - dataDir=None): + datadir=None): '''get the config from all the configuration files. :param application str: The application for which salomeTools is called. :param options class Options: The general salomeToos options (--overwrite or -l5, for example) :param command str: The command that is called. - :param dataDir str: The repository that contain + :param datadir str: The repository that contain external data for salomeTools. :return: The final config. :rtype: class 'src.pyconf.Config' @@ -189,7 +189,7 @@ class ConfigManager: # ===================================================================== # create VARS section var = self._create_vars(application=application, command=command, - dataDir=dataDir) + datadir=datadir) # add VARS to config cfg.VARS = src.pyconf.Mapping(cfg) for variable in var: @@ -221,9 +221,9 @@ class ConfigManager: # ===================================================================== # Load SITE config file # search only in the data directory - src.pyconf.streamOpener = ConfigOpener([cfg.VARS.dataDir]) + src.pyconf.streamOpener = ConfigOpener([cfg.VARS.datadir]) try: - site_cfg = src.pyconf.Config(open(os.path.join(cfg.VARS.dataDir, + site_cfg = src.pyconf.Config(open(os.path.join(cfg.VARS.datadir, 'site.pyconf'))) except src.pyconf.ConfigError as e: raise src.SatException(_("Error in configuration file: " @@ -279,7 +279,7 @@ class ConfigManager: # Load product config files in PRODUCTS section # The directory containing the softwares definition - products_dir = os.path.join(cfg.VARS.dataDir, 'products') + products_dir = os.path.join(cfg.VARS.datadir, 'products') # Loop on all files that are in softsDir directory # and read their config @@ -349,7 +349,7 @@ class ConfigManager: user_cfg.addMapping('USER', src.pyconf.Mapping(user_cfg), "") # - user_cfg.USER.addMapping('workDir', os.path.expanduser('~'), + user_cfg.USER.addMapping('workdir', os.path.expanduser('~'), "This is where salomeTools will work. " "You may (and probably do) change it.\n") user_cfg.USER.addMapping('cvs_user', config.VARS.user, diff --git a/commands/log.py b/commands/log.py index 3abe0f0..c7e4602 100644 --- a/commands/log.py +++ b/commands/log.py @@ -138,8 +138,6 @@ def run(args, runner, logger): (options, args) = parser.parse_args(args) # get the log directory. - # If there is an application, it is in cfg.APPLICATION.out_dir, - # else in user directory logDir = runner.cfg.SITE.log.log_dir # If the clean options is invoked, diff --git a/data/site.pyconf b/data/site.pyconf index dc17baf..918d617 100644 --- a/data/site.pyconf +++ b/data/site.pyconf @@ -18,7 +18,7 @@ SITE : } log : { - log_dir : $USER.workDir + "/LOGS" + log_dir : $USER.workdir + "/LOGS" } } diff --git a/salomeTools.py b/salomeTools.py index ba6d39f..3f43128 100755 --- a/salomeTools.py +++ b/salomeTools.py @@ -83,11 +83,11 @@ parser.add_option('s', 'silent', 'boolean', 'silent', class Sat(object): '''The main class that stores all the commands of salomeTools ''' - def __init__(self, opt='', dataDir=None): + def __init__(self, opt='', datadir=None): '''Initialization :param opt str: The sat options - :param: dataDir str : the directory that contain all the external + :param: datadir str : the directory that contain all the external data (like software pyconf and software scripts) ''' # Read the salomeTools options (the list of possible options is @@ -103,7 +103,7 @@ class Sat(object): self.cfg = None # the config that will be read using pyconf module self.arguments = opt self.options = options # the options passed to salomeTools - self.dataDir = dataDir # default value will be /data + self.datadir = datadir # default value will be /data # set the commands by calling the dedicated function self._setCommands(cmdsdir) @@ -161,7 +161,7 @@ class Sat(object): # read the configuration from all the pyconf files cfgManager = config.ConfigManager() - self.cfg = cfgManager.get_config(dataDir=self.dataDir, + self.cfg = cfgManager.get_config(datadir=self.datadir, application=appliToLoad, options=self.options, command=__nameCmd__) @@ -273,7 +273,7 @@ class Sat(object): command = opt[0] # read the configuration from all the pyconf files cfgManager = config.ConfigManager() - self.cfg = cfgManager.get_config(dataDir=self.dataDir) + self.cfg = cfgManager.get_config(datadir=self.datadir) # Check if this command exists if not hasattr(self, command): diff --git a/test/prepare/test_prepare.py b/test/prepare/test_prepare.py index 00d8e97..64c2c86 100644 --- a/test/prepare/test_prepare.py +++ b/test/prepare/test_prepare.py @@ -28,10 +28,7 @@ sys.path.append(os.path.join(testdir, '..', '_testTools')) sys.path.append(os.path.join(testdir, '..', '..','commands')) from salomeTools import Sat -from tools import check_proc_existence_and_kill -from tools import outRedirection import HTMLTestRunner -import src.xmlManager sleep_time = 3 -- 2.30.2