config_common.py: make get_matching() a generator

Signed-off-by: Valerio Setti <[email protected]>
This commit is contained in:
Valerio Setti
2024-10-09 10:21:10 +02:00
parent 9b987bd204
commit 40a28bd2af
+3 -5
View File
@@ -98,14 +98,12 @@ class Config:
def get_matching(self, regexs, only_enabled): def get_matching(self, regexs, only_enabled):
"""Get all symbols matching one of the regexs.""" """Get all symbols matching one of the regexs."""
if not regexs: if not regexs:
return None return
match_list = []
regex = re.compile('|'.join(regexs)) regex = re.compile('|'.join(regexs))
for setting in self.settings.values(): for setting in self.settings.values():
if regex.search(setting.name): if regex.search(setting.name):
if (not only_enabled) or (only_enabled and setting.active): if setting.active or not only_enabled:
match_list.append(setting.name) yield setting.name
return match_list
def __setitem__(self, name, value): def __setitem__(self, name, value):
"""If name is known, set its value. """If name is known, set its value.