1
0
mirror of synced 2025-12-21 11:01:41 -05:00
Files
airbyte/airbyte-integrations/connectors/source-tplcentral/source_tplcentral/util.py
Cole Snodgrass 2e099acc52 update headers from 2022 -> 2023 (#22594)
* It's 2023!

* 2022 -> 2023

---------

Co-authored-by: evantahler <evan@airbyte.io>
2023-02-08 13:01:16 -08:00

40 lines
965 B
Python

#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from typing import Any, Mapping
def deep_map(function, collection):
if isinstance(collection, list):
return list(map(lambda val: deep_map(function, val), collection))
collection = function(collection)
for key, val in collection.items():
if isinstance(val, dict):
collection[key] = deep_map(function, val)
elif isinstance(val, list):
collection[key] = deep_map(function, val)
else:
collection[key] = val
return collection
def normalize(collection):
return deep_map(_normalizer, collection)
def _normalizer(dictionary):
out = {}
for key, val in dictionary.items():
if not key == "_links":
out[key] = val
return out
def deep_get(mapping: Mapping[str, Any], key: str) -> Any:
key = key.split(".")
while len(key):
mapping = mapping[key.pop(0)]
return mapping