{ "info": { "author": "OGURA_Daiki", "author_email": "8hachibee125@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "=================================================================\nMasala\n=================================================================\n\nbuild status\n\nmaster\n\n.. image:: https://travis-ci.org/hachibeeDI/masala.svg?branch=master\n :target: https://travis-ci.org/hachibeeDI/masala\n\n\nInstall\n=================================================================\n\n.. code-block:: bash\n\n $ pip install masala\n\n\nExample\n=================================================================\n\n\ncurry\n-----------------------------------------------------------------\n\n\n.. code-block:: python\n\n >>> from __future__ import (print_function, division, absolute_import, unicode_literals, )\n >>> from masala import CurryContainer as cc\n >>> cur = cc(lambda a, b, c: [a, b, c])\n >>> cur = cur << 'aaa' << 'bbb'\n >>> cur('ccc')\n ['aaa', 'bbb', 'ccc']\n\n >>> cur = cc(lambda a, b='hogeeee', c='foooo': [a, b, c])\n >>> cur = cur << 'a' << ('c', 'c')\n >>> cur('b')\n ['a', 'b', 'c']\n\n >>> from masala import curried\n >>> @curried\n ... def sum5(a, b, c, d, e):\n ... return a + b + c + d + e\n ...\n >>> sum0 = sum5 << 1 << 2 << 3 << 4 << 5\n >>> assert sum0() == sum5(1, 2, 3, 4, 5)\n\n\n\nshort hands\n-----------------------------------------------------------------\n\nlambda\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n >>> from masala import lambd as _\n >>> from masala.datatype import Either\n >>> Either.right('hachi') >> _.title()\n 'Hachi'\n >>> replacer = _.replace(_, _)\n >>> replacer('hachi', 'chi', 'chiboee')\n 'hachiboee'\n >>> list(map(_ + 2, range(3)))\n [2, 3, 4]\n >>> from six.moves import reduce\n >>> reduce(_ + _, range(5))\n 10\n\n\nmethod chaining\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n.. code-block:: python\n\n >>> from masala import BuilderAllowsMethodChaining as __\n >>> Either.right('hachi') >> __.title().replace('i', 'U').replace('c', 'z')\n 'HazhU'\n >>> foolambda = __.title().replace('i', 'U').replace('c', 'z')\n >>> foolambda('hachi')\n 'HazhU'\n\n >>> Either.right(4) >> ((__ + 4) * 'py'.title())\n 'PyPyPyPyPyPyPyPy'\n >>> (__ + 1 + 2 + 3 + 4 + 5)(0)\n 15\n >>> (__ + 1 + 2 + 3 + 4 + 5).apply__(0)\n 15\n\n\nlist processing\n-----------------------------------------------------------------\n\n\n.. code-block:: python\n\n >>> from masala import (apply as a, lambd as _, )\n >>> from masala.datatype import Stream\n >>> # extends linq like methods to Stream.\n >>> # but I reccomend to use itertools extention is also prepared as `from masala.datatype.stream import itertools_ext`\n >>> from masala.datatype.stream import linq_ext\n >>> Stream([1, 2, 3]).select(_ * 2).to_list()\n [2, 4, 6]\n >>> # support lazy evaluation\n >>> Stream([1, 2, 3]).select(_ * 2) # doctest:+ELLIPSIS\n Stream: < >> Stream(range(0, 15)).select(_ + 1).where(__ % 2 == 0).to_list()\n [2, 4, 6, 8, 10, 12, 14]\n\n >>> Stream(range(0, 100)).select(_ * 2).where(_ > 1000).first() # doctest:+ELLIPSIS\n Empty: < None > reason => :\n\n >>> Stream(range(0, 100)).select(_ * 2).any(_ > 1000)\n False\n >>> Stream(111111).select(_ * 2).to_list()\n Empty: < None > reason => : 'int' object is not iterable\n\n >>> # you can extend the method by yourself\n >>> from masala.datatype.stream import dispatch_stream\n >>> @dispatch_stream\n ... def my_select(xs, x_to_y):\n ... for x in xs:\n ... yield x_to_y(x)\n >>> Stream([1, 2, 3]).my_select(_ * 2).to_list()\n [2, 4, 6]\n >>> from masala.datatype.stream import delete_dispatchedmethods\n >>> # you can clean extentions.\n >>> delete_dispatchedmethods(['my_select'])\n\n >>> # other cases\n >>> twicer = Stream().select(_ * 2)\n >>> twiced = twicer << [1, 2, 3]\n >>> list(twiced)\n [2, 4, 6]\n >>> twiced2 = twicer << [2, 3, 4]\n >>> list(twiced2)\n [4, 6, 8]\n\n >>> delete_dispatchedmethods(linq_ext.__all__)\n\n\n\nPattern Match\n-----------------------------------------------------------------\n\n\n.. code-block:: python\n\n >>> from masala import Match\n\n >>> match = Match(10)\n >>> if match.when(1):\n ... print('boo')\n ... elif match.when(10):\n ... print('yieeeee')\n yieeeee\n\n\n >>> from masala import Wildcard as _\n\n >>> match = Match([1, 2, 3])\n >>> @match.when([2, 2, 2], let_=('one', 'two', 'thr'))\n ... def case1(one, two, thr):\n ... return 'case1'\n >>> @match.when([_, 2, 3], let_=('one', '_', 'thr'))\n ... def case2(one, thr):\n ... return 'case2'\n >>> assert match.end == 'case2'\n\n >>> match = Match('python')\n >>> @match.when(_.isdigit(), let_='moo')\n ... def case1(moo):\n ... return one\n >>> @match.when(_ == 'python', let_=('a'))\n ... def case2(a):\n ... return a\n >>> assert match.end == 'python'\n\n\n >>> # with datatype\n\n >>> from masala.datatype import Right, Left\n\n >>> match = Match(Either.right('python'))\n >>> @match.when(Right)\n ... def case_right(v):\n ... return v + ' is right!'\n >>> @match.when(Left)\n ... def case_left(v):\n ... assert False\n >>> assert match.end == 'python is right!'\n\n\n\ncall method with optional values\n-----------------------------------------------------------------\n\n.. code-block:: python\n\n >>> from masala import Perhaps\n\n >>> p = Perhaps('hoge huga foo')\n >>> p.try_('replace', 'huga', 'muoo').try_('upper').get()\n 'HOGE MUOO FOO'\n >>> p.apply(len).get()\n 13\n\n >>> nonecase = Perhaps(None).try_('replace', 'huga', 'muoo').try_('upper')\n >>> nonecase.get()\n\n >>> nonecase.get_or('nnnnn')\n 'nnnnn'\n\n\n\nSupport\n=================================================================\n\ntested version of Python is\n\n- 2.7\n- 3.4", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hachibeeDI/masala", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "masala", "package_url": "https://pypi.org/project/masala/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/masala/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/hachibeeDI/masala" }, "release_url": "https://pypi.org/project/masala/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "curry functional patternpatch linq", "version": "0.0.2" }, "last_serial": 1158090, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "ceede6e13bdcbf404e1faf26cff2ede9", "sha256": "30372676de59b90eb19745c97640521729db986a6bf5bcbe0eb314b83e35d443" }, "downloads": -1, "filename": "masala-0.0.2.tar.gz", "has_sig": false, "md5_digest": "ceede6e13bdcbf404e1faf26cff2ede9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14424, "upload_time": "2014-07-15T08:39:27", "url": "https://files.pythonhosted.org/packages/29/a9/0373673cc20c35396f1d8a4fb9db6c5ae153610e0e545a79c1f0860a46f9/masala-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ceede6e13bdcbf404e1faf26cff2ede9", "sha256": "30372676de59b90eb19745c97640521729db986a6bf5bcbe0eb314b83e35d443" }, "downloads": -1, "filename": "masala-0.0.2.tar.gz", "has_sig": false, "md5_digest": "ceede6e13bdcbf404e1faf26cff2ede9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14424, "upload_time": "2014-07-15T08:39:27", "url": "https://files.pythonhosted.org/packages/29/a9/0373673cc20c35396f1d8a4fb9db6c5ae153610e0e545a79c1f0860a46f9/masala-0.0.2.tar.gz" } ] }