{ "info": { "author": "herr kaste", "author_email": "herr.kaste@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries" ], "description": "Pseudo-hacky sugar around generators. If you write nested for loops or nested functions ``a(b(c([1,2,3])))`` this might help you. \n\n\nBasically it looks like this::\n\n\t[1, 2, 3] | add(2) | list == [3, 4, 5]\n\nwhere\n\n::\n\t\n\t@worker\n\tdef add(items, n):\n\t\tfor i in items:\n\t\t\tyield i + n\n\nThe leftmost argument always is the iterator coming from the left side. The other arguments represent a bound state. Using this worker is a two-step process.\n\n:: \n\n\tadder = add(2) # bind a state in a closure\n\tadder([1, 2, 3]) == [3, 4, 5] # apply an iterator\n\nworkers tend to be very simple and short, reusable and easy to test.\n\n::\n\n\t@worker\n\tdef echo(items):\n\t\tfor i in items: yield i\n\techo = echo() # echo 'has' no state\n\tassert [1, 2, 3] | echo == [1, 2, 3]\n\n\n\n\nSometimes you can achieve something like this::\n\n\n\tfilter_audio_files = fs.filter_by_ext(['.mp3'])\n\n\t@producer\n\tdef folders_with_audio_files(path):\n\t for root, folders, filenames in os.walk(path):\n\t if any(filenames | filter_audio_files):\n\t yield root\n\n\n\t@worker\n\tdef that_need_fix(paths):\n\t\tfor path in paths:\n\t\t\tfiles = listdir(path) | filter_audio_files | join_path(path) | list\n\t\t\tdos_names = files | get_83DOS_name | list\n\n\t\t\tif files.sort() != dos_names.sort():\n\t\t\t\tyield path\n\tthat_need_fix = that_need_fix()\n\n\n\t# and the outermost commands in a script then look like this\n\n\t#give me all folders with mp3-files inside, e.g. print them to stdout\n\tfolders_with_audio_files(root)\n\t#give me all folder that need a specific fix, aka dry-mode\n\tfolders_with_audio_files(root) | that_need_fix \n\t#actually apply a fix to these folders\n\tfolders_with_audio_files(root) | that_need_fix | apply_fix", "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/kaste/useless.pipes", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "useless.pipes", "package_url": "https://pypi.org/project/useless.pipes/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/useless.pipes/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/kaste/useless.pipes" }, "release_url": "https://pypi.org/project/useless.pipes/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "Generator sugar.", "version": "0.0.1" }, "last_serial": 743163, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "f3ea6a63b0aa8d4b71af11f8135e1abc", "sha256": "752f9334f36b4e11ecb6ba79afd5f595d2496246beb3b24e0b1ddfd91997a57e" }, "downloads": -1, "filename": "useless.pipes-0.0.1.zip", "has_sig": false, "md5_digest": "f3ea6a63b0aa8d4b71af11f8135e1abc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8658, "upload_time": "2012-04-15T12:08:30", "url": "https://files.pythonhosted.org/packages/a0/48/56a0f8a6f4158fb93f094792fde791f13c3bd3d99642a9647fadc5b6bb73/useless.pipes-0.0.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f3ea6a63b0aa8d4b71af11f8135e1abc", "sha256": "752f9334f36b4e11ecb6ba79afd5f595d2496246beb3b24e0b1ddfd91997a57e" }, "downloads": -1, "filename": "useless.pipes-0.0.1.zip", "has_sig": false, "md5_digest": "f3ea6a63b0aa8d4b71af11f8135e1abc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8658, "upload_time": "2012-04-15T12:08:30", "url": "https://files.pythonhosted.org/packages/a0/48/56a0f8a6f4158fb93f094792fde791f13c3bd3d99642a9647fadc5b6bb73/useless.pipes-0.0.1.zip" } ] }