Commit abc2e948 authored by Anton Pershin's avatar Anton Pershin

Added function in comaux for taking value from a sequence by index with a default option

parent b54ff2ad
......@@ -434,6 +434,10 @@ def take_value_if_not_none(value, default=None, transform=str) -> Any:
return transform(value)
def take_value_by_index(seq, i, default=None) -> Any:
return seq[i] if seq is not None else default
def dump_to_json(obj: JsonSerializable, path_to_jsons: str = 'jsons') -> None:
filename = '{}.{}.json'.format(type(obj).__module__, type(obj).__name__)
filename = os.path.join(path_to_jsons, filename)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment