* Separated tests in multiple files. * Added pydantic validation for configuration. * Improved backup/restore on visit of nodes. * Echoing of variables with default no longer visits the default when not used (and no longer creates variables that were not actually used).
42 lines
934 B
Python
42 lines
934 B
Python
def deep_freeze(obj):
|
|
"""
|
|
Deep freeze an object.
|
|
|
|
Args:
|
|
obj (object): The object to freeze.
|
|
|
|
Returns:
|
|
object: The frozen object.
|
|
"""
|
|
if isinstance(obj, dict):
|
|
return tuple((k, deep_freeze(v)) for k, v in sorted(obj.items()))
|
|
if isinstance(obj, list):
|
|
return tuple(deep_freeze(i) for i in obj)
|
|
if isinstance(obj, set):
|
|
return tuple(deep_freeze(i) for i in sorted(obj))
|
|
return obj
|
|
|
|
def escape_single_quotes(s: str):
|
|
"""
|
|
Escape single quotes in a string.
|
|
|
|
Args:
|
|
s (str): The string to escape.
|
|
|
|
Returns:
|
|
str: The escaped string.
|
|
"""
|
|
return s.replace("'", "\\'")
|
|
|
|
def escape_double_quotes(s: str):
|
|
"""
|
|
Escape double quotes in a string.
|
|
|
|
Args:
|
|
s (str): The string to escape.
|
|
|
|
Returns:
|
|
str: The escaped string.
|
|
"""
|
|
return s.replace('"', '\\"')
|