Refactored ExecutionContext serialization (added sheerkapickle) and added History management
This commit is contained in:
@@ -228,6 +228,7 @@ def escape_char(text, to_escape):
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def pp(items):
|
||||
if not hasattr(items, "__iter__"):
|
||||
return str(items)
|
||||
@@ -236,3 +237,66 @@ def pp(items):
|
||||
return str(items)
|
||||
|
||||
return " \n" + " \n".join(str(item) for item in items)
|
||||
|
||||
|
||||
def decode_concept(concept_repr):
|
||||
"""
|
||||
if concept_repr is like :c:key:id:
|
||||
return the key and the id
|
||||
:param concept_repr:
|
||||
:return:
|
||||
"""
|
||||
if not (concept_repr and isinstance(concept_repr, str) and concept_repr.startswith(":c:")):
|
||||
return None, None
|
||||
|
||||
i = 3
|
||||
length = len(concept_repr)
|
||||
key = ""
|
||||
while i < length:
|
||||
if concept_repr[i] == ":":
|
||||
break
|
||||
key += concept_repr[i]
|
||||
i += 1
|
||||
else:
|
||||
return None, None
|
||||
|
||||
i += 1
|
||||
if i >= length:
|
||||
return key, None
|
||||
|
||||
id = ""
|
||||
while i < length:
|
||||
if concept_repr[i] == ":":
|
||||
break
|
||||
id += concept_repr[i]
|
||||
i += 1
|
||||
else:
|
||||
return None, None
|
||||
|
||||
return key, id
|
||||
|
||||
|
||||
def decode_enum(enum_repr: str):
|
||||
"""
|
||||
Tries to transform ClassName.Name into an enum
|
||||
:param enum_repr:
|
||||
:return:
|
||||
"""
|
||||
if not (enum_repr and isinstance(enum_repr, str)):
|
||||
return None
|
||||
|
||||
try:
|
||||
idx = enum_repr.rindex(".")
|
||||
if idx == len(enum_repr):
|
||||
return None
|
||||
|
||||
cls_name = enum_repr[:idx]
|
||||
cls = get_class(cls_name)
|
||||
name = enum_repr[idx + 1:]
|
||||
return cls[name]
|
||||
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
except TypeError:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user