Skip to content
Snippets Groups Projects
Commit e1bbce4c authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Use a slightly cleaner approach to fix ConditionDict for True/False

parent ff7b045f
No related branches found
No related tags found
No related merge requests found
...@@ -196,19 +196,14 @@ class _ConditionDict(dict): ...@@ -196,19 +196,14 @@ class _ConditionDict(dict):
self.tags = tags self.tags = tags
def __getitem__(self, i): def __getitem__(self, i):
# If we do not add these special cases the dictionary will return False # We first evaluate the given string with eval. This is necessary
# when we execute the following code: # to ensure that 'True' and 'False' are correctly evaluated. Only
# # if this failed with a NameError, we check for the existence of
# eval ("True", _ConditionDict(v.tags) # of the given string in the tag list.
# try:
# But in this case we want to return True! A normal dictionary would not attempt return eval(i)
# to replace "True" if "True" is not a key. The _ConditionDict obviously has no except NameError:
# such concerns ;). return i in self.tags
if i == "True":
return True
if i == "False":
return False
return i in self.tags
def _filter_cache_items(condition): def _filter_cache_items(condition):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment