aboutsummaryrefslogtreecommitdiffstats
path: root/uci.py
diff options
context:
space:
mode:
authorGravatar Robin Obůrka <r.oburka@gmail.com> 2016-04-06 23:30:54 +0200
committerGravatar Robin Obůrka <r.oburka@gmail.com> 2016-04-07 00:54:37 +0200
commitb19eb9ad22a8bce912819123f7df7c3bff7f306c (patch)
tree639c82ec20d5e7a26ae68d72baa9cb7c6b9df2c6 /uci.py
parentRename parameter config to section (diff)
downloadansible-uci-b19eb9ad22a8bce912819123f7df7c3bff7f306c.tar.xz
Let get_uci_key() build section key too
It will be used later for section management.
Diffstat (limited to 'uci.py')
-rw-r--r--uci.py10
1 files 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