diff options
author | Robin Obůrka <r.oburka@gmail.com> | 2016-04-06 23:30:54 +0200 |
---|---|---|
committer | Robin Obůrka <r.oburka@gmail.com> | 2016-04-07 00:54:37 +0200 |
commit | b19eb9ad22a8bce912819123f7df7c3bff7f306c (patch) | |
tree | 639c82ec20d5e7a26ae68d72baa9cb7c6b9df2c6 | |
parent | Rename parameter config to section (diff) | |
download | ansible-uci-b19eb9ad22a8bce912819123f7df7c3bff7f306c.tar.xz |
Let get_uci_key() build section key too
It will be used later for section management.
-rw-r--r-- | uci.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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 |