diff options
author | Robin Obůrka <r.oburka@gmail.com> | 2016-04-07 00:28:46 +0200 |
---|---|---|
committer | Robin Obůrka <r.oburka@gmail.com> | 2016-04-07 00:54:53 +0200 |
commit | 871ac3701d0b6189b828114d8a3f47a914a1b10b (patch) | |
tree | f3973ac0f86b69f380fa99aa89d318a3ac26ed3b | |
parent | Parameter name is not required (diff) | |
download | ansible-uci-871ac3701d0b6189b828114d8a3f47a914a1b10b.tar.xz |
Add more logic into get_uci_key()
It recognise key and section.
-rw-r--r-- | uci.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -26,12 +26,18 @@ def val_or_none(params, key): def get_uci_key(package, section, type, index, name): if section: - key = "{}.{}.{}".format(package, section, name) + if name: + key = "{}.{}.{}".format(package, section, name) + else: + key = None skey = "{}.{}".format(package, section) return key, skey elif type and index: - key = "{}.@{}[{}].{}".format(package, type, index, name) + if name: + key = "{}.@{}[{}].{}".format(package, type, index, name) + else: + key = None skey = "{}.@{}[{}]".format(package, type, index) return key, skey |