def query_variable(self, query_):
'''
Return an iterable which yields shared variables found by query_, from current group.
query_:
Can take several forms, as shown below.
All: return all variables under current group.
string: treat as regex, return variables whose name fully match the regex.
'''
if query_ is All:
return self._current_group_di.values()
elif isinstance(query_, str):
regex = re.compile(query_)
return {k:v for k,v in self._current_group_di.items() if regex.fullmatch(k)}
else:
raise TypeError('Unknown query type "%s"' % type(query_))
# TODO add / delete group does not consider non-group object by now
评论列表
文章目录