From: Serge Rehbinder Date: Thu, 28 Jan 2016 13:29:05 +0000 (+0100) Subject: architecture finalization and commentaries for main executable file X-Git-Tag: sprint-01~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=68485e02b5bfee256d2e34556e89dd921149ab11;p=tools%2Fsat.git architecture finalization and commentaries for main executable file --- diff --git a/data/site.pyconf b/data/site.pyconf new file mode 100644 index 0000000..9a58fcd --- /dev/null +++ b/data/site.pyconf @@ -0,0 +1,11 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +SITE : +{ + config : + { + configPath : ["/home/salome/SPN_PRIVATE/sat5dev_Applications"] + } +} + diff --git a/src/config.py b/src/config.py index 954075c..d62cec1 100644 --- a/src/config.py +++ b/src/config.py @@ -18,13 +18,14 @@ import os import sys -import common import platform import datetime import glob import re import shutil +import common + # Define all possible option for config command : sat config parser = common.options.Options() parser.add_option('v', 'value', 'string', 'value', "print the value of CONFIG_VARIABLE.") @@ -134,17 +135,18 @@ class ConfigManager: def get_command_line_overrides(self, options, sections): '''get all the overwrites that are in the command line - :param options : TO DO - :param sections str: The command that is called. - :return: The list of all the overwrites of the command line. + :param options : the options from salomeTools class initialization (like -l5 or --overwrite) + :param sections str: The config section to overwrite. + :return: The list of all the overwrites to apply. :rtype: list ''' # when there are no options or not the overwrite option, return an empty list if options is None or options.overwrite is None: return [] - + over = [] for section in sections: + # only overwrite the sections that correspond to the option over.extend(filter(lambda l: l.startswith(section + "."), options.overwrite)) return over @@ -382,7 +384,6 @@ def description(): def run(args, runner): (options, args) = parser.parse_args(args) - print('Je suis dans la commande config ! Bien joué ! COUCOU') if options.value: print_value(runner.cfg, options.value, True, level=0, show_full_path=False) \ No newline at end of file diff --git a/src/salomeTools.py b/src/salomeTools.py index e5d8b78..ccfa5eb 100755 --- a/src/salomeTools.py +++ b/src/salomeTools.py @@ -19,12 +19,14 @@ '''This file is the main entry file to salomeTools ''' +# python imports import os import sys import imp import types import gettext +# salomeTools imports import common.options import config @@ -32,141 +34,190 @@ import config srcdir = os.path.dirname(os.path.realpath(__file__)) # load resources for internationalization -#gettext.install('salomeTools', os.path.join(srcdir, 'common', 'i18n')) - es = gettext.translation('salomeTools', os.path.join(srcdir, 'common', 'i18n')) es.install() -def find_command_list(): +def find_command_list(dirPath): + ''' Parse files in dirPath that end with .py : it gives commands list + :param dirPath str: The directory path where to search the commands + :return: cmd_list : the list containing the commands name + :rtype: list + ''' cmd_list = [] - for item in os.listdir(srcdir): + for item in os.listdir(dirPath): if item.endswith('.py') and item!='salomeTools.py': cmd_list.append(item[:-len('.py')]) return cmd_list # The list of valid salomeTools commands #lCommand = ['config', 'compile', 'prepare'] -lCommand = find_command_list() +lCommand = find_command_list(srcdir) # Define all possible option for salomeTools command : sat