semvec/pypi-packages huggingface dataset:
dtree-metalcycling 0.4.2
'dtree': Linux 'tree' but for Python dictionaries
Keywords: dictionary, tree

# **dtree**: Linux **tree** but for Python dictionaries

Dictionaries are fun and useful!. But just like a folder structure, they can be multitiered storing all kinds of things in nested hierarchies. `tree` is a Linux utility that prints the multilevel structure of directories as a beautiful tree. `dtree` does the same but for dictionaries.

## Example

Consider the following dictionary

```python
dictionary = { "A": { "B": { "C": 0, "D": "some-string" }, "E": None }, "F": { "G": 0.0, "H": set([]) } }
```

Using `dtree` you can print the tree structure in different ways:

![Demo](https://github.com/metalcycling/dtree/blob/25ed816adacc2cbce20ecd02910891eeb1cb3106/docs/dtree.png?raw=true "Demo")

## Installation

This utility can be installed directly from PyPI as:

```bash
pip install dtree-metalcycling
```

For local installations intended for development, from the top of this repository run:

```bash
pip install -e .
```

## Known limitations

This version currently prints the `str` representation of the dictionary keys for the nodes of the tree. When keys are custom class objects, printing them could be very verbose so that would cause issues with the printed tree. I'll fix this in future PRs.
dataclass_map_and_log 0.1.6
Map a dict to a dataclass and log differences
Requires Python: <3.11,>=3.8

# Dataclass Map And Log[![tag](https://img.shields.io/github/tag/namelivia/dataclass-map-and-log.svg)](https://github.com/namelivia/dataclass-map-and-log/releases) [![Build](https://github.com/namelivia/dataclass-map-and-log/actions/workflows/build.yml/badge.svg)](https://github.com/namelivia/dataclass-map-and-log/actions?query=workflow%3ABuild) [![codecov](https://codecov.io/gh/namelivia/dataclass-map-and-log/branch/master/graph/badge.svg)](https://codecov.io/gh/namelivia/dataclass-map-and-log)

Map dictionaries to pydantic dataclasses, log any extra attributes.

## Example
```python
from dataclass_map_and_log.mapper import DataclassMapper

@dataclass
class Child:
    name: str
    surname: str


@dataclass
class SingleChild:
    name: str


@dataclass
class Parent:
    name: str
    surname: str
    children: List[Child]
    single_child: SingleChild
    
data = {
    "name": "parent_name",
    "surname": "parent_surname",
    "extra": "parent_extra_data",
    "children": [
        {
            "name": "child1_name",
            "surname": "child1_surname",
            "extra": "child_extra_data",
        },
        {
            "name": "child2_name",
            "surname": "child2_surname",
        },
    ],
    "single_child": {"name": "test"},
}

definition = DataclassMapper.map(Parent, data)
```

You can then access the dataclass instance like:
```python
definition.single_child.name
```

And you would have gotten the following warning log messages:
```
"Unexpected attribute extra on class <class 'tests.test_dataclass_map_and_log.Parent'> with value parent_extra_data",
"Unexpected attribute extra on class <class 'tests.test_dataclass_map_and_log.Child'> with value child_extra_data",
```