mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
Refactoring merge Method into a New Class & Adding Unit Tests (#137)
This commit is contained in:
@@ -45,15 +45,6 @@ def efmt(err: Exception) -> str:
|
||||
|
||||
|
||||
# =====
|
||||
def merge(dest: dict, src: dict) -> None:
|
||||
for key in src:
|
||||
if key in dest:
|
||||
if isinstance(dest[key], dict) and isinstance(src[key], dict):
|
||||
merge(dest[key], src[key])
|
||||
continue
|
||||
dest[key] = src[key]
|
||||
|
||||
|
||||
def rget(dct: dict, *keys: Hashable) -> dict:
|
||||
result = functools.reduce((lambda nxt, key: nxt.get(key, {})), keys, dct)
|
||||
if not isinstance(result, dict):
|
||||
|
||||
Reference in New Issue
Block a user