{ "info": { "author": "Maxime Schoemans", "author_email": "maxime.schoemans@ulb.ac.be", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.7" ], "description": "# utempid\n\n> Unique temporary id generator for python\n\n## Usage\n\n### Getting it\nTo download utempid, simply use Pypi via pip.\n\n```shell\n$ pip install utempid\n```\n\n### Using it\n\n```python\n# import the generator class\nfrom utempid import UtempidGenerator\n\n# create the generator\ngen = utempid.UtempidGenerator()\n\n# get temporary ids\nfirst_id = gen.get_id() # first_id = 0\nsecond_id = gen.get_id() # second_id = 1\nthird_id = gen.get_id() # third_id = 2\n\n# return ids when no longer needed\ngen.return_id(second_id)\n\n# track amount of temporary ids in use\nprint(gen.active_count) # 2\n```\n\n### Example\n\nUtempidGenerator can be used when creating temporary objects with unique ids.\nWhen an object is destroyed, the id is returned to the generator.\nThis allows for an easy count of the live objects and creates ids that are limited by the maximum amount of live objects at any point.\n\n```python\n# import the generator class\nfrom utempid import UtempidGenerator\n\nclass TemporaryObject(object):\n\n gen = UtempidGenerator()\n\n def __init__(self):\n self.id = self.gen.get_id()\n\n @classmethod\n def count(cls):\n return cls.gen.active_count\n\n def __del__(self):\n self.gen.return_id(self.id)\n\n\ndef main():\n a = TemporaryObject() # a.id = 0\n b = TemporaryObject() # b.id = 1\n c = TemporaryObject() # c.id = 2\n\n print(\"count: \", TemporaryObject.count()) # 3\n del a # return id 0\n print(\"count: \", TemporaryObject.count()) # 2\n\n d = TemporaryObject() # d.id = 0\n\n print(\"count: \", TemporaryObject.count()) # 3\n b = 1 # return id 1\n print(\"count: \", TemporaryObject.count()) # 2\n```\n\nLicense\n----\n\nMIT License\n\nCopyright (c) 2018 Joel Barmettler\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\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/mschoema/utempid", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "utempid", "package_url": "https://pypi.org/project/utempid/", "platform": "", "project_url": "https://pypi.org/project/utempid/", "project_urls": { "Homepage": "https://github.com/mschoema/utempid" }, "release_url": "https://pypi.org/project/utempid/1.0.0/", "requires_dist": null, "requires_python": ">=3.7", "summary": "Unique temporary id generator for python", "version": "1.0.0" }, "last_serial": 5844386, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "68462dfbf1c4be5d1d2d4d643b072ffb", "sha256": "3d2cef840a10f13d19fbe5a10c89a82c4d1b03a79cc2c6a129beac6d8840fcb9" }, "downloads": -1, "filename": "utempid-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "68462dfbf1c4be5d1d2d4d643b072ffb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 4072, "upload_time": "2019-09-17T22:34:30", "url": "https://files.pythonhosted.org/packages/24/dd/d9e7046a51be7320f955f9150d2da2e094638b4a815645857ddd9ff385c5/utempid-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e9945ead5ee6e26393e022b5acab9b0", "sha256": "d5465a34de36a989cbb18d30a06988a3cc16b4929200c1915a788465a87cfe2c" }, "downloads": -1, "filename": "utempid-1.0.0.tar.gz", "has_sig": false, "md5_digest": "5e9945ead5ee6e26393e022b5acab9b0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 3055, "upload_time": "2019-09-17T22:34:33", "url": "https://files.pythonhosted.org/packages/f5/d8/ddef38c6c96bd3a59b9556d4ee45bd261e05cc23d829e8d9895a97b007dc/utempid-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "68462dfbf1c4be5d1d2d4d643b072ffb", "sha256": "3d2cef840a10f13d19fbe5a10c89a82c4d1b03a79cc2c6a129beac6d8840fcb9" }, "downloads": -1, "filename": "utempid-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "68462dfbf1c4be5d1d2d4d643b072ffb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 4072, "upload_time": "2019-09-17T22:34:30", "url": "https://files.pythonhosted.org/packages/24/dd/d9e7046a51be7320f955f9150d2da2e094638b4a815645857ddd9ff385c5/utempid-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e9945ead5ee6e26393e022b5acab9b0", "sha256": "d5465a34de36a989cbb18d30a06988a3cc16b4929200c1915a788465a87cfe2c" }, "downloads": -1, "filename": "utempid-1.0.0.tar.gz", "has_sig": false, "md5_digest": "5e9945ead5ee6e26393e022b5acab9b0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 3055, "upload_time": "2019-09-17T22:34:33", "url": "https://files.pythonhosted.org/packages/f5/d8/ddef38c6c96bd3a59b9556d4ee45bd261e05cc23d829e8d9895a97b007dc/utempid-1.0.0.tar.gz" } ] }