From e7ff689fdacd79977e9a81dbdc82370d09d40d19 Mon Sep 17 00:00:00 2001 From: Michel Blanc Date: Wed, 20 Feb 2013 19:12:01 +0100 Subject: [PATCH] Fixes unused var and avoid reassigning keys Changed code so key doesn't get reassigned in loop Made use of filtr variable --- setup | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup b/setup index 3b82de4d239..4dddd4384a1 100644 --- a/setup +++ b/setup @@ -1105,9 +1105,9 @@ def run_setup(module): filtr = module.params['filter'] for (k, v) in facts.items(): - k = "ansible_%s" % k.replace('-', '_') - if fnmatch.fnmatch(k, module.params['filter']): - setup_options[k] = v + k2 = "ansible_%s" % k.replace('-', '_') + if fnmatch.fnmatch(k2, filtr): + setup_options[k2] = v # if facter is installed, and we can use --json because # ruby-json is ALSO installed, include facter data in the JSON @@ -1121,9 +1121,9 @@ def run_setup(module): facter = False if facter: for (k,v) in facter_ds.items(): - k = "facter_%s" % k - if fnmatch.fnmatch(k, module.params['filter']): - setup_options[k] = v + k2 = "facter_%s" % k + if fnmatch.fnmatch(k2, filtr): + setup_options[k2] = v # ditto for ohai, but just top level string keys # because it contains a lot of nested stuff we can't use for @@ -1140,7 +1140,7 @@ def run_setup(module): for (k,v) in ohai_ds.items(): if type(v) == str or type(v) == unicode: k2 = "ohai_%s" % k.replace('-', '_') - if fnmatch.fnmatch(k2, module.params['filter']): + if fnmatch.fnmatch(k2, filtr): setup_options[k2] = v setup_result = {}