From b19eb9ad22a8bce912819123f7df7c3bff7f306c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Ob=C5=AFrka?= Date: Wed, 6 Apr 2016 23:30:54 +0200 Subject: Let get_uci_key() build section key too It will be used later for section management. --- uci.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/uci.py b/uci.py index d567e49..8574c45 100644 --- a/uci.py +++ b/uci.py @@ -26,10 +26,14 @@ def val_or_none(params, key): def get_uci_key(package, section, type, index, name): if section: - return "{}.{}.{}".format(package, section, name) + key = "{}.{}.{}".format(package, section, name) + skey = "{}.{}".format(package, section) + return key, skey elif type and index: - return "{}.@{}[{}].{}".format(package, type, index, name) + key = "{}.@{}[{}].{}".format(package, type, index, name) + skey = "{}.@{}[{}]".format(package, type, index) + return key, skey else: module.fail_json(msg="Definition of the key is ambiguous.") @@ -119,7 +123,7 @@ def main(): module.fail_json(msg="Item of type 'list' is unimplemented for now") ## Get key and value - I need to make decisions - key = get_uci_key(package, section, type, index, name) + key, skey = get_uci_key(package, section, type, index, name) val = uci_get(module, bin_path, key) ## Handle deletes -- cgit v1.2.3