{ "info": { "author": "Frank Niessink", "author_email": "frank@niessink.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development" ], "description": "# Access modifiers for Python\n\n[![Build Status](https://travis-ci.com/fniessink/access-modifiers.svg?branch=master)](https://travis-ci.com/fniessink/access-modifiers)\n[![PyPI](https://img.shields.io/pypi/v/access-modifiers.svg)](https://pypi.python.org/pypi/access-modifiers)\n\nThis package provides two access modifiers for Python: private methods and protected methods. The goal is to be able to document methods as being private or protected and to provide basic guards against accidentally calling private and protected methods from outside the allowed scopes.\n\n## How to use\n\nExample usage of private methods:\n\n```python\nfrom access_modifiers import privatemethod\n\nclass Class:\n @privatemethod\n def private_method(self) -> str:\n return \"private method\"\n\n def public_method(self) -> str:\n return \"public method calls \" + self.private_method()\n\nc = Class()\nprint(c.public_method()) # Prints \"public method calls private method\"\nprint(c.private_method()) # Raises an exception\n```\n\nExample usage of protected methods:\n\n```python\nfrom access_modifiers import protectedmethod\n\nclass Class:\n @protectedmethod\n def protected_method(self) -> str:\n return \"protected method\"\n\n def public_method(self) -> str:\n return \"public method calls \" + self.protected_method()\n\n\nclass Subclass(Class):\n @protectedmethod\n def protected_method(self) -> str:\n return \"overridden protected method calls \" + super().protected_method()\n\nc = Subclass()\nprint(c.public_method()) # Prints \"public method calls overridden protected method calls protected method\"\nprint(c.protected_method()) # Raises an exception\n```\n\nPrivate methods can be combined with static methods. Note that the order matters: staticmethod should be the outermost decorator.\n\n```python\nfrom access_modifiers import privatemethod\n\nclass Class:\n @staticmethod\n @privatemethod\n def static_private_method() -> str:\n return \"static private method\"\n\n def public_method(self) -> str:\n return \"public method calls \" + self.static_private_method()\n\nc = Class()\nprint(c.public_method()) # Prints \"public method calls static private method\"\nprint(c.static_private_method()) # Raises an exception\n```\n\nCombining protected methods with static methods is not supported. Combining access modifiers with class methods is not supported (yet).\n\n## Performance\n\nThe access modifier decorators work by looking at the code that is calling the decorator to decide whether it is allowed to call the method. To do so, the decorators use implementation details of CPython, like sys._getframe() and the names of code objects such as lambdas and modules. These checks are done on each method call. Consequently, there is a considerable performance impact. Therefore it's recommended to use the access modifiers during testing and turn them off in production using the `access_modifiers.disable()` method. Note that you need to call this method before any of the access modifier decorators are evaluated, i.e.:\n\n```python\nfrom access_modifiers import disable, privatemethod\n\ndisable() # This will disable the access checks\n\nclass Class:\n @privatemethod\n def private_method(self) -> str:\n return \"private_method\"\n\ndisable() # Calling disable here will not work, Class.private_method has already been wrapped\n```\n\n## Installation\n\nThe package is available from the Python Package Index, install with `pip install access-modifiers`.\n\n## Development \n\nTo clone the repository: `git clone git@github.com:fniessink/access-modifiers.git`.\n\nTo install the development dependencies: `pip install -r requirements-dev.txt`.\n\nTo run the unittests and measure the coverage (which should always be at 100%): `ci/unittest.sh`.\n\nTo run Pylint (which should score a 10) and Mypy (which shouldn't complain): `ci/quality.sh`.\n\nThe implementation is driven by (unit) tests and has 100% unit test statement and branch coverage. Please look at the tests to see which usage scenario's are currently covered.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fniessink/access-modifiers", "keywords": "access modifier,protected,private,oop", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "access-modifiers", "package_url": "https://pypi.org/project/access-modifiers/", "platform": "", "project_url": "https://pypi.org/project/access-modifiers/", "project_urls": { "Homepage": "https://github.com/fniessink/access-modifiers" }, "release_url": "https://pypi.org/project/access-modifiers/0.3.1/", "requires_dist": null, "requires_python": "", "summary": "Private and protected access modifiers for Python", "version": "0.3.1" }, "last_serial": 5736344, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "0556f38c05d0528e7e3f5d00c987d727", "sha256": "403449ce36d6618c0e192f066e89d777097db46acb4c539f2b0db80d38c65044" }, "downloads": -1, "filename": "access_modifiers-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "0556f38c05d0528e7e3f5d00c987d727", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9307, "upload_time": "2019-08-24T10:32:22", "url": "https://files.pythonhosted.org/packages/33/fe/47a998a8d8b051cb644dad6adb47b30fd278e5286d0b368c8fcff4eed412/access_modifiers-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9d24bd6c9ce021b2e6315bc7bf78073f", "sha256": "d26248e3c6f1f3152ea9b2e8714257478797c4ca45f48208bdcbb13f27dec7bf" }, "downloads": -1, "filename": "access_modifiers-0.1.0.tar.gz", "has_sig": false, "md5_digest": "9d24bd6c9ce021b2e6315bc7bf78073f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3686, "upload_time": "2019-08-24T10:32:24", "url": "https://files.pythonhosted.org/packages/7d/6e/75fb94ed3b95705084d7f5ff814df716ab567af55bd890800a7f4b7e592e/access_modifiers-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "83bdd83fa0df8b7edbe4364ad9c35557", "sha256": "4ce204306ae333ce0bc4ccad641173406c6f3a82cdb604edb8170e69345cb985" }, "downloads": -1, "filename": "access_modifiers-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "83bdd83fa0df8b7edbe4364ad9c35557", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9406, "upload_time": "2019-08-24T13:39:38", "url": "https://files.pythonhosted.org/packages/52/49/3538d6f045d5c817521090fcf091f20c8af6fbf9c47781097e34169bbfa3/access_modifiers-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a72035736771281c1c9380135533b80f", "sha256": "0de1f2ce9d8cf0a2d6114913b494ac534506c2da7683eb2fbcc868e29f0f33d9" }, "downloads": -1, "filename": "access_modifiers-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a72035736771281c1c9380135533b80f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3923, "upload_time": "2019-08-24T13:39:39", "url": "https://files.pythonhosted.org/packages/57/40/fd089484776a23803d2d6ebe8a4dfb0f4e2544805c2f5bd5e2d7f9332629/access_modifiers-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "ea23e41baa9849d3a10d12a9e925513d", "sha256": "deda2e45e9f60ea9aafb4c6d21b69438216327cdf6ea05ec59f334af4db29435" }, "downloads": -1, "filename": "access_modifiers-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "ea23e41baa9849d3a10d12a9e925513d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10043, "upload_time": "2019-08-24T16:06:01", "url": "https://files.pythonhosted.org/packages/a1/55/5bd3499bcd3b97601e5dc7b0f036977ccd658d353042188c719a02dec008/access_modifiers-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f1cc3896c830f6a75b7131425a7b85c6", "sha256": "f4ef736e186cb89261fe5a2fc46a997dd291b2352fb510cb09fd2fab3778f8c0" }, "downloads": -1, "filename": "access_modifiers-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f1cc3896c830f6a75b7131425a7b85c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4234, "upload_time": "2019-08-24T16:06:02", "url": "https://files.pythonhosted.org/packages/e4/c3/05108352936e05772e8bf4dce16e4d5cd19e9f94652bffdbb085dc6cb259/access_modifiers-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "d96cc4d036855598fa195337d1e562c2", "sha256": "25fe08fc1cf1d095eb61e0d65faf7b521b63ee9b1dfa5924cd35fa41012ca99b" }, "downloads": -1, "filename": "access_modifiers-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d96cc4d036855598fa195337d1e562c2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10056, "upload_time": "2019-08-24T18:25:49", "url": "https://files.pythonhosted.org/packages/ff/bd/7205bd7926fd4e750e2e22e32fa75da2877c8d94342eb9c98741c0ab6d27/access_modifiers-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7897c30cebdfbc5f5568db285de6e1bb", "sha256": "8ed2f5a433e4cc5ff3be0b59eea398edba9c70e5a9bbb57ce34b04628f0db18b" }, "downloads": -1, "filename": "access_modifiers-0.1.3.tar.gz", "has_sig": false, "md5_digest": "7897c30cebdfbc5f5568db285de6e1bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4255, "upload_time": "2019-08-24T18:25:50", "url": "https://files.pythonhosted.org/packages/9e/60/9912f2c73c15dd9167792084e881e5c7146bc7ca451d59a4318f07c60e47/access_modifiers-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "3b14aa09c699e8532761ca0527efe80f", "sha256": "aa2701922a613f53d830833e7a2ea4f93895035d6e08707be169944e60526c61" }, "downloads": -1, "filename": "access_modifiers-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "3b14aa09c699e8532761ca0527efe80f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10356, "upload_time": "2019-08-24T22:45:29", "url": "https://files.pythonhosted.org/packages/31/c5/68d63825d52fd897b61fb3fadd95780dc196f0074be6f2da3c4321892cce/access_modifiers-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bb687c7d6c94c902a47890116750d40f", "sha256": "44697b433bbd8ad838fe31446e6f345759ff0b314d6e6b4178459a274ed9a8fc" }, "downloads": -1, "filename": "access_modifiers-0.1.4.tar.gz", "has_sig": false, "md5_digest": "bb687c7d6c94c902a47890116750d40f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4595, "upload_time": "2019-08-24T22:45:31", "url": "https://files.pythonhosted.org/packages/67/ee/48ea5eeaab914cc52f46c10d8e1619b04307a99b6e71018d579dd5291251/access_modifiers-0.1.4.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "714f9a058e6742e71ad2ccf5a11e7534", "sha256": "2dd547824d6e421b31547d31942dd91f498fd5529656344df9a71c94ef53d497" }, "downloads": -1, "filename": "access_modifiers-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "714f9a058e6742e71ad2ccf5a11e7534", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10657, "upload_time": "2019-08-25T22:27:37", "url": "https://files.pythonhosted.org/packages/77/8f/bbd4b63721ad51454704dcd2097cd89d5fe851bdaef09d6d081381f16bec/access_modifiers-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "52135c4a7236302eeb57f28f32f83a0f", "sha256": "dd153db3f7efe5b4edb8b2c73e8420edfc545111f033c6852dfd41f93d949ad5" }, "downloads": -1, "filename": "access_modifiers-0.2.0.tar.gz", "has_sig": false, "md5_digest": "52135c4a7236302eeb57f28f32f83a0f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5368, "upload_time": "2019-08-25T22:27:38", "url": "https://files.pythonhosted.org/packages/e9/77/65ffd56b4463505ace31c0fc99669ca7099857e5bf22f551411589009d38/access_modifiers-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "c0ed91780ae5b6ca70e05e98964e81de", "sha256": "05d6ba9c6bc825e74e78114c06bf5ae744e8d6fb34b9e31bcc0b6ee0445321d0" }, "downloads": -1, "filename": "access_modifiers-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c0ed91780ae5b6ca70e05e98964e81de", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10786, "upload_time": "2019-08-26T21:40:24", "url": "https://files.pythonhosted.org/packages/cd/9b/faa088d7eb7cc08748ae7f24c74dba9a659e9f2bba1ea243f90ee1af5060/access_modifiers-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d4a1ffb6db19c8d2e8c380276120f4c", "sha256": "b1ae524bdd37cd64ebfdd75bf3139e92315a4804104bc59bdf04cc027a2d3bd0" }, "downloads": -1, "filename": "access_modifiers-0.2.1.tar.gz", "has_sig": false, "md5_digest": "5d4a1ffb6db19c8d2e8c380276120f4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5486, "upload_time": "2019-08-26T21:40:26", "url": "https://files.pythonhosted.org/packages/61/72/b5733c26d46e4051b8aaef3e1efadcd61ae5a714eec4ff7d402cc0c4d818/access_modifiers-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "b5b9fd5b0834ee086840320de4f337e2", "sha256": "7185d00c39bedaad78a3f759d9a291793199d83d754530e599d6c6f12b6f696d" }, "downloads": -1, "filename": "access_modifiers-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b5b9fd5b0834ee086840320de4f337e2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11341, "upload_time": "2019-08-27T11:42:15", "url": "https://files.pythonhosted.org/packages/7f/9c/bed0b640fbb15ea6c29fd583e7d364c6e878d05985ca1effd0fe17e9c1ba/access_modifiers-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "223ded1c61b7ee5b2b1d20412bd5687a", "sha256": "cd330d7bd5ba0214ea385afe34a70dc9c514992a9e4cab4ae96c9136a82894f0" }, "downloads": -1, "filename": "access_modifiers-0.3.0.tar.gz", "has_sig": false, "md5_digest": "223ded1c61b7ee5b2b1d20412bd5687a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5982, "upload_time": "2019-08-27T11:42:16", "url": "https://files.pythonhosted.org/packages/68/02/c366c85ae6193e70887ad4aff27ad6f0c0823ef0ef95fbabb63bc8610b50/access_modifiers-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "ee7a98aaf521557062363d2c29982d7c", "sha256": "02f5cee19501173708e014ce4f4df89ee49641836aac4543cee6a7d7478e3f87" }, "downloads": -1, "filename": "access_modifiers-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ee7a98aaf521557062363d2c29982d7c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11365, "upload_time": "2019-08-27T12:00:11", "url": "https://files.pythonhosted.org/packages/66/82/ed8df97f3a3099ef55d22bad4119aa64526f3538d6ca8a5147cf151ee296/access_modifiers-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f431b9d4da5101af9017d9471cfbeb37", "sha256": "4e5cbd38b48f2c0a5835f4b55b2ccf837a7ddacf41a590e9ea3a7cf9ca73b663" }, "downloads": -1, "filename": "access_modifiers-0.3.1.tar.gz", "has_sig": false, "md5_digest": "f431b9d4da5101af9017d9471cfbeb37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5997, "upload_time": "2019-08-27T12:00:13", "url": "https://files.pythonhosted.org/packages/5e/94/187bf6ab3c0e474b3bbf30d886ff9b10d13601209c70566773305e7f075c/access_modifiers-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ee7a98aaf521557062363d2c29982d7c", "sha256": "02f5cee19501173708e014ce4f4df89ee49641836aac4543cee6a7d7478e3f87" }, "downloads": -1, "filename": "access_modifiers-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ee7a98aaf521557062363d2c29982d7c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11365, "upload_time": "2019-08-27T12:00:11", "url": "https://files.pythonhosted.org/packages/66/82/ed8df97f3a3099ef55d22bad4119aa64526f3538d6ca8a5147cf151ee296/access_modifiers-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f431b9d4da5101af9017d9471cfbeb37", "sha256": "4e5cbd38b48f2c0a5835f4b55b2ccf837a7ddacf41a590e9ea3a7cf9ca73b663" }, "downloads": -1, "filename": "access_modifiers-0.3.1.tar.gz", "has_sig": false, "md5_digest": "f431b9d4da5101af9017d9471cfbeb37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5997, "upload_time": "2019-08-27T12:00:13", "url": "https://files.pythonhosted.org/packages/5e/94/187bf6ab3c0e474b3bbf30d886ff9b10d13601209c70566773305e7f075c/access_modifiers-0.3.1.tar.gz" } ] }