diff --git a/README.md b/README.md index f0fc7fe..bbe1317 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ # Pyngo +![Pyngo](https://user-images.githubusercontent.com/52716203/145123561-ef58bc47-b5a9-4aaf-b13f-be881cbe6539.png) +
Utils to help integrate pydantic into Django projects
[![codecov](https://codecov.io/gh/yezz123/pyngo-utils/branch/main/graph/badge.svg?token=QAGGVJ8URH)](https://codecov.io/gh/yezz123/pyngo-utils) [![PyPI version](https://badge.fury.io/py/pyngo.svg)](https://badge.fury.io/py/pyngo) -[![Downloads](https://pepy.tech/badge/pyngo/month)](https://pepy.tech/project/pyngo) +[![License](https://img.shields.io/badge/License-MIT-green?style)](https://opensource.org/licenses/MIT) [![Language](https://img.shields.io/badge/Language-Python-green?style)](https://github.com/yezz123) -[![framework](https://img.shields.io/badge/Framework-Django-green?style)](https://fastapi.tiangolo.com/) +[![framework](https://img.shields.io/badge/Framework-Django-green?style)](https://www.djangoproject.com/) [![Pypi](https://img.shields.io/pypi/pyversions/pyngo.svg?color=%2334D058)](https://pypi.org/project/pyngo) --- diff --git a/pyngo/errors.py b/pyngo/errors.py index 2940ec0..3b2b3ab 100644 --- a/pyngo/errors.py +++ b/pyngo/errors.py @@ -34,3 +34,19 @@ def set_nested(data: Dict[str, Any], keys: Sequence[str], value: Any) -> None: for key in keys[:-1]: data = data.setdefault(str(key), {}) data[keys[-1]] = value + + +def get_nested(data: Dict[str, Any], keys: Sequence[str]) -> Any: + """ + Get a value from a nested dictionary. + + Args: + data (Dict[str, Any]): The dictionary to get the value from. + keys (Sequence[str]): The keys to get the value at. + + Returns: + Any: The value. + """ + for key in keys[:-1]: + data = data[key] + return data[keys[-1]]