Library for transform data structures
Project description
HTL - Library for transform data structures
Example
from htl.htl import linear_to_hierarchical, hierarchical_to_linear
linear = [
{'name': 'Lorem', 'parent': None},
{'name': 'ipsum', 'parent': 'Lorem'},
{'name': 'dolor', 'parent': 'ipsum'},
{'name': 'sit', 'parent': 'dolor'},
{'name': 'amet', 'parent': 'ipsum'},
{'name': 'consectetur', 'parent': 'Lorem'},
{'name': 'adipisicing', 'parent': 'consectetur'}
]
hierarchical = linear_to_hierarchical(linear)
"""
hierarchical:
{
'name': 'Lorem',
'children': [
{
'name': 'ipsum',
'children': [
{
'name': 'dolor',
'children': [
{
'name': 'sit'
}
]
},
{
'name': 'amet'
}
]
},
{
'name': 'consectetur',
'children': [
{
'name': 'adipisicing'
}
]
}
]
}
"""
# To reverse conversion, use function hierarchical_to_linear
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
htl-1.0.0.tar.gz
(2.6 kB
view hashes)
Built Distribution
htl-1.0.0-py3-none-any.whl
(3.8 kB
view hashes)