{ "info": { "author": "Eugene Mozge", "author_email": "eumozge@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# parser-string-python\n\nThe parser which can get dict with strings and convert them to Python types like int, float, date, list etc. It can be useful for parsing request params via API.\n\n## Table of contents\n\n* [How to create fields](#how-to-create-field)\n* [How to create a parser](#how-to-create-a-parser)\n* [How to use a parser](#how-to-use-a-parser)\n\n### How to create fields\n\nThere is 99% that you no need more than default fields. And that section is just for knowing how it works. Parser gets fields as required arguments. A field is a pair of key and value. This way any dict is many fields. Every filed inherits from base class `Field`. The `Field` has two important methods `_is_valid_value()` and `_resolve()`. Those methods should me override. The `_resolve()` converts a value to the necessary type. It's the main class method.\n\nAlso, a field can have property `param_start_with`. It's necessary when you want to set validation via param key. For example, there are fields `list_ids` and `ids`. You set `param_start_with` as `list`. It means only `list_ids` will be valid.\n\n\n```\nfrom parser_json_python.fields import Field\n\nclass FieldDate(Field):\n param_start_with = 'date'\n date_template = '%Y-%m-%d %H:%M'\n\n def _is_valid_value(self, value):\n try:\n self._resolve(value)\n return True\n except ValueError:\n return False\n\n def _resolve(self, value):\n return datetime.strptime(value, self.date_template)\n```\n\n### How to create a parser\n\nYou can import `DefaultParser` with all default fields. If you want to create own parser you need to set fields as a list of `Field` object.\n\n```\nfrom parser_json_python.fields import *\n\nDefaultParser = Parser(\n fields=(FieldInt(), FieldFloat(), FieldList(), FieldDate(), FieldBoolean())\n)\n```\n\n### How to use a parser\n\nA `Parser` has two methods. The first `parse_field()` is for convert one param and the second `parse()` for convert dict with params.\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": "https://github.com/eumozge/parser-json-python", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "parser-json-python", "package_url": "https://pypi.org/project/parser-json-python/", "platform": "", "project_url": "https://pypi.org/project/parser-json-python/", "project_urls": { "Homepage": "https://github.com/eumozge/parser-json-python" }, "release_url": "https://pypi.org/project/parser-json-python/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "The parser which can get dict with strings and convert them to Python types like int, float, date, list etc. It can be useful for parsing request params via API.", "version": "1.0.1" }, "last_serial": 5645087, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "84280a981d723d276e2d9f8c73e4d675", "sha256": "35558fc34e9239e3b24b98e736bf106e013ed656dc48e59f045daaf6d536312d" }, "downloads": -1, "filename": "parser_json_python-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "84280a981d723d276e2d9f8c73e4d675", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4717, "upload_time": "2019-07-10T08:22:41", "url": "https://files.pythonhosted.org/packages/9c/a6/89998ca9cf2c39bf9145f42183fe5dc147525683d499533865d5325eb7ac/parser_json_python-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "750a2af6e18e373d965c76cdbac93c95", "sha256": "2b1be50dab82e12b7919553c5d11a539cf530533179ef5e68487b5f0cf2d64be" }, "downloads": -1, "filename": "parser-json-python-0.1.0.tar.gz", "has_sig": false, "md5_digest": "750a2af6e18e373d965c76cdbac93c95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2669, "upload_time": "2019-07-10T08:22:43", "url": "https://files.pythonhosted.org/packages/cc/ae/b3e1ef212d20df049e454c24247f3aba5fbbee8c48a0316a6c10e01012ec/parser-json-python-0.1.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "462a375f05f048eb897dc7ba848e03e7", "sha256": "5544ceb3c5fbdf3e26a1ff0fd1667ebe870fa4a27e7781165f459a646650dc54" }, "downloads": -1, "filename": "parser_json_python-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "462a375f05f048eb897dc7ba848e03e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5519, "upload_time": "2019-07-14T15:00:24", "url": "https://files.pythonhosted.org/packages/7a/9d/5c37c44e251315a45430e87ccb042468bd98dec1bb3ab4eb8c0739c1a6e6/parser_json_python-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a378d1a2385cb6798d9d4e2704d5ef82", "sha256": "542a433c84e84ace7d95efc2cae6c428700b2d156984bf4882ee1d05d43406e5" }, "downloads": -1, "filename": "parser-json-python-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a378d1a2385cb6798d9d4e2704d5ef82", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3352, "upload_time": "2019-07-14T15:00:26", "url": "https://files.pythonhosted.org/packages/e0/28/05021e2da3f71f310d3ceb523bc2c8f7389c4fa91599ccc905ae240d91ce/parser-json-python-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "ddb7b3e5400d2f0c024573181a13fc4e", "sha256": "692ff5f23ae45356b630ebdce004484d86301e0ec75fe7508abb0e747f382366" }, "downloads": -1, "filename": "parser_json_python-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ddb7b3e5400d2f0c024573181a13fc4e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5634, "upload_time": "2019-08-07T13:25:10", "url": "https://files.pythonhosted.org/packages/ac/2e/0018721b35dcba6681f738b8809b1c543416b6b064490d88b25d3001a833/parser_json_python-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "44d7eb50d723f115435e42f642be651f", "sha256": "d8bbe5baeff1363852127fc227eb49b403594e09421c13f0884a11bc4c5168e8" }, "downloads": -1, "filename": "parser-json-python-1.0.1.tar.gz", "has_sig": false, "md5_digest": "44d7eb50d723f115435e42f642be651f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3452, "upload_time": "2019-08-07T13:25:12", "url": "https://files.pythonhosted.org/packages/43/21/1a2addedcc7be2cdd53fcb286d7c4d88a509431dfb1bbde31dcfcc1f2e3c/parser-json-python-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ddb7b3e5400d2f0c024573181a13fc4e", "sha256": "692ff5f23ae45356b630ebdce004484d86301e0ec75fe7508abb0e747f382366" }, "downloads": -1, "filename": "parser_json_python-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ddb7b3e5400d2f0c024573181a13fc4e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5634, "upload_time": "2019-08-07T13:25:10", "url": "https://files.pythonhosted.org/packages/ac/2e/0018721b35dcba6681f738b8809b1c543416b6b064490d88b25d3001a833/parser_json_python-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "44d7eb50d723f115435e42f642be651f", "sha256": "d8bbe5baeff1363852127fc227eb49b403594e09421c13f0884a11bc4c5168e8" }, "downloads": -1, "filename": "parser-json-python-1.0.1.tar.gz", "has_sig": false, "md5_digest": "44d7eb50d723f115435e42f642be651f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3452, "upload_time": "2019-08-07T13:25:12", "url": "https://files.pythonhosted.org/packages/43/21/1a2addedcc7be2cdd53fcb286d7c4d88a509431dfb1bbde31dcfcc1f2e3c/parser-json-python-1.0.1.tar.gz" } ] }