-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from ImMin5/master
Add search spec 'projection'
- Loading branch information
Showing
4 changed files
with
113 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
def save_to_dict_value( | ||
data: dict, | ||
dotted_key: str, | ||
value: any, | ||
default_value: any = None, | ||
overwrite: bool = False, | ||
) -> dict: | ||
if "." in dotted_key: | ||
key, rest_dotted_key = dotted_key.split(".", 1) | ||
print("key, rest_dotted_key", key, rest_dotted_key) | ||
if key not in data: | ||
data[key] = {} | ||
|
||
if len(rest_dotted_key) > 0: | ||
print("nested") | ||
save_to_dict_value(data[key], rest_dotted_key, value, default_value) | ||
else: | ||
if dotted_key not in data or overwrite is True: | ||
data[dotted_key] = value | ||
print("not dotted", data, dotted_key, value) | ||
|
||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters