Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
878 B
Python
Raw Normal View History

import collections.abc as collections_abc
from moto.moto_api._internal import mock_random
2022-12-11 09:48:12 -01:00
from typing import Any
2015-09-16 10:00:38 -04:00
2022-12-11 09:48:12 -01:00
def get_random_pipeline_id() -> str:
return f"df-{mock_random.get_random_hex(length=19)}"
2022-12-11 09:48:12 -01:00
def remove_capitalization_of_dict_keys(obj: Any) -> Any:
if isinstance(obj, collections_abc.Mapping):
result = obj.__class__()
for key, value in obj.items():
normalized_key = key[:1].lower() + key[1:]
2022-12-11 09:48:12 -01:00
result[normalized_key] = remove_capitalization_of_dict_keys(value) # type: ignore[index]
return result
2021-07-26 07:40:39 +01:00
elif isinstance(obj, collections_abc.Iterable) and not isinstance(obj, str):
2022-12-11 09:48:12 -01:00
result = obj.__class__() # type: ignore[assignment]
for item in obj:
2022-12-11 09:48:12 -01:00
result += (remove_capitalization_of_dict_keys(item),) # type: ignore[operator]
return result
else:
return obj