From 97ed348e17d2e4e391d05ec0f4db5970d1c3eade Mon Sep 17 00:00:00 2001 From: Julien Pepy Date: Mon, 18 Aug 2014 09:28:32 +0200 Subject: [PATCH] Clean options building in Composer module --- .../extras/packaging/language/composer.py | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/language/composer.py b/lib/ansible/modules/extras/packaging/language/composer.py index 23d9dc5031e..a24b826a4de 100644 --- a/lib/ansible/modules/extras/packaging/language/composer.py +++ b/lib/ansible/modules/extras/packaging/language/composer.py @@ -128,30 +128,34 @@ def main(): supports_check_mode=True ) - module.params["working_dir"] = os.path.abspath(module.params["working_dir"]) + options = [] - options = set([]) # Default options - options.add("--no-ansi") - options.add("--no-progress") - options.add("--no-interaction") + options.append('--no-ansi') + options.append('--no-progress') + options.append('--no-interaction') - if module.check_mode: - options.add("--dry-run") - del module.params['CHECKMODE'] + options.extend(['--working-dir', os.path.abspath(module.params['working_dir'])]) - # Get composer command with fallback to default + # Get composer command with fallback to default command = module.params['command'] - del module.params['command']; # Prepare options - for i in module.params: - opt = "--%s" % i.replace("_","-") - p = module.params[i] - if isinstance(p, (bool)) and p: - options.add(opt) - elif isinstance(p, (str)): - options.add("%s=%s" % (opt, p)) + if module.params['prefer_source']: + options.append('--prefer-source') + if module.params['prefer_dist']: + options.append('--prefer-dist') + if module.params['no_dev']: + options.append('--no-dev') + if module.params['no_scripts']: + options.append('--no-scripts') + if module.params['no_plugins']: + options.append('--no-plugins') + if module.params['optimize_autoloader']: + options.append('--optimize-autoloader') + + if module.check_mode: + options.append('--dry-run') rc, out, err = composer_install(module, command, options)