From 871ac3701d0b6189b828114d8a3f47a914a1b10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Ob=C5=AFrka?= Date: Thu, 7 Apr 2016 00:28:46 +0200 Subject: Add more logic into get_uci_key() It recognise key and section. --- uci.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/uci.py b/uci.py index afec6cf..adc8a74 100644 --- a/uci.py +++ b/uci.py @@ -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 -- cgit v1.2.3