{"id":13398505,"url":"https://github.com/schematics/schematics","last_synced_at":"2025-05-13T23:10:37.253Z","repository":{"id":1260779,"uuid":"1199632","full_name":"schematics/schematics","owner":"schematics","description":"Python Data Structures for Humans™.","archived":false,"fork":false,"pushed_at":"2023-07-12T06:21:13.000Z","size":2577,"stargazers_count":2585,"open_issues_count":109,"forks_count":289,"subscribers_count":62,"default_branch":"master","last_synced_at":"2024-10-29T14:58:53.345Z","etag":null,"topics":["datastructures","deserialization","python","schema","serialization","types","validation"],"latest_commit_sha":null,"homepage":"http://schematics.readthedocs.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schematics.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS"}},"created_at":"2010-12-27T02:25:29.000Z","updated_at":"2024-10-25T17:40:21.000Z","dependencies_parsed_at":"2024-01-03T00:18:00.136Z","dependency_job_id":"a49652fd-5d89-4fe4-b489-3afe3238bfce","html_url":"https://github.com/schematics/schematics","commit_stats":{"total_commits":1144,"total_committers":126,"mean_commits":9.079365079365079,"dds":0.6896853146853147,"last_synced_commit":"3a144be0aa50f68a4da917e8d957b924dedf9a52"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schematics%2Fschematics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schematics%2Fschematics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schematics%2Fschematics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schematics%2Fschematics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schematics","download_url":"https://codeload.github.com/schematics/schematics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045230,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datastructures","deserialization","python","schema","serialization","types","validation"],"created_at":"2024-07-30T19:00:27.638Z","updated_at":"2025-04-09T13:02:17.971Z","avatar_url":"https://github.com/schematics.png","language":"Python","readme":"==========\nSchematics\n==========\n\n.. rubric:: Python Data Structures for Humans™.\n\n.. image:: https://travis-ci.org/schematics/schematics.svg?branch=master\n   :target: https://travis-ci.org/schematics/schematics\n   :alt: Build Status\n\n.. image:: https://coveralls.io/repos/github/schematics/schematics/badge.svg?branch=master\n   :target: https://coveralls.io/github/schematics/schematics?branch=master \n   :alt: Coverage\n\n\nAbout\n=====\n\n**Project documentation:** https://schematics.readthedocs.io/en/latest/\n\nSchematics is a Python library to combine types into structures, validate them, and transform the shapes of your data based on simple descriptions.\n\nThe internals are similar to ORM type systems, but there is no database layer in Schematics. Instead, we believe that building a database layer is easily made when Schematics handles everything except for writing the query.\n\nSchematics can be used for tasks where having a database involved is unusual.\n\nSome common use cases:\n\n+ Design and document specific `data structures \u003chttps://schematics.readthedocs.io/en/latest/usage/models.html\u003e`_\n+ `Convert structures \u003chttps://schematics.readthedocs.io/en/latest/usage/exporting.html#converting-data\u003e`_ to and from different formats such as JSON or MsgPack\n+ `Validate \u003chttps://schematics.readthedocs.io/en/latest/usage/validation.html\u003e`_ API inputs\n+ `Remove fields based on access rights \u003chttps://schematics.readthedocs.io/en/latest/usage/exporting.html\u003e`_ of some data's recipient\n+ Define message formats for communications protocols, like an RPC\n+ Custom `persistence layers \u003chttps://schematics.readthedocs.io/en/latest/usage/models.html#model-configuration\u003e`_\n\n\nExample\n=======\n\nThis is a simple Model. \n\n.. code:: python\n\n  \u003e\u003e\u003e from schematics.models import Model\n  \u003e\u003e\u003e from schematics.types import StringType, URLType\n  \u003e\u003e\u003e class Person(Model):\n  ...     name = StringType(required=True)\n  ...     website = URLType()\n  ...\n  \u003e\u003e\u003e person = Person({'name': u'Joe Strummer',\n  ...                  'website': 'http://soundcloud.com/joestrummer'})\n  \u003e\u003e\u003e person.name\n  u'Joe Strummer'\n\nSerializing the data to JSON.\n\n.. code:: python\n\n  \u003e\u003e\u003e import json\n  \u003e\u003e\u003e json.dumps(person.to_primitive())\n  {\"name\": \"Joe Strummer\", \"website\": \"http://soundcloud.com/joestrummer\"}\n\nLet's try validating without a name value, since it's required.\n\n.. code:: python\n\n  \u003e\u003e\u003e person = Person()\n  \u003e\u003e\u003e person.website = 'http://www.amontobin.com/'\n  \u003e\u003e\u003e person.validate()\n  Traceback (most recent call last):\n    File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n    File \"schematics/models.py\", line 231, in validate\n      raise DataError(e.messages)\n  schematics.exceptions.DataError: {'name': ['This field is required.']}\n\nAdd the field and validation passes.\n\n.. code:: python\n\n  \u003e\u003e\u003e person = Person()\n  \u003e\u003e\u003e person.name = 'Amon Tobin'\n  \u003e\u003e\u003e person.website = 'http://www.amontobin.com/'\n  \u003e\u003e\u003e person.validate()\n  \u003e\u003e\u003e\n\n\n.. _coverage:\n\nTesting \u0026 Coverage support\n==========================\n\nRun coverage and check the missing statements. ::\n\n  $ coverage run --source schematics -m py.test \u0026\u0026 coverage report\n\n","funding_links":[],"categories":["Data Validation","Python","资源列表","数据验证","python","Libraries in Python","Model, Schema","Data Validation [🔝](#readme)","Awesome Python"],"sub_categories":["数据验证","Data Validation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschematics%2Fschematics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschematics%2Fschematics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschematics%2Fschematics/lists"}