Skip to content

Commit 40bc1d0

Browse files
committed
add json dump wrapper
1 parent a4e1173 commit 40bc1d0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/somesy/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Utility functions for somesy."""
2+
import wrapt
3+
4+
5+
@wrapt.decorator
6+
def json_dump_wrapper(wrapped, instance, args, kwargs):
7+
"""Wrap json.dump to write non-ascii characters with default indentation."""
8+
# Ensure ensure_ascii is set to False
9+
kwargs["ensure_ascii"] = False
10+
# set indent to 2 if not set
11+
kwargs["indent"] = kwargs.get("indent", 2)
12+
return wrapped(*args, **kwargs)

0 commit comments

Comments
 (0)