diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 49226ac36..d702994d2 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -160,6 +160,10 @@ class Config: lines.append(keyval) 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']) def get(self, section, option, fallback=_UNSET, raw=False): """Get the value from a section/option. diff --git a/qutebrowser/config/sections.py b/qutebrowser/config/sections.py index 4c3f2a1be..9f349bd5b 100644 --- a/qutebrowser/config/sections.py +++ b/qutebrowser/config/sections.py @@ -85,6 +85,10 @@ class KeyValue: """Get boolean state.""" return bool(self.values) + def __contains__(self, key): + """Return whether the section contains a given key.""" + return key in self.values + def items(self): """Get dict item tuples.""" return self.values.items() @@ -164,6 +168,11 @@ class ValueList: self.update_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): """Get dict items.""" self.update_valdict()