kkpyutil 1.38.1__tar.gz → 1.40.0__tar.gz
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.
- {kkpyutil-1.38.1 → kkpyutil-1.40.0}/PKG-INFO +1 -1
- {kkpyutil-1.38.1 → kkpyutil-1.40.0}/kkpyutil.py +36 -1
- {kkpyutil-1.38.1 → kkpyutil-1.40.0}/pyproject.toml +1 -1
- {kkpyutil-1.38.1 → kkpyutil-1.40.0}/LICENSE +0 -0
- {kkpyutil-1.38.1 → kkpyutil-1.40.0}/README.md +0 -0
- {kkpyutil-1.38.1 → kkpyutil-1.40.0}/kkpyutil_helper/windows/kkttssave.ps1 +0 -0
- {kkpyutil-1.38.1 → kkpyutil-1.40.0}/kkpyutil_helper/windows/kkttsspeak.ps1 +0 -0
|
@@ -2936,12 +2936,47 @@ 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
|
|
2945
|
+
|
|
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
|
|
2953
|
+
|
|
2939
2954
|
|
|
2955
|
+
class OfflineJSON:
|
|
2956
|
+
def __init__(self, file_path):
|
|
2957
|
+
self.path = file_path
|
|
2940
2958
|
|
|
2959
|
+
def exists(self):
|
|
2960
|
+
return osp.isfile(self.path)
|
|
2961
|
+
|
|
2962
|
+
def load(self):
|
|
2963
|
+
return load_json(self.path) if self.exists() else None
|
|
2964
|
+
|
|
2965
|
+
def save(self, data: dict):
|
|
2966
|
+
save_json(self.path, data)
|
|
2967
|
+
|
|
2968
|
+
def merge(self, props: dict):
|
|
2969
|
+
data = self.load()
|
|
2970
|
+
if not data:
|
|
2971
|
+
return self.save(props)
|
|
2972
|
+
data.update(props)
|
|
2973
|
+
self.save(data)
|
|
2974
|
+
return data
|
|
2941
2975
|
|
|
2942
2976
|
|
|
2943
2977
|
def _test():
|
|
2944
|
-
print(say('hello'))
|
|
2978
|
+
# print(say('hello'))
|
|
2979
|
+
print(create_guid())
|
|
2945
2980
|
|
|
2946
2981
|
|
|
2947
2982
|
if __name__ == '__main__':
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|