In PythonEvaluator, I now evaluate concept and/or concept body
This commit is contained in:
@@ -340,6 +340,7 @@ class Sheerka(Concept):
|
||||
self.cache_manager.clear()
|
||||
self.printer_handler.reset()
|
||||
self.sdp.reset()
|
||||
self.locals = {}
|
||||
|
||||
def evaluate_user_input(self, text: str, user_name="kodjo"):
|
||||
"""
|
||||
|
||||
@@ -214,6 +214,34 @@ def product(a, b):
|
||||
return res
|
||||
|
||||
|
||||
def dict_product(a, b):
|
||||
"""
|
||||
Cartesian product like where a and b are list of dictionaries
|
||||
>>> a = [{"a": "a", "b":"b", "c":"c"}]
|
||||
>>> b = [{"d":"d1"}, {"d":"d2"}]
|
||||
>>>
|
||||
>>> assert dict_product(a, b) == [{"a": "a", "b":"b", "c":"c", "d":"d1"}, {"a": "a", "b":"b", "c":"c", "d":"d2"}]
|
||||
|
||||
:param a:
|
||||
:param b:
|
||||
:return:
|
||||
"""
|
||||
if a is None or len(a) == 0:
|
||||
return b
|
||||
if b is None or len(b) == 0:
|
||||
return a
|
||||
|
||||
res = []
|
||||
for item_a in a:
|
||||
for item_b in b:
|
||||
items = item_a.copy()
|
||||
items.update(item_b)
|
||||
res.append(items)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def strip_quotes(text):
|
||||
if not isinstance(text, str):
|
||||
return text
|
||||
|
||||
Reference in New Issue
Block a user