{ "info": { "author": "Olivier Verville", "author_email": "", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only" ], "description": "# Dedict\nDedict is a simple dependency-less library that allows you to create data objects from dictionaries. It currently works on Python 3.6 and 3.7\n\n### Why Dedict?\nThere's already a few libraries out there that allow you to create objects from json/dictionaries, such as [jsonpickle](https://jsonpickle.github.io/). However these libraries usually rely on metadata stored in the input structure to create the object. That means the serialized object has noisy metadata in it and that the dictionary/json must have been generated with the library to be able to be transformed back into an object.\n\nThere's also [jsonstruct](https://github.com/initialxy/jsonstruct) which fixes the metadata issue, but requires dataclasses to have \"default\" values defined for their parameters so that it can read the types at runtime and understand how to create the object.\n\nDedict aims to strive away from these methods, and allow the creation of objects without relying on metadata inside the input data or arbitrary default values within the data class. Instead, dedict makes clever use of [type hints](https://www.python.org/dev/peps/pep-0484/) and [variable annotations](https://www.python.org/dev/peps/pep-0526/) that were introduced with Python 3.6\n\n### Install\n```\npip install dedict\n```\n\n### Usage example\n```python\nclass SomeDataClass(Dedictable):\n something: str\n whatever: int\n\nsome_data_class = SomeDataClass.dedict({'something': 'test', 'whatever': 100})\n\n# output: SomeDataClass(something='test', whatever=100)\n```\n\nDedict also works recursively, meaning you can parse complex data structures\n```python\nclass SomeChildClass(Dedictable):\n a: str\n b: str\n\nclass Complex(Dedictable):\n some_string: str\n child: SomeChildClass\n\ncomplex = Complex.dedict({'some_string': 'test', 'child': {'a': 'hello', 'b': 'world'}})\n```\n\n### Built-in object model validation\nDedict also ensures the data passed is actually a valid representation of the object you're trying to create, by checking whether your data structure has fields that do not belong in the target object\n```python\nclass Sample(Dedictable):\n something: str\n whatever: str\n\nsample = Sample.dedict({'something': 'else', 'whatever': 'you want', 'hello': 'world'})\n\n# raises: AttributeError('object Sample has no attribute named hello')\n```\n\nBy default, dedict will not care about missing attributes in the input data structure, and will consider them optional. However you can enforce full validation by instead using the `DedictableStrict` implementation.\n```python\nclass Strict(DedictableStrict):\n a: str\n b: str\n c: str\n\ns = Strict.dedict({'b': 'hello', 'c': 'world'})\n\n# raises: AttributeError('dictionary was missing mandatory attribute a to create an object of type Sample')\n```\n\nHowever, if you want full validation but also need to set some attributes as optional, dedict provides a new type annotation to mark attributes as optional when using the strict implementation.\n```python\nclass Strict(DedictableStrict):\n a: OptionalAttr[str]\n b: str\n c: str\n\ns = Strict.dedict({'b': 'hello', 'c': 'world'})\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "dedict", "package_url": "https://pypi.org/project/dedict/", "platform": "", "project_url": "https://pypi.org/project/dedict/", "project_urls": null, "release_url": "https://pypi.org/project/dedict/1.0.7/", "requires_dist": null, "requires_python": "", "summary": "simple library to create objects from dictionaries", "version": "1.0.7" }, "last_serial": 5743364, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "7024e41b237a4f5e61dce3d8fb6a12cd", "sha256": "24021f5b2f6b3bc20b21e1b21b664e2fd741b85439ea53146afff4210d11bb16" }, "downloads": -1, "filename": "dedict-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7024e41b237a4f5e61dce3d8fb6a12cd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4189, "upload_time": "2019-08-17T09:36:51", "url": "https://files.pythonhosted.org/packages/54/70/f94ea41239f725e89a6d8b8bb5e3d2bfc2a5611b9b4b45e6915272ef5468/dedict-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3b8ed6788b5df36c1a3a4281798d555b", "sha256": "14fe3913c707610875ab511b6a3a3cff89be3672bd9853a28a676164baf652eb" }, "downloads": -1, "filename": "dedict-1.0.1.tar.gz", "has_sig": false, "md5_digest": "3b8ed6788b5df36c1a3a4281798d555b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2935, "upload_time": "2019-08-17T09:36:52", "url": "https://files.pythonhosted.org/packages/ba/4e/389bb4878d91cdd598fe85dab9ac453210d3636586762a09fb45e7853375/dedict-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "a4d2e210dfba558bd1e30c733080875a", "sha256": "d84c619d8dfb443dee0a337239fa808e5d16e8def70534c4381c0105be9bb5f4" }, "downloads": -1, "filename": "dedict-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a4d2e210dfba558bd1e30c733080875a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4326, "upload_time": "2019-08-17T09:42:12", "url": "https://files.pythonhosted.org/packages/e3/9c/cda16693923c0c576fe616e1c2a351324577ac3b1f92e79caf6e2bcba15c/dedict-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "42d11944de631acaaa531a18a2af8be9", "sha256": "71f3dd966ecb292b13326c5bde2bd7dc1835c8e02b6461c7ce8d47898f784420" }, "downloads": -1, "filename": "dedict-1.0.2.tar.gz", "has_sig": false, "md5_digest": "42d11944de631acaaa531a18a2af8be9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3089, "upload_time": "2019-08-17T09:42:14", "url": "https://files.pythonhosted.org/packages/4a/ed/70c6cf3cb0e6b2a57f2eb3fd6c559189655dbd476df524c8342ffc6adb17/dedict-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "54c8ce8c0d11015ae3dc0d63fb92c344", "sha256": "7aacd7ef235599612ae726a41a63b365fa0b47081e33c67b8717e9ff5ad3ae03" }, "downloads": -1, "filename": "dedict-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "54c8ce8c0d11015ae3dc0d63fb92c344", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4363, "upload_time": "2019-08-20T14:56:42", "url": "https://files.pythonhosted.org/packages/58/7d/fb964a37f54ff2c4bbd44255661c1fa276510860bcfe098f2a4015fbe53e/dedict-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "17beecda7b366811eee0dfee6256399c", "sha256": "943a20cc2505de4c15a7ae1e10a1a90233c18af777a611ca55f37fe709785464" }, "downloads": -1, "filename": "dedict-1.0.3.tar.gz", "has_sig": false, "md5_digest": "17beecda7b366811eee0dfee6256399c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3132, "upload_time": "2019-08-20T14:56:44", "url": "https://files.pythonhosted.org/packages/0f/ac/7816545fa853c05a90b012084eaa237478f3e1411df3d927dd9f9063b37c/dedict-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "2331a5e3f7255ae9270196a32414a2b3", "sha256": "96a907f54f7d4efc488bb08954e7573e92293d4b76a643c67f2460873f9fcacb" }, "downloads": -1, "filename": "dedict-1.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "2331a5e3f7255ae9270196a32414a2b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4378, "upload_time": "2019-08-20T15:11:30", "url": "https://files.pythonhosted.org/packages/f6/09/e721e66dba02ff539ce19aed829e3841f0ed41da8461a1d39802d90f0049/dedict-1.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "14008a48880afded6b83e926de6d822d", "sha256": "9cf5dee5d8da461a28a1c3bbd88cf3dfec828da6b96ee8306a8518f8ff763eb0" }, "downloads": -1, "filename": "dedict-1.0.4.tar.gz", "has_sig": false, "md5_digest": "14008a48880afded6b83e926de6d822d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3148, "upload_time": "2019-08-20T15:11:32", "url": "https://files.pythonhosted.org/packages/7e/67/32f3fee0c3aa510ee5e0f2a9bccd70e59f6009abcc32242cd59e629b35b4/dedict-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "60cfeb60df02ba08d9538aefde349b79", "sha256": "22db0743bac016748db4c40be64d985f515d06ad999cef2bf84c8fe4c822bb56" }, "downloads": -1, "filename": "dedict-1.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "60cfeb60df02ba08d9538aefde349b79", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4430, "upload_time": "2019-08-27T18:50:59", "url": "https://files.pythonhosted.org/packages/22/24/927ad7fee2f1b5b673122c057bb8e87c32fb129d3eccdadf1179495987d7/dedict-1.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36081362aa121bb3cce002b43e4e61f1", "sha256": "9b6944cfec7ede7e59484a9272bb47ef69a61f6f47c6216c410db93295fe4c66" }, "downloads": -1, "filename": "dedict-1.0.5.tar.gz", "has_sig": false, "md5_digest": "36081362aa121bb3cce002b43e4e61f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3206, "upload_time": "2019-08-27T18:51:01", "url": "https://files.pythonhosted.org/packages/a8/c1/6fd5e28ba2d9e63d2d45c3494652ecc14c3f16bf64f3428e19e1a3886818/dedict-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "d5a7f5106b8e2a54d20e4dcc215fd0de", "sha256": "6cf1adb994542b1b77c0c8b9ad1ec67b45c459f3d319037cc56f1bfb31be97b0" }, "downloads": -1, "filename": "dedict-1.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "d5a7f5106b8e2a54d20e4dcc215fd0de", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4421, "upload_time": "2019-08-27T19:22:32", "url": "https://files.pythonhosted.org/packages/74/bb/b18620e3342657fe005642f9d69637522bff52bcc8b8e1b52c7c160ba235/dedict-1.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21d46ba749c497d4085b7fb173c31748", "sha256": "582d244033ebac877c3a7fb9b2292d4f7bb920d5a13d614b13ef4d29f7ce9258" }, "downloads": -1, "filename": "dedict-1.0.6.tar.gz", "has_sig": false, "md5_digest": "21d46ba749c497d4085b7fb173c31748", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3194, "upload_time": "2019-08-27T19:22:34", "url": "https://files.pythonhosted.org/packages/06/8c/462d274754c55f470bbb0b16cc13453412307815552d098758da4bd1e6e0/dedict-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "650df4ca2b456d2f320c0617a7fb78eb", "sha256": "d83487bbc60160dff3270752f6631344e031bf1abd83a37ac49a5e601009703f" }, "downloads": -1, "filename": "dedict-1.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "650df4ca2b456d2f320c0617a7fb78eb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4472, "upload_time": "2019-08-28T15:33:25", "url": "https://files.pythonhosted.org/packages/3f/79/f3befcb9cc4a61d817c93829448202c2e009cbca24d2fffd6b7b14a7e8fd/dedict-1.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f26a825a672758097da7e4dcaa57fd78", "sha256": "3d2cf39441e2450f2ce7d830e01f3c57b26bdc0564174e2d90dd63dab34f4b21" }, "downloads": -1, "filename": "dedict-1.0.7.tar.gz", "has_sig": false, "md5_digest": "f26a825a672758097da7e4dcaa57fd78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3231, "upload_time": "2019-08-28T15:33:27", "url": "https://files.pythonhosted.org/packages/17/34/109aef09ecfc2363d80d579519e7386d99f5839092b8439599d9d91046cd/dedict-1.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "650df4ca2b456d2f320c0617a7fb78eb", "sha256": "d83487bbc60160dff3270752f6631344e031bf1abd83a37ac49a5e601009703f" }, "downloads": -1, "filename": "dedict-1.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "650df4ca2b456d2f320c0617a7fb78eb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4472, "upload_time": "2019-08-28T15:33:25", "url": "https://files.pythonhosted.org/packages/3f/79/f3befcb9cc4a61d817c93829448202c2e009cbca24d2fffd6b7b14a7e8fd/dedict-1.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f26a825a672758097da7e4dcaa57fd78", "sha256": "3d2cf39441e2450f2ce7d830e01f3c57b26bdc0564174e2d90dd63dab34f4b21" }, "downloads": -1, "filename": "dedict-1.0.7.tar.gz", "has_sig": false, "md5_digest": "f26a825a672758097da7e4dcaa57fd78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3231, "upload_time": "2019-08-28T15:33:27", "url": "https://files.pythonhosted.org/packages/17/34/109aef09ecfc2363d80d579519e7386d99f5839092b8439599d9d91046cd/dedict-1.0.7.tar.gz" } ] }