kkpyutil 1.38.1__py3-none-any.whl → 1.39.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kkpyutil
3
- Version: 1.38.1
3
+ Version: 1.39.0
4
4
  Summary: Building blocks for sysadmin and DevOps
5
5
  Home-page: https://github.com/kakyoism/kkpyutil/
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ kkpyutil.py,sha256=aJZiOrfAupfxoq0xFySLag6iaWZQyx7JMOpDAzaB-wE,111187
2
+ kkpyutil_helper/windows/kkttssave.ps1,sha256=xa3-WzqNh2rGYlOx_I4ewOuCE94gkTO5cEwYH0M67_0,446
3
+ kkpyutil_helper/windows/kkttsspeak.ps1,sha256=7WUUHMmjTQroUWA2Mvdt4JtSt475nZUHQx-qP-7rS6o,305
4
+ kkpyutil-1.39.0.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
+ kkpyutil-1.39.0.dist-info/METADATA,sha256=NW7-hBiiwyDwK6cXJguT7L87xuyCQC6YCZl00fPJhc4,1136
6
+ kkpyutil-1.39.0.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
+ kkpyutil-1.39.0.dist-info/RECORD,,
kkpyutil.py CHANGED
@@ -2936,8 +2936,20 @@ def remove_unsupported_dict_keys(mydict: dict, supported_keys: set):
2936
2936
  return mydict
2937
2937
 
2938
2938
 
2939
+ def json_to_text(obj, use_unicode=True, pretty=False):
2940
+ try:
2941
+ json_str = json.dumps(obj, ensure_ascii=not use_unicode, indent=4 if pretty else None)
2942
+ return json_str, None
2943
+ except TypeError as e:
2944
+ return None, e
2939
2945
 
2940
2946
 
2947
+ def json_from_text(json_str):
2948
+ try:
2949
+ data = json.loads(json_str)
2950
+ return data, None
2951
+ except json.JSONDecodeError as e:
2952
+ return None, e
2941
2953
 
2942
2954
 
2943
2955
  def _test():
@@ -1,7 +0,0 @@
1
- kkpyutil.py,sha256=afYWa2A3aviwb-5ZKPXh18NUjYcj2fk20dHbtYvAFbw,110786
2
- kkpyutil_helper/windows/kkttssave.ps1,sha256=xa3-WzqNh2rGYlOx_I4ewOuCE94gkTO5cEwYH0M67_0,446
3
- kkpyutil_helper/windows/kkttsspeak.ps1,sha256=7WUUHMmjTQroUWA2Mvdt4JtSt475nZUHQx-qP-7rS6o,305
4
- kkpyutil-1.38.1.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
- kkpyutil-1.38.1.dist-info/METADATA,sha256=wx_y0ac1ICJFrJrlam2Dh-0LJplfYD2ul2aHoD6_nOw,1136
6
- kkpyutil-1.38.1.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
- kkpyutil-1.38.1.dist-info/RECORD,,