{ "info": { "author": "Konstantin Schukraft", "author_email": "konstantin@schukraft.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: ISC License (ISCL)", "Operating System :: OS Independent", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Rohrleitung\n===========\n\nRohrleitung (ger.): _pipeline_\n\nDidn't like the shell-like approach the other pipelining packages took, where you\nwould concatenate specially written generators with the UNIX pipe `|`. While that's\ngreat for the CLI and short shell scripts, I wanted a more programmable way.\n\nWorth mentioning is surely [genpipeline](https://github.com/fkarb/genpipeline) that\nimplements coroutine-based pipelines as presented by [David Beazley's Coroutines\nintro](http://www.dabeaz.com/coroutines/). But this means you have to do everything\nin coroutines, I built Rohrleitung so I could just use classic generator-based\nfilters. Look into both and decide which way is cleaner for your environment.\n\nISC licenced, see the LICENCE file.\n\nExamples:\n---------\n\n from functools import partial\n # pip install toolz\n from toolz.curried import interpose\n\n from rohrleitung import Pipeline, L\n\n\n def three_n_plus_one(n):\n if n % 2:\n return 3 * n + 1\n else:\n return n / 2\n\n\n @L\n def collatz_length(n, l=0):\n if int(n) < 1:\n raise ValueError('Nope')\n if n == 1:\n return l\n else:\n # L changes call signatures of decorated function, so in recursive ones\n # you have to adapt.\n return collatz_length.__wrapped__(three_n_plus_one(n), l + 1)\n\n # building pipelines in a programmatic way, without immediately executing them\n # standard list manipulation can change pipeline on the fly\n pipeline = [\n partial(filter, lambda x: x % 2), # Standard python's filter function\n lambda y: (2 * x for x in y), # Like using L, but manually\n L(lambda x: x ** 3), # Using L helper function\n collatz_length,\n ]\n pipeline.append(interpose('a'))\n print(list(Pipeline(pipeline, range(10))))\n\n a = Pipeline([L(lambda x: 2 * x), L(lambda x: x + 1), L(lambda x: x ** 2)])\n for i, k in enumerate(a(range(3))):\n print(\"(2x+1)^2, x={}: {}\".format(i, k))\n\n # With toolz' curried filter function we don't need partial\n from toolz.curried import filter\n newpipeline = [\n collatz_length,\n filter(lambda x: not(x % 2)),\n L(lambda x: bin(x)),\n L(lambda x: x.count('1'))\n ]\n p1 = Pipeline(newpipeline)\n for i in p1(range(1, 10)):\n print(i)\n\n # Reuse same pipeline\n for i in p1(range(1, 3)):\n print(i)\n\n # Or modify it, then use again\n p1.pipeline.insert(2, L(lambda x: x + 1))\n for i in p1(range(1, 10)):\n print(i)\n\n p2 = Pipeline(pipeline)\n p3 = 2 * (p2 + [L(lambda x: int(str(x), 16))]) + p1\n # Alternativly 2 * p2 | p1 if you prefer shell syntax\n for i in p3(range(1, 10)):\n print(i)\n\n # Slicing and cutting pipelines on the fly\n for i in p1[1:4:2](range(10)):\n print(i)", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yggdr/rohrleitung", "keywords": "rohrleitung pipeline pipelines generators iterators", "license": "ISC", "maintainer": "", "maintainer_email": "", "name": "rohrleitung", "package_url": "https://pypi.org/project/rohrleitung/", "platform": "any", "project_url": "https://pypi.org/project/rohrleitung/", "project_urls": { "Homepage": "https://github.com/yggdr/rohrleitung" }, "release_url": "https://pypi.org/project/rohrleitung/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "pipelining generators like python, not like shell", "version": "0.1.1" }, "last_serial": 2145213, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ba4df95565991cb7bc9bcdb922e5f57f", "sha256": "040a12bed7a42a83043af7752f45f0d58c931955bc0b68f318d0a876ec4e65cb" }, "downloads": -1, "filename": "rohrleitung-0.1.tar.gz", "has_sig": false, "md5_digest": "ba4df95565991cb7bc9bcdb922e5f57f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3409, "upload_time": "2016-05-31T13:45:34", "url": "https://files.pythonhosted.org/packages/a8/bf/a6f6da10fca7315b2a9cbeb6345accac429ca0e2da6bbcc27a8ffa969e5e/rohrleitung-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a3e0ea58492f307c4eb286b3fbdaad1a", "sha256": "3bb1e7dadd0d8bcdbdc747326bca5879d0385e1b2848372730bef6ee27800336" }, "downloads": -1, "filename": "rohrleitung-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a3e0ea58492f307c4eb286b3fbdaad1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3922, "upload_time": "2016-06-01T14:30:27", "url": "https://files.pythonhosted.org/packages/30/df/361998adeee46f04a19ebe3ebf285f8e076f4114e4cac1ed369ec6bbad68/rohrleitung-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a3e0ea58492f307c4eb286b3fbdaad1a", "sha256": "3bb1e7dadd0d8bcdbdc747326bca5879d0385e1b2848372730bef6ee27800336" }, "downloads": -1, "filename": "rohrleitung-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a3e0ea58492f307c4eb286b3fbdaad1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3922, "upload_time": "2016-06-01T14:30:27", "url": "https://files.pythonhosted.org/packages/30/df/361998adeee46f04a19ebe3ebf285f8e076f4114e4cac1ed369ec6bbad68/rohrleitung-0.1.1.tar.gz" } ] }