From c14f30dc23f854ab7c90fd68ff806d5f90a53273 Mon Sep 17 00:00:00 2001 From: Al Straumann Date: Wed, 2 Oct 2019 17:02:17 -0500 Subject: [PATCH] arg unpacking for nested value retrieval --- Reconnoitre/lib/file_helper.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Reconnoitre/lib/file_helper.py b/Reconnoitre/lib/file_helper.py index 0119de8..93068d9 100644 --- a/Reconnoitre/lib/file_helper.py +++ b/Reconnoitre/lib/file_helper.py @@ -144,7 +144,7 @@ def write_recommendations(results, ip_address, outputdir): f.close() -def get_config_options(key, option): +def get_config_options(key, *args): __location__ = os.path.realpath( os.path.join( os.getcwd(), @@ -161,13 +161,9 @@ def get_config_options(key, option): "%(outputdir)s")) res = j.get(key, None) + for arg in args: + res = res.get(arg, None) + if res is None: + raise KeyError - if res is None: - raise KeyError - - res2 = res.get(option, None) - - if res2 is None: - raise KeyError - - return res2 + return res