From: Serge Rehbinder Date: Wed, 8 Mar 2017 14:17:41 +0000 (+0100) Subject: sat package: an the option --without_property to ba able to filter some products... X-Git-Tag: 5.0.0a1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=57ed5ad9fb66024757bc90e9d6c2634068b6355f;p=tools%2Fsat.git sat package: an the option --without_property to ba able to filter some products by their properties --- diff --git a/commands/package.py b/commands/package.py index d00051d..d933c61 100644 --- a/commands/package.py +++ b/commands/package.py @@ -104,6 +104,10 @@ parser.add_option('', 'add_files', 'list2', 'add_files', _('Optional: The list of additional files to add to the archive.'), []) parser.add_option('', 'without_commercial', 'boolean', 'without_commercial', _('Optional: do not add commercial licence.'), False) +parser.add_option('', 'without_property', 'string', 'without_property', + _('Optional: Filter the products by their properties.\n\tSyntax: ' + '--without_property :')) + def add_files(tar, name_archive, d_content, logger, f_exclude=None): '''Create an archive containing all directories and files that are given in @@ -930,7 +934,22 @@ def add_readme(config, package_type, where): f.write(src.template.substitute(readme_template_path, d)) return readme_path - + +def update_config(config, prop, value): + '''Remove from config.APPLICATION.products the products that have the property given as input. + + :param config Config: The global config. + :param prop str: The property to filter + :param value str: The value of the property to filter + ''' + src.check_config_has_application(config) + l_product_to_remove = [] + for product_name in config.APPLICATION.products.keys(): + prod_cfg = src.product.get_product_config(config, product_name) + if src.get_property_in_product_cfg(prod_cfg, prop) == value: + l_product_to_remove.append(product_name) + for product_name in l_product_to_remove: + config.APPLICATION.products.__delitem__(product_name) def description(): '''method that is called when salomeTools is called with --help option. @@ -1017,6 +1036,11 @@ def run(args, runner, logger): logger.write("\n", 1) return 1 + # Remove the products that are filtered by the --without_property option + if options.without_property: + [prop, value] = options.without_property.split(":") + update_config(runner.cfg, prop, value) + # Print src.printcolors.print_value(logger, "Package type", package_type, 2) diff --git a/complete_sat.sh b/complete_sat.sh index bd05037..29ae207 100755 --- a/complete_sat.sh +++ b/complete_sat.sh @@ -234,7 +234,7 @@ _salomeTools_complete() return 0 ;; package) - opts="--name --binaries --sources --project --salometools --with_vcs --without_commercial" + opts="--name --binaries --sources --project --salometools --with_vcs --without_commercial --without_property" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 ;;