{ "info": { "author": "Acrisel Team", "author_email": "support@acrisel.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=======\nacrilib\n=======\n\n----------------------------------------------------\nIndependent programming idioms and utilities library\n----------------------------------------------------\n\n.. contents:: Table of Contents\n :depth: 2\n\nOverview\n========\n\n **acrilib** is a python library providing useful programming patterns and tools. **acrilib** started as Acrisel's internal idioms and utilities for programmers. The main key is that this library is completely independent. It does not use any external packages beside what provided by Python.\n \n It includes:\n 1. programming idioms that are repeatedly used by programmers.\n #. helpers functions for logging and other utilities.\n \n We decided to contribute this library to Python community as a token of appreciation to\n what this community enables us.\n \n We hope that you will find this library useful and helpful as we find it.\n \n If you have comments or insights, please don't hesitate to contact us at support@acrisel.com\n \nProgramming Idoms\n=================\n\nthreaded\n--------\n\n decorator for methods that can be executed as a thread. RetriveAsycValue callable class used in the example below provide means to access results. One can provide their own callable to pass results. \n\nexample\n~~~~~~~\n\n .. code-block:: python\n\n from acris import threaded, RetriveAsycValue\n from time import sleep\n\n class ThreadedExample(object):\n @threaded\n def proc(self, id_, num, stall):\n s = num\n while num > 0:\n print(\"%s: %s\" % (id_, s))\n num -= 1\n s += stall\n sleep(stall)\n print(\"%s: %s\" % (id_, s)) \n return s\n\n \nexample output\n~~~~~~~~~~~~~~\n\n .. code-block:: python\n\n print(\"starting workers\")\n te1 = ThreadedExample().proc('TE1', 3, 1)\n te2 = ThreadedExample().proc('TE2', 3, 1)\n \n print(\"collecting results\")\n te1_callback = RetriveAsycValue('te1')\n te1.addCallback(te1_callback)\n te2_callback = RetriveAsycValue('te2')\n te2.addCallback(te2_callback)\n \n print('joining t1')\n te1.join()\n print('joined t1')\n print('%s callback result: %s' % (te1_callback.name, te1_callback.result))\n result = te1.syncResult()\n print('te1 syncResult : %s' %result)\n \n result = te2.syncResult()\n print('te2 syncResult : %s' % result)\n print('%s callback result: %s' % (te2_callback.name, te2_callback.result))\n\n will produce:\n\n .. code-block:: python\n\n starting workers\n TE1: 3\n TE2: 3\n collecting results\n joining t1\n TE1: 4\n TE2: 4\n TE1: 5\n TE2: 5\n TE1: 6\n TE2: 6\n joined t1\n te1 callback result: 6\n te1 syncResult : 6\n te2 syncResult : 6\n te2 callback result: 6\n \nSingleton and NamedSingleton\n----------------------------\n\n meta class that creates singleton footprint of classes inheriting from it.\n\nSingleton example\n~~~~~~~~~~~~~~~~~\n\n .. code-block:: python\n\n from acris import Singleton\n\n class Sequence(Singleton):\n step_id=0\n \n def __call__(self):\n step_id = self.step_id\n self.step_id += 1\n return step_id \n\nexample output\n~~~~~~~~~~~~~~\n\n .. code-block:: python\n \n A=Sequence()\n print('A', A())\n print('A', A())\n B=Sequence()\n print('B', B()) \n\n will produce:\n\n .. code-block:: python\n\n A 0\n A 1\n B 2\n \nNamedSingleton example\n~~~~~~~~~~~~~~~~~~~~~~\n\n .. code-block:: python\n\n from acris import Singleton\n\n class Sequence(NamedSingleton):\n step_id = 0\n \n def __init__(self, name=''):\n self.name = name\n \n def __call__(self,):\n step_id = self.step_id\n self.step_id += 1\n return step_id \n\nexample output\n~~~~~~~~~~~~~~\n\n .. code-block:: python\n \n A = Sequence('A')\n print(A.name, A())\n print(A.name, A())\n B = Sequence('B')\n print(B.name, B()) \n\n will produce:\n\n .. code-block:: python\n\n A 0\n A 1\n B 0\n \nSequence\n--------\n\n meta class to produce sequences. Sequence allows creating different sequences using name tags.\n\nexample\n~~~~~~~\n\n .. code-block:: python\n\n from acris import Sequence\n\n A = Sequence('A')\n print('A', A())\n print('A', A())\n B = Sequence('B')\n print('B', B()) \n \n A = Sequence('A')\n print('A', A())\n print('A', A())\n B = Sequence('B')\n print('B', B()) \n\nexample output\n~~~~~~~~~~~~~~\n\n .. code-block:: python\n \n A 0\n A 1\n B 0\n A 2\n A 3\n B 1\n\nTimedSizedRotatingHandler\n-------------------------\n\t\n TBD\n\n \nDecorators\n----------\n\n Useful decorators for production and debug.\n \ntraced_method\n~~~~~~~~~~~~~\n\n logs entry and exit of function or method.\n \n .. code-block :: python\n \n from acris import traced_method\n\n traced = traced_method(print, print_args=True, print_result=True)\n\n class Oper(object):\n def __init__(self, value):\n self.value = value\n \n def __repr__(self):\n return str(self.value)\n \n @traced\n def mul(self, value):\n self.value *= value \n return self \n \n @traced\n def add(self, value):\n self.value += value\n return self\n \n o=Oper(3)\n print(o.add(2).mul(5).add(7).mul(8))\n \n would result with the following output:\n \n .. code-block :: python\n \n [ add ][ entering][ args: (2) ][ kwargs: {} ][ trace_methods.py.Oper(39) ]\n [ add ][ exiting ] [ time span: 0:00:00.000056][ result: 5 ][ trace_methods.py.Oper(39) ]\n [ mul ][ entering][ args: (5) ][ kwargs: {} ][ trace_methods.py.Oper(34) ]\n [ mul ][ exiting ] [ time span: 0:00:00.000010][ result: 25 ][ trace_methods.py.Oper(34) ]\n [ add ][ entering][ args: (7) ][ kwargs: {} ][ trace_methods.py.Oper(39) ]\n [ add ][ exiting ] [ time span: 0:00:00.000007][ result: 32 ][ trace_methods.py.Oper(39) ]\n [ mul ][ entering][ args: (8) ][ kwargs: {} ][ trace_methods.py.Oper(34) ]\n [ mul ][ exiting ] [ time span: 0:00:00.000008][ result: 256 ][ trace_methods.py.Oper(34) ]\n 256\n\t\nData Types\n----------\n\n varies derivative of Python data types\n\nMergeChainedDict\n~~~~~~~~~~~~~~~~\n\n Similar to ChainedDict, but merged the keys and is actually derivative of dict.\n\n .. code-block:: python\n\n a={1:11, 2:22}\n b={3:33, 4:44}\n c={1:55, 4:66}\n d=MergedChainedDict(c, b, a)\n print(d) \n\n Will output:\n\n .. code-block:: python\n\n \t{1: 55, 2: 22, 3: 33, 4: 66}\n\n \nMediator\n--------\n \n Class interface to generator allowing query of has_next()\n \nExample \n~~~~~~~\n\n .. code-block:: python\n\n from acris import Mediator\n\n def yrange(n):\n i = 0\n while i < n:\n yield i\n i += 1\n\n n = 10\n m = Mediator(yrange(n))\n for i in range(n):\n print(i, m.has_next(3), next(m))\n print(i, m.has_next(), next(m))\n\nExample Output\n~~~~~~~~~~~~~~\n\n .. code-block:: python\n\n 0 True 0\n 1 True 1\n 2 True 2\n 3 True 3\n 4 True 4\n 5 True 5\n 6 True 6\n 7 True 7\n 8 False 8\n 9 False 9\n Traceback (most recent call last):\n File \"/private/var/acrisel/sand/acris/acris/acris/example/mediator.py\", line 19, in \n print(i, m.has_next(), next(m))\n File \"/private/var/acrisel/sand/acris/acris/acris/acris/mediator.py\", line 38, in __next__\n value=next(self.generator)\n StopIteration \n \n\nsetup tools\n===========\n \nMethods to use in standard python environment\n \nChange History\n==============\n\nVersion 1.0\n------------\n\n 1. Initial publication to open source", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Acrisel/acrilib", "keywords": "library sequence logger yield singleton thread synchronize resource pool utilities os ssh xml excel mail", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "acrilib", "package_url": "https://pypi.org/project/acrilib/", "platform": "", "project_url": "https://pypi.org/project/acrilib/", "project_urls": { "Homepage": "https://github.com/Acrisel/acrilib" }, "release_url": "https://pypi.org/project/acrilib/1.0.8/", "requires_dist": null, "requires_python": "", "summary": "acrilib is a python library of programming patterns commonly used in Python", "version": "1.0.8" }, "last_serial": 3858749, "releases": { "1.0.2": [ { "comment_text": "", "digests": { "md5": "17f1f578ef31b5285d16ec0250521620", "sha256": "61a00d0e06ddf82b07d50ca7a55cacc146b6dfe7de94481fd83baf66e86779c7" }, "downloads": -1, "filename": "acrilib-1.0.2.tar.gz", "has_sig": true, "md5_digest": "17f1f578ef31b5285d16ec0250521620", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17036, "upload_time": "2017-10-17T15:20:42", "url": "https://files.pythonhosted.org/packages/83/63/b514e4d0bbd356634ced09a272b8a97c0dd960078611d24226b62791c8c8/acrilib-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "cdc7d6a3fa2c89079134cfd3c99c0573", "sha256": "723aa6980c10cf790266d654bc3ea69fa6264c832e795c1e223da12c7ce987a5" }, "downloads": -1, "filename": "acrilib-1.0.3.tar.gz", "has_sig": true, "md5_digest": "cdc7d6a3fa2c89079134cfd3c99c0573", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16996, "upload_time": "2017-10-31T15:51:24", "url": "https://files.pythonhosted.org/packages/8b/6a/7479f32dfde0ab8e8249bcaf90fcda88ce2d06073dd7f0d12024fa3910d2/acrilib-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "4e9a9a09342a8b576c978a67cd1a0f6d", "sha256": "ca39da0701c221321ade11012a4b2522b48cb3d0b8cf9058cf69c94759fc51fb" }, "downloads": -1, "filename": "acrilib-1.0.4.tar.gz", "has_sig": true, "md5_digest": "4e9a9a09342a8b576c978a67cd1a0f6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28813, "upload_time": "2017-12-24T14:45:55", "url": "https://files.pythonhosted.org/packages/38/0e/14aff2b3fb17dad0afacfc8c713b6f2fc8f194f62eb58380a27475c557cb/acrilib-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "967571fe601e20b637c577193559bd4e", "sha256": "5297034aeea9146042f0ff7e23468e3eb33dac69962a043965b8969ea3da837f" }, "downloads": -1, "filename": "acrilib-1.0.5.tar.gz", "has_sig": true, "md5_digest": "967571fe601e20b637c577193559bd4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29080, "upload_time": "2018-01-01T17:49:47", "url": "https://files.pythonhosted.org/packages/30/6c/1348059dd183c0b17c49c4229bdfcd63f50c68bce577265ce10d8b3fbfc8/acrilib-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "72931bb5325f23d5c8373cd6c9679374", "sha256": "3f8550b6eeab4e0ea16283349fd484ff6bf326668dd8d498c37e51696cdc9001" }, "downloads": -1, "filename": "acrilib-1.0.6.tar.gz", "has_sig": true, "md5_digest": "72931bb5325f23d5c8373cd6c9679374", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29222, "upload_time": "2018-01-03T01:48:42", "url": "https://files.pythonhosted.org/packages/2d/2e/ea102026cc11281e49c8fd7a29db4fd65597fe49b894b46b5ea50d34b9ba/acrilib-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "6cecc63d20b0879c5ed59125aa76dcfe", "sha256": "b2e484dcef766e142e2ede950ae5b847cdeb49620e49d3fe82c85751f90666ec" }, "downloads": -1, "filename": "acrilib-1.0.7.tar.gz", "has_sig": true, "md5_digest": "6cecc63d20b0879c5ed59125aa76dcfe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30369, "upload_time": "2018-01-20T23:47:05", "url": "https://files.pythonhosted.org/packages/6e/9e/e00ce9a3ab044ae76852dd7d2890309486f02c459c833eec4d90fe300749/acrilib-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "49e3e27ec0617597f952160c50f752af", "sha256": "f8b8cfe2fc42a8b6ed70a763b80a0cfe21f023b8b188f1bb3f35391741292609" }, "downloads": -1, "filename": "acrilib-1.0.8.tar.gz", "has_sig": true, "md5_digest": "49e3e27ec0617597f952160c50f752af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28496, "upload_time": "2018-05-13T16:18:22", "url": "https://files.pythonhosted.org/packages/c1/1e/674816ba726c251022418ffc28486a736db4ddd1fa65b387b7834bdc0e7c/acrilib-1.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "49e3e27ec0617597f952160c50f752af", "sha256": "f8b8cfe2fc42a8b6ed70a763b80a0cfe21f023b8b188f1bb3f35391741292609" }, "downloads": -1, "filename": "acrilib-1.0.8.tar.gz", "has_sig": true, "md5_digest": "49e3e27ec0617597f952160c50f752af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28496, "upload_time": "2018-05-13T16:18:22", "url": "https://files.pythonhosted.org/packages/c1/1e/674816ba726c251022418ffc28486a736db4ddd1fa65b387b7834bdc0e7c/acrilib-1.0.8.tar.gz" } ] }