{ "info": { "author": "Daniel Rodriguez", "author_email": "danjrod@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development" ], "description": "metaframe\n=========\n\n.. image:: https://img.shields.io/pypi/v/metaframe.svg\n :alt: PyPi Version\n :scale: 100%\n :target: https://pypi.python.org/pypi/metaframe/\n\n.. image:: https://img.shields.io/pypi/dm/metaframe.svg\n :alt: PyPi Monthly Donwloads\n :scale: 100%\n :target: https://pypi.python.org/pypi/metaframe/\n\n.. image:: https://img.shields.io/pypi/l/metaframe.svg\n :alt: License\n :scale: 100%\n :target: https://github.com/mementum/metaframe/blob/master/LICENSE\n\n.. image:: https://travis-ci.org/mementum/metaframe.png?branch=master\n :alt: Travis-ci Build Status\n :scale: 100%\n :target: https://travis-ci.org/mementum/metaframe\n\n.. image:: https://readthedocs.org/projects/metaframe/badge/?version=latest\n :alt: Documentation Status\n :scale: 100%\n :target: https://readthedocs.org/projects/metaframe/\n\n.. image:: https://img.shields.io/pypi/pyversions/metaframe.svg\n :alt: Pytghon versions\n :scale: 100%\n :target: https://pypi.python.org/pypi/metaframe/\n\nMetaClass infrastructure to intercept instance creation/initialization enabling\nmodification of args/kwargs and instance.\n\nDocumentation\n=============\n\nRead the full documentation at readthedocs.org:\n\n - `metaframe documentation `_\n\nPython 2/3 Support\n==================\n\n - Python 2.7\n - Python 3.2/3.3/3.4/3.5\n\n - It also works with pypy and pypy3\n\nInstallation\n============\n\n``metaframe`` is self-contained with no external dependencies\n\nFrom pypi::\n\n pip install metaframe\n\nFrom source:\n\n - Place the *metaframe* directory found in the sources inside your project\n\nFeatures:\n=========\n\n - ``MetaFrame`` metaclass to apply to any object\n - With embedded staticmethod with_metaclass to enable inheritance\n\n - ``MetaFrameBase`` class from which classes can inherit\n - 3 hooks (classmethods)\n\n - ``_new_pre``: called before object creation\n - ``_new_do``: called for object creation\n - ``_init_pre``: called after object creation / before object initialization\n - ``_init_do``: called fo object initialization\n - ``_init_post``: called after object initialization\n\nUsage:\n======\n\nA quick example which filters None and arguments which do not convert to float\nfrom the kwargs before the object is created::\n\n from metaframe import MetaFrame\n\n\n class A(MetaFrame.as_metaclass(object)):\n\n @classmethod\n def _new_do(cls, *args, **kwargs):\n\n nkwargs = dict()\n for key, val in kwargs.items():\n\n # Remove any argument with a value of None\n if val is None:\n continue\n\n try:\n val = float(val)\n except:\n continue\n\n nkwargs[key] = val\n\n # The only nuisance being the cumbersome call to _new_do\n # super doesn't work\n obj, args, kwargs = cls.__class__._new_do(cls, *args, **nkwargs)\n return obj, args, kwargs\n\n def __init__(self, **kwargs):\n for key, val in kwargs.items():\n print('key, val, type', key, val, type(val))\n\n\n a = A(p1=72, p2=None, p3='hello', p4=None, p5='72.5')\n\n\n # Now with a subclassed MetaB from MetaFrame\n # Here super can be applied to find the higher in the hierarchy _new_do\n\n class MetaB(MetaFrame):\n\n def _new_do(cls, *args, **kwargs):\n\n nkwargs = dict()\n for key, val in kwargs.items():\n\n # Remove any argument with a value of None\n if val is None:\n continue\n\n try:\n val = float(val)\n except:\n continue\n\n nkwargs[key] = val\n\n # super can be called directly\n obj, args, kwargs = super(MetaB, cls)._new_do(*args, **nkwargs)\n return obj, args, kwargs\n\n\n class B(MetaB.as_metaclass()):\n def __init__(self, **kwargs):\n for key, val in kwargs.items():\n print('key, val, type', key, val, type(val))\n\n\n b = B(p1=27, p2=None, p3='olleh', p4=None, p5='5.27')", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/mementum/metaframe/tarball/1.0.1", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mementum/metaframe", "keywords": "metaclass,development", "license": "GPLv3+", "maintainer": null, "maintainer_email": null, "name": "metaframe", "package_url": "https://pypi.org/project/metaframe/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/metaframe/", "project_urls": { "Download": "https://github.com/mementum/metaframe/tarball/1.0.1", "Homepage": "https://github.com/mementum/metaframe" }, "release_url": "https://pypi.org/project/metaframe/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "MetaClass supporting fine grained control of object creationand initialization", "version": "1.0.1" }, "last_serial": 1795428, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "d3136ef583576e05d9a8ec783e418536", "sha256": "3e2846d0cfa1a872680562df1e046ab54c96b40bf274e8fcc9039ee518fda939" }, "downloads": -1, "filename": "metaframe-1.0.0.zip", "has_sig": false, "md5_digest": "d3136ef583576e05d9a8ec783e418536", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8849, "upload_time": "2015-10-23T22:30:45", "url": "https://files.pythonhosted.org/packages/35/d1/0d778b7f5b8ae6791adb5defe0d2d379f8b59c8da5769278897ae2e235ac/metaframe-1.0.0.zip" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "b8148957beeee8537326ce340e692073", "sha256": "336c564ad36e081eb1fef896683d13ae4af2c428cf0db08432e10b000840192b" }, "downloads": -1, "filename": "metaframe-1.0.1.zip", "has_sig": false, "md5_digest": "b8148957beeee8537326ce340e692073", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10836, "upload_time": "2015-10-31T22:21:18", "url": "https://files.pythonhosted.org/packages/11/2c/c2d55ddc1dc85d60a263d8f66552dbe117c4e332f5fa594bdd0fd4918bbc/metaframe-1.0.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b8148957beeee8537326ce340e692073", "sha256": "336c564ad36e081eb1fef896683d13ae4af2c428cf0db08432e10b000840192b" }, "downloads": -1, "filename": "metaframe-1.0.1.zip", "has_sig": false, "md5_digest": "b8148957beeee8537326ce340e692073", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10836, "upload_time": "2015-10-31T22:21:18", "url": "https://files.pythonhosted.org/packages/11/2c/c2d55ddc1dc85d60a263d8f66552dbe117c4e332f5fa594bdd0fd4918bbc/metaframe-1.0.1.zip" } ] }