Add untested has_option
This commit is contained in:
parent
30c18579f2
commit
1258a466dd
@ -160,6 +160,10 @@ class Config:
|
|||||||
lines.append(keyval)
|
lines.append(keyval)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
def has_option(section, option):
|
||||||
|
"""Returns True if option is in section."""
|
||||||
|
return option in self.config[section]
|
||||||
|
|
||||||
@cmdutils.register(instance='config', completion=['setting'])
|
@cmdutils.register(instance='config', completion=['setting'])
|
||||||
def get(self, section, option, fallback=_UNSET, raw=False):
|
def get(self, section, option, fallback=_UNSET, raw=False):
|
||||||
"""Get the value from a section/option.
|
"""Get the value from a section/option.
|
||||||
|
@ -85,6 +85,10 @@ class KeyValue:
|
|||||||
"""Get boolean state."""
|
"""Get boolean state."""
|
||||||
return bool(self.values)
|
return bool(self.values)
|
||||||
|
|
||||||
|
def __contains__(self, key):
|
||||||
|
"""Return whether the section contains a given key."""
|
||||||
|
return key in self.values
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
"""Get dict item tuples."""
|
"""Get dict item tuples."""
|
||||||
return self.values.items()
|
return self.values.items()
|
||||||
@ -164,6 +168,11 @@ class ValueList:
|
|||||||
self.update_valdict()
|
self.update_valdict()
|
||||||
return bool(self.valdict)
|
return bool(self.valdict)
|
||||||
|
|
||||||
|
def __contains__(self, key):
|
||||||
|
"""Return whether the section contains a given key."""
|
||||||
|
self.update_valdict()
|
||||||
|
return key in self.valdict
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
"""Get dict items."""
|
"""Get dict items."""
|
||||||
self.update_valdict()
|
self.update_valdict()
|
||||||
|
Loading…
Reference in New Issue
Block a user