From 43c80102ecfebf1b5afcb0e7cf2bf25c4289d7f9 Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Tue, 24 Jan 2017 13:26:59 -0500 Subject: Clean up pylint for delete_empty_keys. --- roles/openshift_facts/library/openshift_facts.py | 29 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 599793ae9..c99452062 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1697,12 +1697,29 @@ def set_builddefaults_facts(facts): def delete_empty_keys(keylist): - count=0 - c=len(keylist) - for i in range(0,c): - if len(keylist[i-count]['value'])==0: - del keylist[i-count] - count+=1 + """ Delete dictionary elements from keylist where "value" is empty. + + Args: + keylist(list): A list of builddefault configuration envs. + + Returns: + none + + Example: + keylist = [{'name': 'HTTP_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, + {'name': 'HTTPS_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, + {'name': 'NO_PROXY', 'value': ''}] + + After calling delete_empty_keys the provided list is modified to become: + + [{'name': 'HTTP_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, + {'name': 'HTTPS_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}] + """ + count = 0 + for i in range(0, len(keylist)): + if len(keylist[i - count]['value']) == 0: + del keylist[i - count] + count += 1 def set_buildoverrides_facts(facts): -- cgit v1.2.3