{ "info": { "author": "Gabe Appleton", "author_email": "gabe@gabeappleton.me", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Operating System :: OS Independent", "Programming Language :: JavaScript", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "Predecessor\n===========\n\nOverview\n--------\n\nThis set of libraries is intended to provide useful classes to inherit\nfrom, in a way that is cross compatible between multiple languages. A\nversion of this library is currently available in:\n\n- Python (2 or 3)\n- Javascript\n\nThe libraries currently provide:\n\n- singleton objects\n- serializable objects\n\nSingleton\n---------\n\nThe singleton class provides a way to ensure you only have one instance\nof a class. For instance:\n\n.. code:: python\n\n from predecessor import Singleton\n\n\n class Example(Singleton):\n def __init__(self, foo, bar):\n self.foo = foo\n self.bar = bar\n\n\n a = Example(3, 8)\n b = Example(2, 9)\n a is b # returns True\n a.foo == b.foo == 3 # returns True\n\nOr equivalently in Javascript:\n\n.. code:: javascript\n\n const Singleton = require('predecessor').Singleton;\n\n class Example extends Singleton {\n constructor(foo, bar) {\n this.foo = foo;\n this.bar = bar;\n }\n }\n\n let a = new Example(3, 8);\n let b = new Example(2, 9);\n a === b; // returns true\n a.foo === 3; // returns true\n b.foo === 3; // returns true\n\nSerializable\n------------\n\nThe singleton class provides a way to serialize a class without needing\nto care about what form the resulting blob takes. If a compatible class\ndefinition is available in all supported languages, it should be\ndeserializable in all supported languages.\n\nThe Basic Case\n~~~~~~~~~~~~~~\n\n.. code:: python\n\n from predecessor import Serializable\n\n\n class Example(Serializable):\n def __init__(self, foo, bar): # Note that keyword args are not supported\n self.foo = foo\n self.bar = bar\n\n def serialized(self):\n return super(Example, self).serialized(self.foo, self.bar)\n\n\n a = Example(3, 8)\n b = Example.deserialize(a.serialized())\n a.foo == b.foo == 3 # returns True\n a.bar == b.bar == 8 # returns True\n\nOr equivalently in Javascript:\n\n.. code:: javascript\n\n const Serializable = require('predecessor').Serializable;\n\n class Example extends Serializable {\n constructor(foo, bar) {\n this.foo = foo;\n this.bar = bar;\n }\n\n serialized() {\n return super.serialized(this.foo, this.bar);\n }\n }\n\n let a = new Example(3, 8);\n let b = Example.deserialize(a.serialized());\n a.foo === 3; // returns true\n b.foo === 3; // returns true\n a.foo === 8; // returns true\n b.foo === 8; // returns true\n\nImplied Serialization\n~~~~~~~~~~~~~~~~~~~~~\n\nIn both languages, you can also use implied serialization. This looks\nlike:\n\n.. code:: python\n\n class Example(Serializable):\n __slots__ = ('a', 'b', 'c')\n\n def __init__(self, a, b, c):\n self.a = a\n self.b = b\n self.c = c\n\n.. code:: javascript\n\n class Example extends Serializable {\n constructor(a, b, c) {\n super();\n this._slots = ['a', 'b', 'c'];\n this.a = a;\n this.b = b;\n this.c = c;\n }\n }\n\nAdvanced Recombination\n~~~~~~~~~~~~~~~~~~~~~~\n\nIn both languages you can do data processing before feeding things into\nyour constructor.\n\n.. code:: python\n\n class Example(Serializable):\n def __init__(self, a, b, c):\n self.a = a\n self.b = b\n self.c = c\n\n def serialized(self):\n return super(Example, self).serialized(self.a, self.b)\n\n @classmethod\n def recombine(cls, a, b):\n return cls(a, b, a+b)\n\n.. code:: javascript\n\n class Example extends Serializable {\n constructor(a, b, c) {\n super();\n this.a = a;\n this.b = b;\n this.c = c;\n }\n\n serialized() {\n return super.serialized(this.a, this.b);\n }\n\n static recombine(a, b) {\n return new this(a, b, a+b);\n }\n }\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/gappleto97/predecessor", "keywords": "", "license": "LGPLv3", "maintainer": "", "maintainer_email": "", "name": "predecessor", "package_url": "https://pypi.org/project/predecessor/", "platform": "", "project_url": "https://pypi.org/project/predecessor/", "project_urls": { "Homepage": "https://gitlab.com/gappleto97/predecessor" }, "release_url": "https://pypi.org/project/predecessor/0.0.3/", "requires_dist": [ "cryptography; extra == 'crypto'", "u-msgpack-python; extra == 'serialize'" ], "requires_python": "", "summary": "A set of useful python classes to inherit from", "version": "0.0.3" }, "last_serial": 3855968, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "8c893bbd7bc4aa4ffed11e9ecb30b0cd", "sha256": "f4fed84ef749dd1949525fe6484a5abeb3734d68bdfdb4b5d0db214256ed90eb" }, "downloads": -1, "filename": "predecessor-0.0.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "8c893bbd7bc4aa4ffed11e9ecb30b0cd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 2340, "upload_time": "2018-05-02T22:33:56", "url": "https://files.pythonhosted.org/packages/79/ea/d05e6308b6f983fd8ba82448ffe0b1937eca5ecc439d8a72aaf45413fbfe/predecessor-0.0.1-py2.py3-none-any.whl" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "20dcfc79fc3aa60ec736a253dc56def2", "sha256": "762988c0ca9455a782283d47e800c523a149f1e0754ec17458c88f5b3ca75618" }, "downloads": -1, "filename": "predecessor-0.0.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "20dcfc79fc3aa60ec736a253dc56def2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 1808, "upload_time": "2018-05-05T05:35:52", "url": "https://files.pythonhosted.org/packages/d0/a4/9628269cd1d19214e7a86436bf4f4648f3bbeeb64738e3ff4650c43c3d09/predecessor-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2f2e065d7a173dbc2be4ef8031cdaa0f", "sha256": "85d0cce4bf5e0bc2812d88e93f0d2ad959617533028788679b6c3fe2d0e018c8" }, "downloads": -1, "filename": "predecessor-0.0.2.tar.gz", "has_sig": true, "md5_digest": "2f2e065d7a173dbc2be4ef8031cdaa0f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1936, "upload_time": "2018-05-05T05:35:57", "url": "https://files.pythonhosted.org/packages/f0/e2/7eb9d6569ea2ac7bd2f8a0db907d233ec1baf91466017dc16b97527813bb/predecessor-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "3d9879c61268ec46246b04e949720c8e", "sha256": "7c8def70350fa26bb5f3ceb049942d6eecc902f1c0fc7b057720c2efb02e8022" }, "downloads": -1, "filename": "predecessor-0.0.3-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "3d9879c61268ec46246b04e949720c8e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4404, "upload_time": "2018-05-12T04:13:35", "url": "https://files.pythonhosted.org/packages/21/8f/7c45e1f57cd9e0d806f2df31b3d0104a890ab5430d9a6bea9d37c4554d80/predecessor-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f91a9352ad866c6a655d1d599b67c91f", "sha256": "64d5681481d56765145c0c6afde07302405dca2d34acdd71650928890a8f73b1" }, "downloads": -1, "filename": "predecessor-0.0.3.tar.gz", "has_sig": true, "md5_digest": "f91a9352ad866c6a655d1d599b67c91f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2810, "upload_time": "2018-05-12T04:13:39", "url": "https://files.pythonhosted.org/packages/58/38/79b3aa3eaa4caa654d0da932613825121a6266ba21d1ea32784a0d58e318/predecessor-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3d9879c61268ec46246b04e949720c8e", "sha256": "7c8def70350fa26bb5f3ceb049942d6eecc902f1c0fc7b057720c2efb02e8022" }, "downloads": -1, "filename": "predecessor-0.0.3-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "3d9879c61268ec46246b04e949720c8e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4404, "upload_time": "2018-05-12T04:13:35", "url": "https://files.pythonhosted.org/packages/21/8f/7c45e1f57cd9e0d806f2df31b3d0104a890ab5430d9a6bea9d37c4554d80/predecessor-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f91a9352ad866c6a655d1d599b67c91f", "sha256": "64d5681481d56765145c0c6afde07302405dca2d34acdd71650928890a8f73b1" }, "downloads": -1, "filename": "predecessor-0.0.3.tar.gz", "has_sig": true, "md5_digest": "f91a9352ad866c6a655d1d599b67c91f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2810, "upload_time": "2018-05-12T04:13:39", "url": "https://files.pythonhosted.org/packages/58/38/79b3aa3eaa4caa654d0da932613825121a6266ba21d1ea32784a0d58e318/predecessor-0.0.3.tar.gz" } ] }