registrable


Nameregistrable JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/epwalsh/python-registrable
SummaryPython module for registering and instantiating classes by name. Based on the implementation from AllenNLP.
upload_time2019-12-04 18:12:35
maintainer
docs_urlNone
authorEvan Pete Walsh
requires_python>=3.6.1
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-registrable

[![CircleCI](https://circleci.com/gh/epwalsh/python-registrable.svg?style=svg)](https://circleci.com/gh/epwalsh/python-registrable)
[![License](https://img.shields.io/github/license/epwalsh/python-registrable)](https://github.com/epwalsh/python-registrable/blob/master/LICENSE)
[![PyPI version](https://badge.fury.io/py/registrable.svg)](https://pypi.org/project/registrable/)
[![Documentation Status](https://readthedocs.org/projects/python-registrable/badge/?version=latest)](https://python-registrable.readthedocs.io/en/latest/?badge=latest)

Python module for registering and instantiating classes by name. Based on the implementation from [AllenNLP](https://github.com/allenai/allennlp).


## Installing

The quickest way to install is through PyPI.

```
pip install registrable
```

## Usage

```python
from registrable import Registrable

# Create a base class that inherits from `Registrable`.
class MyBaseClass(Registrable):
    def do_something(self):
        raise NotImplementedError


# Now register subclass implementations of your base class.
@MyBaseClass.register("first_implementation")
class FirstImplementation(MyBaseClass):
    def do_something(self):
        return 1


# You can access an implementation by calling `.by_name()` on the base class.
subclass = MyBaseClass.by_name("first_implementation")
instance = subclass()
assert instance.do_something() == 1
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/epwalsh/python-registrable",
    "name": "registrable",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.1",
    "maintainer_email": "",
    "keywords": "",
    "author": "Evan Pete Walsh",
    "author_email": "epwalsh10@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ba/57/e7a9c28426a7bcd411a77885a633de468430f1f479c043deb1254ba1da02/registrable-0.0.4.tar.gz",
    "platform": "",
    "description": "# python-registrable\n\n[![CircleCI](https://circleci.com/gh/epwalsh/python-registrable.svg?style=svg)](https://circleci.com/gh/epwalsh/python-registrable)\n[![License](https://img.shields.io/github/license/epwalsh/python-registrable)](https://github.com/epwalsh/python-registrable/blob/master/LICENSE)\n[![PyPI version](https://badge.fury.io/py/registrable.svg)](https://pypi.org/project/registrable/)\n[![Documentation Status](https://readthedocs.org/projects/python-registrable/badge/?version=latest)](https://python-registrable.readthedocs.io/en/latest/?badge=latest)\n\nPython module for registering and instantiating classes by name. Based on the implementation from [AllenNLP](https://github.com/allenai/allennlp).\n\n\n## Installing\n\nThe quickest way to install is through PyPI.\n\n```\npip install registrable\n```\n\n## Usage\n\n```python\nfrom registrable import Registrable\n\n# Create a base class that inherits from `Registrable`.\nclass MyBaseClass(Registrable):\n    def do_something(self):\n        raise NotImplementedError\n\n\n# Now register subclass implementations of your base class.\n@MyBaseClass.register(\"first_implementation\")\nclass FirstImplementation(MyBaseClass):\n    def do_something(self):\n        return 1\n\n\n# You can access an implementation by calling `.by_name()` on the base class.\nsubclass = MyBaseClass.by_name(\"first_implementation\")\ninstance = subclass()\nassert instance.do_something() == 1\n```\n\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Python module for registering and instantiating classes by name. Based on the implementation from AllenNLP.",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/epwalsh/python-registrable"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a476370d9389664f1af31de4048934faeb681035a079ddc3d284a366875e755",
                "md5": "de406b3068d4ad68dd85639c3ef025e2",
                "sha256": "475ec762101c50942f59d15256646162c497e91e6ecd1442ad9b34ada113f73c"
            },
            "downloads": -1,
            "filename": "registrable-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de406b3068d4ad68dd85639c3ef025e2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6.1",
            "size": 9904,
            "upload_time": "2019-12-04T18:12:34",
            "upload_time_iso_8601": "2019-12-04T18:12:34.398192Z",
            "url": "https://files.pythonhosted.org/packages/8a/47/6370d9389664f1af31de4048934faeb681035a079ddc3d284a366875e755/registrable-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ba57e7a9c28426a7bcd411a77885a633de468430f1f479c043deb1254ba1da02",
                "md5": "128dedc4aec86abd7ab2be75dc6e2148",
                "sha256": "20bb42aeeab062432f053a788c775106e45a2fab1fdae4103df45e465086d0a3"
            },
            "downloads": -1,
            "filename": "registrable-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "128dedc4aec86abd7ab2be75dc6e2148",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.1",
            "size": 4942,
            "upload_time": "2019-12-04T18:12:35",
            "upload_time_iso_8601": "2019-12-04T18:12:35.941551Z",
            "url": "https://files.pythonhosted.org/packages/ba/57/e7a9c28426a7bcd411a77885a633de468430f1f479c043deb1254ba1da02/registrable-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-12-04 18:12:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "epwalsh",
    "github_project": "python-registrable",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "requirements": [],
    "lcname": "registrable"
}
        
Elapsed time: 0.33353s