{ "info": { "author": "x-debug", "author_email": "chenxf@partnerch.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "===========\npyJSON models\n===========\n\n.. image:: https://badge.fury.io/py/jsonmodels.png\n :target: http://badge.fury.io/py/jsonmodels\n\n.. image:: https://travis-ci.org/beregond/jsonmodels.png?branch=master\n :target: https://travis-ci.org/beregond/jsonmodels\n\n.. image:: https://img.shields.io/pypi/dm/jsonmodels.svg\n :target: https://pypi.python.org/pypi/jsonmodels\n\n.. image:: https://coveralls.io/repos/beregond/jsonmodels/badge.png\n :target: https://coveralls.io/r/beregond/jsonmodels\n\n\n`jsonmodels` \u662f\u4e00\u4e2a\u80fd\u591f\u65b9\u4fbf\u5f97\u5904\u7406json\u683c\u5f0f\u6570\u636e\u548c\u6a21\u578b\u6570\u636e\u8f6c\u5316\u7684\u5de5\u5177\n\n* Free software: GPL3\n* Documentation: http://jsonmodels.rtfd.org\n* Source: https://gitee.com/huichengip_chenxf/jsonmodels\n\n\u7279\u6027\n--------\n\n* \u5b8c\u5168\u652f\u6301 Python 2.7, 3.3, 3.4, 3.5, 3.6.\n\n* \u652f\u6301 PyPy (see implementation notes in docs for more details).\n\n* \u521b\u5efa\u7c7b\u4f3cDjango\u4e00\u6837\u7684models:\n\n .. code-block:: python\n\n from jsonmodels import models, fields, errors, validators\n\n\n class Cat(models.Base):\n\n name = fields.StringField(required=True)\n breed = fields.StringField()\n love_humans = fields.IntField(nullable=True)\n\n\n class Dog(models.Base):\n\n name = fields.StringField(required=True)\n age = fields.IntField()\n\n\n class Car(models.Base):\n\n registration_number = fields.StringField(required=True)\n engine_capacity = fields.FloatField()\n color = fields.StringField()\n\n\n class Person(models.Base):\n\n name = fields.StringField(required=True)\n surname = fields.StringField(required=True)\n nickname = fields.StringField(nullable=True)\n car = fields.EmbeddedField(Car)\n pets = fields.ListField([Cat, Dog], nullable=True)\n\n* \u901a\u8fc7\u5c5e\u6027\u8bbf\u95ee\u503c:\n\n .. code-block:: python\n\n >>> cat = Cat()\n >>> cat.populate(name='Garfield')\n >>> cat.name\n 'Garfield'\n >>> cat.breed = 'mongrel'\n >>> cat.breed\n 'mongrel'\n\n* \u9a8c\u8bc1\u6a21\u578b:\n\n .. code-block:: python\n\n >>> person = Person(name='Chuck', surname='Norris')\n >>> person.validate()\n None\n\n >>> dog = Dog()\n >>> dog.validate()\n *** ValidationError: Field \"name\" is required!\n\n* \u8f6c\u5316\u6a21\u578b\u4e3apython\u7684\u683c\u5f0f\u6216\u8005json:\n\n .. code-block:: python\n\n >>> cat = Cat(name='Garfield')\n >>> dog = Dog(name='Dogmeat', age=9)\n >>> car = Car(registration_number='ASDF 777', color='red')\n >>> person = Person(name='Johny', surname='Bravo', pets=[cat, dog])\n >>> person.car = car\n >>> person.to_struct()\n {\n 'car': {\n 'color': 'red',\n 'registration_number': 'ASDF 777'\n },\n 'surname': 'Bravo',\n 'name': 'Johny',\n 'nickname': None,\n 'pets': [\n {'name': 'Garfield'},\n {'age': 9, 'name': 'Dogmeat'}\n ]\n }\n\n >>> import json\n >>> person_json = json.dumps(person.to_struct())\n\n* \u4f60\u4e0d\u60f3\u5199json\u5143\u6570\u636e? pyjsonmodels\u80fd\u4e3a\u4f60\u505a\u8fd9\u4ef6\u4e8b:\n\n .. code-block:: python\n\n >>> person = Person()\n >>> person.to_json_schema()\n {\n 'additionalProperties': False,\n 'required': ['surname', 'name'],\n 'type': 'object',\n 'properties': {\n 'car': {\n 'additionalProperties': False,\n 'required': ['registration_number'],\n 'type': 'object',\n 'properties': {\n 'color': {'type': 'string'},\n 'engine_capacity': {'type': ''},\n 'registration_number': {'type': 'string'}\n }\n },\n 'surname': {'type': 'string'},\n 'name': {'type': 'string'},\n 'nickname': {'type': ['string', 'null']}\n 'pets': {\n 'items': {\n 'oneOf': [\n {\n 'additionalProperties': False,\n 'required': ['name'],\n 'type': 'object',\n 'properties': {\n 'breed': {'type': 'string'},\n 'name': {'type': 'string'}\n }\n },\n {\n 'additionalProperties': False,\n 'required': ['name'],\n 'type': 'object',\n 'properties': {\n 'age': {'type': 'number'},\n 'name': {'type': 'string'}\n }\n },\n {\n 'type': 'null'\n }\n ]\n },\n 'type': 'array'\n }\n }\n }\n\n* \u9a8c\u8bc1\u6a21\u578b\u548c\u7528\u9a8c\u8bc1\u5668, \u6700\u7ec8\u5f71\u54cd\u751f\u6210\u7684json\u5143\u6570\u636e:\n\n .. code-block:: python\n\n >>> class Person(models.Base):\n ...\n ... name = fields.StringField(\n ... required=True,\n ... validators=[\n ... validators.Regex('^[A-Za-z]+$'),\n ... validators.Length(3, 25),\n ... ],\n ... )\n ... age = fields.IntField(\n ... nullable=True,\n ... validators=[\n ... validators.Min(18),\n ... validators.Max(101),\n ... ]\n ... )\n ... nickname = fields.StringField(\n ... required=True,\n ... nullable=True\n ... )\n ...\n\n >>> person = Person()\n >>> person.age = 11\n >>> person.validate()\n *** ValidationError: '11' is lower than minimum ('18').\n >>> person.age = None\n >>> person.validate()\n None\n\n >>> person.age = 19\n >>> person.name = 'Scott_'\n >>> person.validate()\n *** ValidationError: Value \"Scott_\" did not match pattern \"^[A-Za-z]+$\".\n\n >>> person.name = 'Scott'\n >>> person.validate()\n None\n\n >>> person.nickname = None\n >>> person.validate()\n *** ValidationError: Field is required!\n\n >>> person.to_json_schema()\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"age\": {\n \"maximum\": 101,\n \"minimum\": 18,\n \"type\": [\"number\", \"null\"]\n },\n \"name\": {\n \"maxLength\": 25,\n \"minLength\": 3,\n \"pattern\": \"/^[A-Za-z]+$/\",\n \"type\": \"string\"\n },\n \"nickname\": {,\n \"type\": [\"string\", \"null\"]\n }\n },\n \"required\": [\n \"nickname\",\n \"name\"\n ],\n \"type\": \"object\"\n }\n\n \u60f3\u77e5\u9053\u66f4\u591a\u7684\u5185\u5bb9\u8bf7\u8bbf\u95ee\u6587\u6863.\n\n* \u5bf9\u4e8e\u5faa\u73af\u5f15\u7528,\u53ef\u4ee5\u652f\u6301\u61d2\u52a0\u8f7d:\n\n .. code-block:: python\n\n >>> class Primary(models.Base):\n ...\n ... name = fields.StringField()\n ... secondary = fields.EmbeddedField('Secondary')\n\n >>> class Secondary(models.Base):\n ...\n ... data = fields.IntField()\n ... first = fields.EmbeddedField('Primary')\n\n* \u7528\u5b9a\u4e49\u7684\u65b9\u5f0f\u4e5f\u53ef\u4ee5\u5904\u7406\u5faa\u73af\u5f15\u7528:\n\n .. code-block:: python\n\n >>> class File(models.Base):\n ...\n ... name = fields.StringField()\n ... size = fields.FloatField()\n\n >>> class Directory(models.Base):\n ...\n ... name = fields.StringField()\n ... children = fields.ListField(['Directory', File])\n\n >>> class Filesystem(models.Base):\n ...\n ... name = fields.StringField()\n ... children = fields.ListField([Directory, File])\n\n >>> Filesystem.to_json_schema()\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\"type\": \"string\"}\n \"children\": {\n \"items\": {\n \"oneOf\": [\n \"#/definitions/directory\",\n \"#/definitions/file\"\n ]\n },\n \"type\": \"array\"\n }\n },\n \"additionalProperties\": false,\n \"definitions\": {\n \"directory\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"children\": {\n \"items\": {\n \"oneOf\": [\n \"#/definitions/directory\",\n \"#/definitions/file\"\n ]\n },\n \"type\": \"array\"\n },\n \"name\": {\"type\": \"string\"}\n },\n \"type\": \"object\"\n },\n \"file\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"name\": {\"type\": \"string\"},\n \"size\": {\"type\": \"number\"}\n },\n \"type\": \"object\"\n }\n }\n }\n\n* \u6bd4\u8f83json\u5143\u6570\u636e:\n\n .. code-block:: python\n\n >>> from jsonmodels.utils import compare_schemas\n >>> schema1 = {'type': 'object'}\n >>> schema2 = {'type': 'array'}\n >>> compare_schemas(schema1, schema1)\n True\n >>> compare_schemas(schema1, schema2)\n False\n\n\u66f4\u591a\n----\n\n\u6587\u6863\u4e2d\u5df2\u7ecf\u63cf\u8ff0\u5f88\u8be6\u7ec6:\nhttp://jsonmodels.rtfd.org.\n\n\n\n\nHistory\n-------\n\n2.3 (2018-02-04)\n++++++++++++++++\n\n* Added name mapping for fields.\n* Added value parsing to IntField.\n* Fixed bug with ECMA regex flags recognition.\n\n2.2 (2017-08-21)\n++++++++++++++++\n\n* Fixed time fields, when value is not required.\n* Dropped support for python 2.6\n* Added support for python 3.6\n* Added nullable param for fields.\n* Improved model representation.\n\n2.1.5 (2017-02-01)\n++++++++++++++++++\n\n* Fixed DateTimefield error when value is None.\n* Fixed comparing models without required values.\n\n2.1.4 (2017-01-24)\n++++++++++++++++++\n\n* Allow to compare models based on their type and fields (rather than their\n reference).\n\n2.1.3 (2017-01-16)\n++++++++++++++++++\n\n* Fixed generated schema.\n* Improved JSON serialization.\n\n2.1.2 (2016-01-06)\n++++++++++++++++++\n\n* Fixed memory leak.\n\n2.1.1 (2015-11-15)\n++++++++++++++++++\n\n* Added support for Python 2.6, 3.2 and 3.5.\n\n2.1 (2015-11-02)\n++++++++++++++++\n\n* Added lazy loading of types.\n* Added schema generation for circular models.\n* Improved readability of validation error.\n* Fixed structure generation for list field.\n\n2.0.1 (2014-11-15)\n++++++++++++++++++\n\n* Fixed schema generation for primitives.\n\n2.0 (2014-11-14)\n++++++++++++++++\n\n* Fields now are descriptors.\n* Empty required fields are still validated only during explicite validations.\n\nBackward compatibility breaks\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* Renamed _types to types in fields.\n* Renamed _items_types to items_types in ListField.\n* Removed data transformers.\n* Renamed module `error` to `errors`.\n* Removed explicit validation - validation occurs at assign time.\n* Renamed `get_value_replacement` to `get_default_value`.\n* Renamed modules `utils` to `utilities`.\n\n1.4 (2014-07-22)\n++++++++++++++++\n\n* Allowed validators to modify generated schema.\n* Added validator for maximum value.\n* Added utilities to convert regular expressions between Python and ECMA\n formats.\n* Added validator for regex.\n* Added validator for minimum value.\n* By default \"validators\" property of field is an empty list.\n\n1.3.1 (2014-07-13)\n++++++++++++++++++\n\n* Fixed generation of schema for BoolField.\n\n1.3 (2014-07-13)\n++++++++++++++++\n\n* Added new fields (BoolField, TimeField, DateField and DateTimeField).\n* ListField is always not required.\n* Schema can be now generated from class itself (not from an instance).\n\n1.2 (2014-06-18)\n++++++++++++++++\n\n* Fixed values population, when value is not dictionary.\n* Added custom validators.\n* Added tool for schema comparison.\n\n1.1.1 (2014-06-07)\n++++++++++++++++++\n\n* Added possibility to populate already initialized data to EmbeddedField.\n* Added `compare_schemas` utility.\n\n1.1 (2014-05-19)\n++++++++++++++++\n\n* Added docs.\n* Added json schema generation.\n* Added tests for PEP8 and complexity.\n* Moved to Python 3.4.\n* Added PEP257 compatibility.\n* Added help text to fields.\n\n1.0.5 (2014-04-14)\n++++++++++++++++++\n\n* Added data transformers.\n\n1.0.4 (2014-04-13)\n++++++++++++++++++\n\n* List field now supports simple types.\n\n1.0.3 (2014-04-10)\n++++++++++++++++++\n\n* Fixed compatibility with Python 3.\n* Fixed `str` and `repr` methods.\n\n1.0.2 (2014-04-03)\n++++++++++++++++++\n\n* Added deep data initialization.\n\n1.0.1 (2014-04-03)\n++++++++++++++++++\n\n* Added `populate` method.\n\n1.0 (2014-04-02)\n++++++++++++++++\n\n* First stable release on PyPI.\n\n0.1.0 (2014-03-17)\n++++++++++++++++++\n\n* First release on PyPI.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitee.com/huichengip_chenxf/jsonmodels.git", "keywords": "pyjsonmodels", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pyjsonmodels", "package_url": "https://pypi.org/project/pyjsonmodels/", "platform": "", "project_url": "https://pypi.org/project/pyjsonmodels/", "project_urls": { "Homepage": "https://gitee.com/huichengip_chenxf/jsonmodels.git" }, "release_url": "https://pypi.org/project/pyjsonmodels/2.4/", "requires_dist": null, "requires_python": "", "summary": "\u65b9\u4fbf\u5904\u7406\u6a21\u578b\u8f6c\u6362\u7684\u5de5\u5177", "version": "2.4" }, "last_serial": 3650433, "releases": { "2.4": [ { "comment_text": "", "digests": { "md5": "3abd6ed1e4cd553e5ec29095b1c190ba", "sha256": "74774aa16f72b5297ccaecb4432092d2d6e36a79e386926d8fe7557ddc5ca73e" }, "downloads": -1, "filename": "pyjsonmodels-2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3abd6ed1e4cd553e5ec29095b1c190ba", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 20461, "upload_time": "2018-03-08T08:05:36", "url": "https://files.pythonhosted.org/packages/a2/02/072b4b7b26b4712a59665ee2b958d5d44e89bf1c12504e91b9b70b4ccd67/pyjsonmodels-2.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d9ee1cb7efbd97e22cd885853b7b2277", "sha256": "37e48dc7f09d4272ba2df6c308f06dd4c9771d0d8ab7d004c61f7faed0750314" }, "downloads": -1, "filename": "pyjsonmodels-2.4.tar.gz", "has_sig": false, "md5_digest": "d9ee1cb7efbd97e22cd885853b7b2277", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21205, "upload_time": "2018-03-08T08:05:31", "url": "https://files.pythonhosted.org/packages/ec/92/c42395342614aef13f575ae80b5e49892f3e7e80be5e788110ca9331a729/pyjsonmodels-2.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3abd6ed1e4cd553e5ec29095b1c190ba", "sha256": "74774aa16f72b5297ccaecb4432092d2d6e36a79e386926d8fe7557ddc5ca73e" }, "downloads": -1, "filename": "pyjsonmodels-2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3abd6ed1e4cd553e5ec29095b1c190ba", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 20461, "upload_time": "2018-03-08T08:05:36", "url": "https://files.pythonhosted.org/packages/a2/02/072b4b7b26b4712a59665ee2b958d5d44e89bf1c12504e91b9b70b4ccd67/pyjsonmodels-2.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d9ee1cb7efbd97e22cd885853b7b2277", "sha256": "37e48dc7f09d4272ba2df6c308f06dd4c9771d0d8ab7d004c61f7faed0750314" }, "downloads": -1, "filename": "pyjsonmodels-2.4.tar.gz", "has_sig": false, "md5_digest": "d9ee1cb7efbd97e22cd885853b7b2277", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21205, "upload_time": "2018-03-08T08:05:31", "url": "https://files.pythonhosted.org/packages/ec/92/c42395342614aef13f575ae80b5e49892f3e7e80be5e788110ca9331a729/pyjsonmodels-2.4.tar.gz" } ] }