{"id":13770580,"url":"https://github.com/hearsaycorp/normalize","last_synced_at":"2025-03-22T09:12:43.492Z","repository":{"id":14088417,"uuid":"16792286","full_name":"hearsaycorp/normalize","owner":"hearsaycorp","description":"A toolkit for wrapping network data in Python objects","archived":false,"fork":false,"pushed_at":"2024-09-19T08:21:59.000Z","size":2193,"stargazers_count":14,"open_issues_count":6,"forks_count":35,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-14T11:08:56.653Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hearsaycorp.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-13T04:55:26.000Z","updated_at":"2025-02-10T03:59:43.000Z","dependencies_parsed_at":"2022-09-26T20:01:45.306Z","dependency_job_id":"a6d68d88-3274-4331-8fae-f937fb90be8f","html_url":"https://github.com/hearsaycorp/normalize","commit_stats":{"total_commits":391,"total_committers":17,"mean_commits":23.0,"dds":0.1457800511508951,"last_synced_commit":"022eb70e3fcdf102224b38e149ac19feb7f443b4"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hearsaycorp%2Fnormalize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hearsaycorp%2Fnormalize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hearsaycorp%2Fnormalize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hearsaycorp%2Fnormalize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hearsaycorp","download_url":"https://codeload.github.com/hearsaycorp/normalize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244931628,"owners_count":20534012,"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":[],"created_at":"2024-08-03T17:00:39.420Z","updated_at":"2025-03-22T09:12:43.473Z","avatar_url":"https://github.com/hearsaycorp.png","language":"Python","readme":"\nNormalize\n=========\n\nThe normalize package is a class builder and toolkit most useful for\nwriting \"plain old data structures\" to wrap data from network sources\nin python objects.\n\nIt is called \"normalize\", because it is focused on the first normal\nform of relational database modelling.\nThis is the simplest and most straightforward level which defines what\nare normally called \"records\" (or *rows*).\nA record is a defined collection of properties/attributes (*columns*),\nwhere you know roughly what to expect in each property/attribute, and\ncan access them by some kind of descriptor (i.e., the attribute name).\nYou can also use it as a general purpose declarative meta-programming\nframework, as it ships with an official meta-object-protocol (MOP) API\nto describe this information, built on top of python's notion of\nclasses/types and descriptors and extended where necessary.\n\nPut simply, you write python classes to describe your assumptions\nabout the data structures you're dealing with, feed in input data and\nyou get regular python objects back which have attributes which you\ncan use naturally.\nOr, you get an error and find you have to revisit your assumptions.\nYou can then perform basic operations with the objects, such as make\nchanges to them and convert them back, or compare them to another\nversion using the rich comparison API.\nYou can also construct the objects 'natively' using regular python\nkeyword/value constructors or by passing a ``dict`` as the first\nargument.\n\nIt is very similar in scope to the ``remoteobjects`` and\n``schematics`` packages on PyPI, and may in time evolve to include all\nthe features of those packages.\n\nWhile there is some notion of primary keys in the module, mainly for\nthe purposes of recognizing objects in collections for comparison,\nhigher levels of normalization are an exercise left to the\nimplementer.\n\n\nFeatures\n--------\n\n* declarative API, which may optionally contain direct marshaling\n  hints:\n\n  ::\n\n      class Star(Record):\n          id = Property(isa=int, required=True)\n          name = Property(isa=str)\n          other_names = Property(json_name=\"otherNames\")\n\n  Type descriptions (``isa=``) are completely optional, but if given\n  will be use for type checking and coercion.\n\n* rich descriptor API (in ``normalize.property``), including the\n  notions of not just 'required' and 'isa' type hints as shown above\n  but also default functions, custom-type check functions, and\n  coercion functions.\n\n  It also sports an extensible attribute trait system, which adds more\n  features via optional Property sub-classes, selected automatically,\n  enabling:\n\n  * lazy attributes which short-cut at the python core level once\n    calculated (a somewhat underused python feature)\n\n  * read-only attributes\n\n  * type-safe attributes (i.e., that type-check on assign)\n\n  * collection attributes (see below)\n\n* coercion from regular python dictionaries or ``key=value``\n  (*kwargs*) constructor arguments\n\n* conversion to and from JSON for all classes, regardless of whether\n  they derive ``normalize.record.json.JsonRecord``.  Support for custom\n  functions for JSON marshal in and out.\n\n* conversion to primitive python types via the pickle API\n  (``__getnewargs__``)\n\n* **New in 0.5**: generic mechanism for marshalling to and from other\n  other forms.  See the documentation for the new\n  ``normalize.visitor.VisitorPattern`` API.\n\n* typed collections with item coercion (currently lists and dicts only):\n\n  ::\n\n      class StarSystem(Record):\n          components = ListProperty(Star)\n\n      alpha_centauri = StarSystem(\n          components=[{id=70890, name=\"Proxima Centauri\"},\n                      {id=71683, name=\"Alpha Centauri A\"},\n                      {id=71681, name=\"Alpha Centauri B\"}]\n      )\n\n* \"field selector\" API which allows for specification of properties\n  deep into nested data structures;\n\n  ::\n\n      name_selector = FieldSelector(\"components\", 0, \"name\")\n      print name_selector.get(alpha_centauri)  # \"Proxima Centauri\"\n\n* comparison API which returns differences between two Records of\n  matching types.  Ability to mark properties as \"extraneous\" to skip\n  comparison (this also affects the ``==`` operator)\n\n* ...and much more!\n\n\n============\nContributing\n============\n\n#. Fork the repo from `GitHub \u003chttps://github.com/hearsaycorp/normalize\u003e`_.\n#. Make your changes.\n#. Add unittests for your changes.\n#. Run `pep8 \u003chttps://pypi.python.org/pypi/pep8\u003e`_, `pyflakes \u003chttps://pypi.python.org/pypi/pyflakes\u003e`_, and `pylint \u003chttps://pypi.python.org/pypi/pyflakes\u003e`_ to make sure your changes follow the Python style guide and doesn't have any errors.\n#. Commit.  Please write a commit message which explains the use case; see the commit log for examples.\n#. Add yourself to the AUTHORS file (in alphabetical order).\n#. Send a pull request from your fork to the main repo.\n","funding_links":[],"categories":["Model, Schema"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhearsaycorp%2Fnormalize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhearsaycorp%2Fnormalize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhearsaycorp%2Fnormalize/lists"}