{ "info": { "author": "Sanhe Hu", "author_email": "husanhe@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": ".. image:: https://travis-ci.org/MacHu-GWU/attrs_mate-project.svg?branch=master\n :target: https://travis-ci.org/MacHu-GWU/attrs_mate-project?branch=master\n\n.. image:: https://codecov.io/gh/MacHu-GWU/attrs_mate-project/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/MacHu-GWU/attrs_mate-project\n\n.. image:: https://img.shields.io/pypi/v/attrs_mate.svg\n :target: https://pypi.python.org/pypi/attrs_mate\n\n.. image:: https://img.shields.io/pypi/l/attrs_mate.svg\n :target: https://pypi.python.org/pypi/attrs_mate\n\n.. image:: https://img.shields.io/pypi/pyversions/attrs_mate.svg\n :target: https://pypi.python.org/pypi/attrs_mate\n\n.. image:: https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social\n :target: https://github.com/MacHu-GWU/attrs_mate-project\n\n------\n\n\n.. image:: https://img.shields.io/badge/Link-Document-blue.svg\n :target: https://attrs_mate.readthedocs.io/index.html\n\n.. image:: https://img.shields.io/badge/Link-API-blue.svg\n :target: https://attrs_mate.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Source_Code-blue.svg\n :target: https://attrs_mate.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Install-blue.svg\n :target: `install`_\n\n.. image:: https://img.shields.io/badge/Link-GitHub-blue.svg\n :target: https://github.com/MacHu-GWU/attrs_mate-project\n\n.. image:: https://img.shields.io/badge/Link-Submit_Issue-blue.svg\n :target: https://github.com/MacHu-GWU/attrs_mate-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Request_Feature-blue.svg\n :target: https://github.com/MacHu-GWU/attrs_mate-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Download-blue.svg\n :target: https://pypi.org/pypi/attrs_mate#files\n\n\nWelcome to ``attrs_mate`` Documentation\n==============================================================================\n\n`attrs `_ might be the second widely used python library for developers (First is ``requests``). It is the ultimate weapon for writing class.\n\n``attrs_mate`` aims to bring more features to ``attrs``, less code, and better code pattern.\n\n\nUsage1: More Utility Methods\n------------------------------------------------------------------------------\n\n.. code-block:: python\n\n from attrs_mate import attr, AttrsClass\n\n @attr.s\n class User(AttrsClass):\n id = attr.ib()\n name = attr.ib()\n\n user = User(id=1, name=\"Alice\")\n user.keys() # [\"id\", \"name\"]\n user.values() # [1, \"Alice\"]\n user.items() # [(\"id\", 1), (\"name\": \"Alice\")]\n user.to_dict() # {\"id\": 1, \"name\": \"Alice\"}\n user.to_OrderedDict() # OrderedDict([(\"id\", 1), (\"name\": \"Alice\")])\n\n\nUsage2: Allow attrs to construct complex object from dict data.\n------------------------------------------------------------------------------\n\n**Plus, this is an example of nesting schema**.\n\n.. code-block:: python\n\n import attr\n from attrs_mate import AttrsClass\n\n\n @attr.s\n class Profile(AttrsClass):\n \"\"\"\n firstname, lastname, ssn are generic data type field.\n \"\"\"\n firstname = AttrsClass.ib_str() # default String Validator\n lastname = AttrsClass.ib_str()\n ssn = AttrsClass.ib_str()\n\n\n @attr.s\n class Degree(AttrsClass):\n name = AttrsClass.ib_str()\n year = AttrsClass.ib_int() # default Integer Validator\n\n\n @attr.s\n class People(AttrsClass):\n \"\"\"\n - ``profile`` is nested field.\n - ``degrees`` is collection type field.\n \"\"\"\n id = AttrsClass.ib_int()\n profile = Profile.ib_nested() # default Nested Schema Validator and Converter\n degrees = Degree.ib_list() # default Nested Schema Validator and Converter\n\n >>> people = People(\n id=1,\n profile=Profile(\n firstname=\"David\",\n lastname=\"John\",\n ssn=\"123-45-6789\",\n ),\n degrees=[\n Degree(name=\"Bachelor\", year=2004),\n Degree(name=\"Master\", year=2006),\n ],\n )\n\n >>> people_data = people.to_dict()\n >>> people_data\n {\n 'id': 1,\n 'profile': {\n 'lastname': 'John', 'ssn': '123-45-6789', 'firstname': 'David'\n },\n 'degrees': [\n {'name': 'Bachelor', 'year': 2004},\n {'name': 'Master', 'year': 2006}\n ]\n }\n\n >>> people = People.from_dict(people_data)\n >>> people\n People(id=1, profile=Profile(firstname='David', lastname='John', ssn='123-45-6789'), degrees=[Degree(name='Bachelor', year=2004), Degree(name='Master', year=2006)])\n\nOr you can just pass nested schema in dictionary, it works the same:\n\n.. code-block:: python\n\n >>> people = People(\n id=1,\n profile=dict(\n firstname=\"David\",\n lastname=\"John\",\n ssn=\"123-45-6789\",\n ),\n degrees=[\n dict(name=\"Bachelor\", year=2004),\n dict(name=\"Master\", year=2006),\n ],\n )\n\n\nUsage3: Cached Instance and Property Attribute\n------------------------------------------------------------------------------\n\n.. code-block:: python\n\n from attrs_mate import attr, LazyClass\n\n @attr.s\n class User(LazyClass): # instance are cached\n id = attr.ib()\n lastname = attr.ib()\n firstname = attr.ib()\n uuid_called_count = attr.ib(default=0)\n fullname_called_count = attr.ib(default=0)\n\n @LazyClass.lazyproperty\n def uuid(self):\n self.uuid_called_count += 1\n return self.id\n\n @LazyClass.lazyproperty\n def fullname(self): # property method are cached\n self.fullname_called_count += 1\n return \"{} {}\".format(self.lastname, self.firstname)\n\n >>> user1 = User.lazymake(id=1, lastname=\"David\", firstname=\"John\")\n >>> user1.fullname_called_count\n 0 # initially, fullname never been called\n >>> user1.fullname\n David John\n >>> user1.fullname_called_count\n 1 # called once\n >>> user1.fullname\n David John\n >>> user1.fullname_called_count\n 1 # User.fullname() not been called\n\n # use factory method to create new instance\n >>> user2 = User.lazymake(id=1, lastname=\"David\", firstname=\"Kim\")\n >>> id(user1) == id(user2)\n True # since\n >>> user2.firstname == \"John\"\n True\n >>> user2.fullname_called_count\n 1 # already been called once, because it is actually user1\n\n\n.. _install:\n\nInstall\n------------------------------------------------------------------------------\n\n``attrs_mate`` is released on PyPI, so all you need is:\n\n.. code-block:: console\n\n $ pip install attrs_mate\n\nTo upgrade to latest version:\n\n.. code-block:: console\n\n $ pip install --upgrade attrs_mate\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://pypi.python.org/pypi/attrs_mate/0.0.5#downloads", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/MacHu-GWU/", "keywords": "", "license": "MIT", "maintainer": "Sanhe Hu", "maintainer_email": "husanhe@gmail.com", "name": "attrs-mate", "package_url": "https://pypi.org/project/attrs-mate/", "platform": "Windows", "project_url": "https://pypi.org/project/attrs-mate/", "project_urls": { "Download": "https://pypi.python.org/pypi/attrs_mate/0.0.5#downloads", "Homepage": "https://github.com/MacHu-GWU/" }, "release_url": "https://pypi.org/project/attrs-mate/0.0.5/", "requires_dist": [ "attrs (>=19.1.0)" ], "requires_python": "", "summary": "A plugin extends power of attrs library.", "version": "0.0.5" }, "last_serial": 5723121, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "79d1561ddffad213890d6752f9a24633", "sha256": "ab9dc1aea5c63b379910be2a185a6fff37a1d65917a7ebf2eb49e57c0c05dd55" }, "downloads": -1, "filename": "attrs_mate-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "79d1561ddffad213890d6752f9a24633", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 5639, "upload_time": "2017-10-10T21:34:50", "url": "https://files.pythonhosted.org/packages/c9/52/e6ad39a34a47f85be2653bf6a266e803c70f966181d869f6828fb580296e/attrs_mate-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "322a3905360e8a1cdc6b0d2d0ce23ae4", "sha256": "0289f1f9c659ba70edbab822d593eab392309287c20325434d11cb21e1d54adb" }, "downloads": -1, "filename": "attrs_mate-0.0.1.tar.gz", "has_sig": false, "md5_digest": "322a3905360e8a1cdc6b0d2d0ce23ae4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5778, "upload_time": "2017-10-10T21:34:55", "url": "https://files.pythonhosted.org/packages/95/c0/b77d214eb0f89dd5efb5811565fd96a9b060e3aa040312657caec174044f/attrs_mate-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "046f822d0983eb39f1c25d0b6adf9978", "sha256": "124528d2a869d8179529c0f1fed8009531ca6025afc700a3571990ff3fe8d54f" }, "downloads": -1, "filename": "attrs_mate-0.0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "046f822d0983eb39f1c25d0b6adf9978", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9904, "upload_time": "2018-09-06T01:14:37", "url": "https://files.pythonhosted.org/packages/88/fb/bb6360762eb6138c219af0ea95b851a238574c17d3ec1d4d3e420ae09f18/attrs_mate-0.0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1481d54c8ca13a887c4bbcc2a687cd4e", "sha256": "d364e5305b0bd399c663d8ad8248ef4e47dda6bf2239aefdc553878d530a78b1" }, "downloads": -1, "filename": "attrs_mate-0.0.2.tar.gz", "has_sig": false, "md5_digest": "1481d54c8ca13a887c4bbcc2a687cd4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9736, "upload_time": "2018-09-06T01:14:38", "url": "https://files.pythonhosted.org/packages/3c/2a/2319d9e6d9d72ed3bfdec6dcf2948d6109b11eee1ecf276bff7b6416cefb/attrs_mate-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "7b1c6a3255e80ecd195d5777c78bc4b3", "sha256": "2c74315ad1e9aba86cc5290a73887fe16c1ea437173a4d31068fb134408854c9" }, "downloads": -1, "filename": "attrs_mate-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7b1c6a3255e80ecd195d5777c78bc4b3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18792, "upload_time": "2019-01-24T04:24:36", "url": "https://files.pythonhosted.org/packages/7d/cc/a85201c761656f208d9098b316a730b356430204877db1445445f4599f29/attrs_mate-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "392976fc5bf0f902c5e1fd81bb8eaea5", "sha256": "b68031c43aa5e6e6b3b54ac9492d3d566f2c78069d35e10861ce91806c1d31ee" }, "downloads": -1, "filename": "attrs_mate-0.0.3.tar.gz", "has_sig": false, "md5_digest": "392976fc5bf0f902c5e1fd81bb8eaea5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14185, "upload_time": "2019-01-24T04:24:38", "url": "https://files.pythonhosted.org/packages/fa/d3/7c35c5227fcc92d45764d71715d6cf3d860d2e708dcc8731516e17eeb23a/attrs_mate-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "4570cff5b39a807e849d236894023b7a", "sha256": "3558d04ffd69ddaf5a569472411d7c52830ba962b5aec746833e97871175f6d1" }, "downloads": -1, "filename": "attrs_mate-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4570cff5b39a807e849d236894023b7a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18862, "upload_time": "2019-02-07T16:45:15", "url": "https://files.pythonhosted.org/packages/fb/ff/101cbf5f119997198d4c88028eee7e379487972618b875541f174ed9f028/attrs_mate-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "34c75ace28f9d546c8810684141bfebe", "sha256": "bfce0f2fcd7d59524791da1496f2dfbb009ee07eb68a373971a46d69810be21c" }, "downloads": -1, "filename": "attrs_mate-0.0.4.tar.gz", "has_sig": false, "md5_digest": "34c75ace28f9d546c8810684141bfebe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14309, "upload_time": "2019-02-07T16:45:17", "url": "https://files.pythonhosted.org/packages/f5/49/4f4812ed981295cebf7efdd3348974571db13dd3c11bf921b9e7a58b27cf/attrs_mate-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "70e8df183952da4be67637de5fdb1cf1", "sha256": "adeed047a37b27f95a6f4463a975a22ec0e41c2efef7aa84e6cf16aed4113e7f" }, "downloads": -1, "filename": "attrs_mate-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "70e8df183952da4be67637de5fdb1cf1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22227, "upload_time": "2019-08-23T23:08:11", "url": "https://files.pythonhosted.org/packages/94/0c/8facaffb0eb29d066577e504d60f6dd97e87046fc21487e09569553b3089/attrs_mate-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ab13550230f6128a1bed4e44473fc79b", "sha256": "99850384674726be45a26e4cfcc1932aac7a4555b8f1254ece387958f6c5c416" }, "downloads": -1, "filename": "attrs_mate-0.0.5.tar.gz", "has_sig": false, "md5_digest": "ab13550230f6128a1bed4e44473fc79b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16523, "upload_time": "2019-08-23T23:08:12", "url": "https://files.pythonhosted.org/packages/9f/6f/662246d2108eb8b3d5a5ef6cc84f4de11da116661f159bceeb95d3aee034/attrs_mate-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "70e8df183952da4be67637de5fdb1cf1", "sha256": "adeed047a37b27f95a6f4463a975a22ec0e41c2efef7aa84e6cf16aed4113e7f" }, "downloads": -1, "filename": "attrs_mate-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "70e8df183952da4be67637de5fdb1cf1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22227, "upload_time": "2019-08-23T23:08:11", "url": "https://files.pythonhosted.org/packages/94/0c/8facaffb0eb29d066577e504d60f6dd97e87046fc21487e09569553b3089/attrs_mate-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ab13550230f6128a1bed4e44473fc79b", "sha256": "99850384674726be45a26e4cfcc1932aac7a4555b8f1254ece387958f6c5c416" }, "downloads": -1, "filename": "attrs_mate-0.0.5.tar.gz", "has_sig": false, "md5_digest": "ab13550230f6128a1bed4e44473fc79b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16523, "upload_time": "2019-08-23T23:08:12", "url": "https://files.pythonhosted.org/packages/9f/6f/662246d2108eb8b3d5a5ef6cc84f4de11da116661f159bceeb95d3aee034/attrs_mate-0.0.5.tar.gz" } ] }