No project description provided
Project description
CLassAttributeModelGenerator
Given a nested dict create a hierarchical object model.
Optionally provide models in YAML or JSON format.
Some would say this is just a dict-wrapper.
Example: Loading a nested dict
>>> data = dict(obj=dict(foo="bar", spam="eggs", a_list=[1,2,3]))
>>> data
{'obj': {'foo': 'bar', 'spam': 'eggs', 'a_list': [1, 2, 3]}}
>>> x = clamg.unpack(data)
>>> x
<clamg(obj=<obj(foo=bar, spam=eggs, a_list=[1, 2, 3])>)>
>>> x.obj.foo
'bar'
Example: Loading YAML
>>> SAMPLE_YAML = """\
... obj:
... yaml: yes
... foo: bar
... spam: eggs
... a_list:
... - 1
... - 2
... - 3
... """
>>> clamg.loads(SAMPLE_YAML)
<clamg(obj=<obj(yaml=True, foo=bar, spam=eggs, a_list=[1, 2, 3])>)>
Example: Loading JSON
>>> SAMPLE_JSON = '{"obj": {"json": "yes", "foo": "bar", "spam": "eggs", "a_list": [1,2,3]}}'
>>> clamg.loads(SAMPLE_JSON)
<clamg(obj=<obj(json=yes, foo=bar, spam=eggs, a_list=[1, 2, 3])>)>
It has occasionally proven useful when working with deeply nested structures.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clamg-0.3.tar.gz
(3.3 kB
view hashes)
Built Distribution
clamg-0.3-py3-none-any.whl
(3.4 kB
view hashes)