{ "info": { "author": "Haak Saxberg", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [], "description": "Utils\n=====\n\nSometimes you write a function over and over again; sometimes you look up at\nthe ceiling and ask \"why, Guido, why isn't this included in the standard\nlibrary?\"\n\nWell, we perhaps can't answer that question. But we can collect those functions\ninto a centralized place!\n\nProvided things\n+++++++++++++++\n\nUtils is broken up into broad swathes of functionality, to ease the task of\nremembering where exactly something lives.\n\nenum\n----\n\nPython doesn't have a built-in way to define an enum, so this module provides (what I think) is a pretty clean way to go about them.\n\n::\n\n from utils import enum\n\n class Colors(enum.Enum):\n RED = 0\n GREEN = 1\n\n # Defining an Enum class allows you to specify a few\n # things about the way it's going to behave.\n class Options:\n frozen = True # can't change attributes\n strict = True # can only compare to itself; i.e., Colors.RED == Animals.COW\n # will raise an exception.\n\n # or use the enum factory (no Options, though)\n ColorsAlso = enum.enum(\"RED\", \"GREEN\")\n\nOnce defined, use is straightforward:\n\n::\n\n >>> Colors\n \n >>> Colors.RED\n \n >>> Colors.RED == 0\n True\n >>> Colors.RED == Colors.RED\n True\n >>> Colors.RED = 2\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"utils/enum.py\", line 114, in __setattr__\n raise TypeError(\"can't set attributes on a frozen enum\")\n TypeError: can't set attributes on a frozen enum\n\nmath\n----\n\nCurrently only has the multiplicative analogue of the built-in ``sum``.\n\ndicts\n-----\n\nintersections, differences, winnowing, a few specialized dicts...\n\nlists\n-----\n\nflatten and unlisting. also ``flat_map``!\n\nbools\n-----\n\ncurrently only provides an ``xor`` function.\n\ndates\n-----\n\nMostly cool for the ``TimePeriod`` classes:\n\n::\n\n >>> from datetime import date # will also work with datetimes\n >>> time_period = TimePeriod(date(2013, 5, 10), date(2013, 8, 11))\n >>> time_period\n \n >>> date(2013, 6, 12) in time_period\n True\n >>> other_time_period = TimePeriod(date(2013, 6, 1), date(2013, 6, 30))\n >>> other_time_period in time_period\n True\n >>> another_time_period = TimePeriod(date(2013, 8, 1), date(2013, 8, 30))\n >>> time_period.overlaps(another_time_period)\n True\n >>> TimePeriod.get_containing_period(time_period, another_time_period)\n \n\n\nand so on and so forth. There's also a ``DiscontinousTimePeriod`` class, which\nstores a collection of TimePeriods.\n\nThere's also helper functions for common operations like ``days_ahead`` and\n``days_ago``, which pretty much do what they say on the tin.\n\nobjects\n-------\n\nprovides ``get_attr``, which is really just a convenient way to do deep ``getattr`` chaining:\n\n::\n\n >>> get_attr(complicated, 'this.is.a.deep.string', default=None)\n \"the deep string\" # or None, if anything in the lookup chain didn't exist\n\nThere's also an ``immutable`` utility, which will wrap an object and preven all attribute changes,\nrecursively by default. Any attempt to set attributes on the wrapped object will raise an ``AttributeError``:\n\n::\n\n >>> imm = immutable(something)\n >>> imm\n >\n >>> imm.red\n >\n >>> imm.red = SomethingElse('blue')\n # ...\n AttributeError: This object has been marked as immutable; you cannot set its attributes.\n >>> something.red = SomethingElse('blue')\n >>> imm.red\n >\n\nYou can toggle the recursive immutability by specifying the 'recursive' flag.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/haaksmash/pyutils", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "utils", "package_url": "https://pypi.org/project/utils/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/utils/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/haaksmash/pyutils" }, "release_url": "https://pypi.org/project/utils/0.9.0/", "requires_dist": null, "requires_python": null, "summary": "Python Distribution Utilities", "version": "0.9.0" }, "last_serial": 3013816, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "154502f3e98316dc30a77cae52f819ce", "sha256": "e948983941947fe8aefc92ba0ab9fcfe8b83c647e9547784062bad59822674e5" }, "downloads": -1, "filename": "utils-0.1.tar.gz", "has_sig": false, "md5_digest": "154502f3e98316dc30a77cae52f819ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2464, "upload_time": "2013-06-22T21:54:43", "url": "https://files.pythonhosted.org/packages/66/67/de9c299552009706aea585232ee6aa3db7c85e6ef00724412a43a277d7c9/utils-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "42ad8126c63e8803a8488dc4865fe8cf", "sha256": "b47bf0194b0c251237c80d755122438e5cce8ec3db52e23e57c9b5fdb6692f8d" }, "downloads": -1, "filename": "utils-0.2.tar.gz", "has_sig": false, "md5_digest": "42ad8126c63e8803a8488dc4865fe8cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4519, "upload_time": "2013-07-28T23:12:53", "url": "https://files.pythonhosted.org/packages/2f/73/14e27c6a1a82285160698c4bbd455d82352d7fc3bc935821f60e691905d3/utils-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "766de7f1a70934511d22f5fb3e314a61", "sha256": "0fd763a5d7291622885f084ad18c3f052dac051e15770059fdb94a3406f67c02" }, "downloads": -1, "filename": "utils-0.3.tar.gz", "has_sig": false, "md5_digest": "766de7f1a70934511d22f5fb3e314a61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7792, "upload_time": "2013-08-09T08:03:45", "url": "https://files.pythonhosted.org/packages/18/b9/a98be2c134c74ca9e5be9fb066bc01dd7a2dac4d9832df17fd7185ce9f36/utils-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "fd7725586b8a6a8141c80bed8a2bf9c2", "sha256": "bee2133a3c964b4d66dd845a2cc682c046ed6be5ea1e64d187d5d3931be9e174" }, "downloads": -1, "filename": "utils-0.4.tar.gz", "has_sig": false, "md5_digest": "fd7725586b8a6a8141c80bed8a2bf9c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10569, "upload_time": "2013-08-17T20:41:05", "url": "https://files.pythonhosted.org/packages/c8/1c/d4948569840a99390abd6cf522982918a75e9dbbcbaeb7fba9d2cc834746/utils-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "5dece63791376e60b2ff64b16b2ae7d0", "sha256": "a2512be191b309d72eaf1ae7fbf95c928bfc34664cc8554c241cae6cf6646ad4" }, "downloads": -1, "filename": "utils-0.5.tar.gz", "has_sig": false, "md5_digest": "5dece63791376e60b2ff64b16b2ae7d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12342, "upload_time": "2013-08-30T06:58:33", "url": "https://files.pythonhosted.org/packages/b7/6e/f7b13fb6813459f897dc11f7a8a2af7e7abb8fc32d5817a77891c768d890/utils-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "75828d22aa805f9abe6cff5915bfbbc2", "sha256": "babd9a14c5f5d5ddb6aa8d5d5f3d6074c21b58f8ff614097e35522ce2d7ba977" }, "downloads": -1, "filename": "utils-0.6.tar.gz", "has_sig": false, "md5_digest": "75828d22aa805f9abe6cff5915bfbbc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14194, "upload_time": "2014-11-06T20:37:07", "url": "https://files.pythonhosted.org/packages/b6/f7/980090cbc96b9ce5934857bef6acdda8f9af839db8dae499adedf6e6326b/utils-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "9b454a7775735ff7939cca269bf89067", "sha256": "6bf9dae704fbffb4fed2b9c4d12ee7547af6b773273ca5142ec68912099ca8c9" }, "downloads": -1, "filename": "utils-0.7.tar.gz", "has_sig": false, "md5_digest": "9b454a7775735ff7939cca269bf89067", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14286, "upload_time": "2015-02-02T08:03:18", "url": "https://files.pythonhosted.org/packages/49/7a/ae11832c22f17c60905fbb00c585582dd885b2a9d06b323db59fbb4f341e/utils-0.7.tar.gz" } ], "0.8.0": [ { "comment_text": "", "digests": { "md5": "9f1bff64076cedad62743d8c5cf2c3d4", "sha256": "272ebb342ff792ea61daf352ce7bef14e9402bf5d2f1766c47f99b2a4c779cca" }, "downloads": -1, "filename": "utils-0.8.0.tar.gz", "has_sig": false, "md5_digest": "9f1bff64076cedad62743d8c5cf2c3d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14328, "upload_time": "2015-06-02T06:57:48", "url": "https://files.pythonhosted.org/packages/b9/d9/cc23a499523e1e566e0732abf3b83543797d37a8af996a0db18d92160186/utils-0.8.0.tar.gz" } ], "0.9.0": [ { "comment_text": "", "digests": { "md5": "1113552f4556ba707659fd21823d3d1b", "sha256": "6892efdfdfdf1fd99cef76daa20b9b4667d53e00aa289651fedfb0dbbebf1906" }, "downloads": -1, "filename": "utils-0.9.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1113552f4556ba707659fd21823d3d1b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 23443, "upload_time": "2017-07-11T05:16:17", "url": "https://files.pythonhosted.org/packages/9b/de/9ffaf89be661b32d1e0cff05e1af5e4fc2d608c47498975e94aca219aed4/utils-0.9.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c705687fe230ff0369e7d404bca06060", "sha256": "9ef5730cf1bc26e0d29db407f3c129b596ede7bc679e08213cde76e079415512" }, "downloads": -1, "filename": "utils-0.9.0.tar.gz", "has_sig": false, "md5_digest": "c705687fe230ff0369e7d404bca06060", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14777, "upload_time": "2015-12-19T22:15:08", "url": "https://files.pythonhosted.org/packages/07/49/42c86388fed58455e7e18d3821d7687f4921e47a40cb312e69b82f75c660/utils-0.9.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1113552f4556ba707659fd21823d3d1b", "sha256": "6892efdfdfdf1fd99cef76daa20b9b4667d53e00aa289651fedfb0dbbebf1906" }, "downloads": -1, "filename": "utils-0.9.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1113552f4556ba707659fd21823d3d1b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 23443, "upload_time": "2017-07-11T05:16:17", "url": "https://files.pythonhosted.org/packages/9b/de/9ffaf89be661b32d1e0cff05e1af5e4fc2d608c47498975e94aca219aed4/utils-0.9.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c705687fe230ff0369e7d404bca06060", "sha256": "9ef5730cf1bc26e0d29db407f3c129b596ede7bc679e08213cde76e079415512" }, "downloads": -1, "filename": "utils-0.9.0.tar.gz", "has_sig": false, "md5_digest": "c705687fe230ff0369e7d404bca06060", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14777, "upload_time": "2015-12-19T22:15:08", "url": "https://files.pythonhosted.org/packages/07/49/42c86388fed58455e7e18d3821d7687f4921e47a40cb312e69b82f75c660/utils-0.9.0.tar.gz" } ] }