All this package does is create a dataclass so you can straight up use it as if it was a dictionary. Here's a basic example:
from dataclass_dict import create_dataclass_dict
# Generate a instance
instance = create_dataclass_dict({"name": "Test", "value": 10})
# prints "Test"
print(instance.name)
# also prints "Test"
print(instance["name"])
# prints "Test" and deletes the field "name"
print(instance.pop("name")
Also, you can automatically generate a dataclass with a json like this:
from dataclass_dict import dataclass_from_json
json_code = """{
"name": "Test",
"value": 10
}"""
instance = dataclass_from_json(json_code)
If you'd like, you can load a json file straight from a url like this:
from dataclass_dict import dataclass_from_url
dataclass_from_url("json_url")
Plus, if you pass multiple parameters this way:
from dataclass_dict import dataclass_from_url
dataclass_from_url("json_url_1", "json_url_2")
They will be downloaded at the same time using threads.
Keep in mind that all parameters from the function :func:`json.dumps` works with the :func:`dataclass_from_json` and :func:`dataclass_from_url` so you can write special parsers.
.. automodule:: dataclass_dict :members: :private-members: :special-members: :show-inheritance: :exclude-members: __weakref__
.. automodule:: dataclass_dict.threaded_request :members: :private-members: :special-members: :show-inheritance: :exclude-members: __weakref__
.. automodule:: dataclass_dict.utils :members: :private-members: :special-members: :show-inheritance: :exclude-members: __weakref__
- The software will now tell which variable has a invalid name.
- If the creation dictionary have a string that is not a valid variable name, it will raise an :class:`~AssertionError`
- :func:`~dataclass_dict.utils.valid_variable` was added
- Now, the package should be able to be installed normally. The package name was being identified as src
- Any attribute, including parent ones, that starts with underscore will be ignored.
- :func:`~dataclass_dict.utils.item_zip` was added. It iterates between more than one :class:`~dict`.
- Now, indeed, anything started with underscore will be ignored.
- Any attribute starting with a _ will not be added to the dataclass, but will be available normally
- :meth:`~dataclass_dict.DataclassDict.__new__` and :meth:`~dataclass_dict.DataclassDict.__init_subclass__` now calls their parents with :func:`super`
- If a class inherited :class:`~dataclass_dict.DataclassDict` and it didn't have a field with annotations, it would raise an error. That's fixed now.
- Added Tidelif information in the readme
- Fixed informations in the setup.py file such as descriptions and repository link.
- Package released