1
Fork 0
mirror of https://github.com/RGBCube/JsonWrapper synced 2025-07-27 11:47:45 +00:00

Merge pull request #1 from RGBCube/sourcery/main

Sourcery refactored main branch
This commit is contained in:
RGBCube 2022-02-19 13:41:49 +03:00 committed by GitHub
commit 5d112701f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,7 +67,7 @@ class _PathMagic:
Returns: Returns:
dict: The modified dict. dict: The modified dict.
""" """
if key in alt_dict.keys() and isinstance(alt_dict[key], dict): if key in alt_dict and isinstance(alt_dict[key], dict):
return alt_dict return alt_dict
alt_dict[key] = {} alt_dict[key] = {}
@ -195,7 +195,7 @@ class JsonWrapper:
json_data = self.json.data() json_data = self.json.data()
if pathmagic == "" or pathmagic == []: if pathmagic in ["", []]:
json_data[key] = value json_data[key] = value
self.json.dump(json_data) self.json.dump(json_data)
@ -218,7 +218,7 @@ class JsonWrapper:
json_data = self.json.data() json_data = self.json.data()
if pathmagic == "" or pathmagic == []: if pathmagic in ["", []]:
return json_data.get(key, default) return json_data.get(key, default)
else: else:
@ -245,7 +245,7 @@ class JsonWrapper:
json_data = self.json.data() json_data = self.json.data()
if pathmagic == "" or pathmagic == []: if pathmagic in ["", []]:
json_data.pop(key, None) json_data.pop(key, None)
self.json.dump(json_data) self.json.dump(json_data)
@ -259,7 +259,7 @@ class JsonWrapper:
Args: Args:
pathmagic (Union[str, List[str]], optional): The path to follow. Defaults to "". pathmagic (Union[str, List[str]], optional): The path to follow. Defaults to "".
""" """
if pathmagic == "" or pathmagic == []: if pathmagic in ["", []]:
self.json.dump({}) self.json.dump({})
else: else: