{ "info": { "author": "Greg Price", "author_email": "gnprice@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Environment :: No Input/Output (Daemon)", "Environment :: Other Environment", "Environment :: Web Environment", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only" ], "description": "Pysh is a library for running external commands from a Python program,\nwith the usual concision and clarity that Python achieves in other domains.\n\n## Usage\n\nSimple commands are simple:\n\n from pysh import check_cmd, try_cmd\n\n check_cmd('gpg --decrypt --output {} {}', cleartext_path, cryptotext_path)\n\n if not try_cmd('git diff-index --quiet HEAD'):\n raise RuntimeError(\"worktree not clean\")\n\n repo_root = slurp_cmd('git rev-parse --show-toplevel')\n # \"slurp\" strips trailing newlines, just like shell `$(...)`\n\n### Writing command lines\n\nCommand lines offer a `format`-like minilanguage, powered by\n`pysh.shwords`. The format string is automatically split to form the\ncommand's list of arguments, providing shell-script-like\nconvenience... but the interpolated data never affects the split,\navoiding classic shell-script bugs.\n\n from pysh import shwords, check_cmd\n\n shwords('rm -rf {tmpdir}/{userdoc}', tmpdir='/tmp', userdoc='1 .. 2')\n # -> ['rm', '-rf', '/tmp/1 .. 2']\n\n check_cmd('rm -rf {tmpdir}/{userdoc}', tmpdir='/tmp', userdoc='1 .. 2')\n # removes `/tmp/1 .. 2` -- not `/tmp/1`, `..`, and `2`\n\nA format-minilanguage extension `{...!@}` substitutes in a whole list:\n\n check_cmd('grep -C2 TODO -- {!@}', files)\n\nEach function taking a command line also has a twin, named with `_f`,\nthat opts into f-string-like behavior:\n\n from pysh import check_cmd, check_cmd_f\n\n check_cmd_f('{compiler} {cflags!@} -c {source_file} -o {object_file}')\n\n # equivalent to:\n check_cmd('{} {!@} -c {} -o {}',\n compiler, cflags, source_file, object_file)\n\n### Pipelines\n\nPipelines are composed with the `|` operator. Each stage (or\n\"filter\") in the pipeline can be an external command, or Python code.\n\nMost often pipelines are built from the filters offered in the\n`pysh.cmd` module. You can consume the output with `pysh.slurp`:\n\n import pysh\n from pysh import cmd\n\n hello = pysh.slurp(cmd.echo(b'hello world')\n | cmd.run('tr h H'))\n # -> b'Hello world'\n\nOr iterate through it:\n\n for commit_id in (cmd.run('git rev-list -n10 -- {!@}', files)\n | cmd.splitlines()):\n # ... gets last 10 commits touching `files`\n\nYou can also write filters directly, using the `@pysh.filter`\ndecorator. See examples in the `example/` tree. This is also the same\nAPI that all the filters in `pysh.cmd` are built on, so there are many\nexamples there.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gnprice/pysh", "keywords": "scripting shell subprocess cli", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pysh-lib", "package_url": "https://pypi.org/project/pysh-lib/", "platform": "", "project_url": "https://pypi.org/project/pysh-lib/", "project_urls": { "Documentation": "https://github.com/gnprice/pysh/blob/master/pysh/README.md", "Examples": "https://github.com/gnprice/pysh/tree/master/example", "Homepage": "https://github.com/gnprice/pysh" }, "release_url": "https://pypi.org/project/pysh-lib/0.0.1/", "requires_dist": [ "click (>=7.0)" ], "requires_python": ">=3.7", "summary": "Pythonically simple alternative to shell scripts and subprocess", "version": "0.0.1" }, "last_serial": 5728762, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "e195ba47af6646d106dd0e0128a1c2f0", "sha256": "76433547e7676a813f06f5fe8d2502d4168e3f851c1d18ace1e0d65a2c903e10" }, "downloads": -1, "filename": "pysh_lib-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e195ba47af6646d106dd0e0128a1c2f0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 11813, "upload_time": "2019-08-26T03:35:09", "url": "https://files.pythonhosted.org/packages/a3/88/48cda987c0c9d8cd30a5231c0f254eef518d41ca7e212000964951df8f3f/pysh_lib-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1003b0ba76fd33c7d7817e096d580288", "sha256": "f53be93cdca259dfec002dc37d73021b77e1b82b6168c0701665c66671d04ae4" }, "downloads": -1, "filename": "pysh-lib-0.0.1.tar.gz", "has_sig": false, "md5_digest": "1003b0ba76fd33c7d7817e096d580288", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 14405, "upload_time": "2019-08-26T03:35:11", "url": "https://files.pythonhosted.org/packages/20/d4/5fe713810afb588f983af6640e0c12c46742f34ff692627ad6019c153575/pysh-lib-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e195ba47af6646d106dd0e0128a1c2f0", "sha256": "76433547e7676a813f06f5fe8d2502d4168e3f851c1d18ace1e0d65a2c903e10" }, "downloads": -1, "filename": "pysh_lib-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e195ba47af6646d106dd0e0128a1c2f0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 11813, "upload_time": "2019-08-26T03:35:09", "url": "https://files.pythonhosted.org/packages/a3/88/48cda987c0c9d8cd30a5231c0f254eef518d41ca7e212000964951df8f3f/pysh_lib-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1003b0ba76fd33c7d7817e096d580288", "sha256": "f53be93cdca259dfec002dc37d73021b77e1b82b6168c0701665c66671d04ae4" }, "downloads": -1, "filename": "pysh-lib-0.0.1.tar.gz", "has_sig": false, "md5_digest": "1003b0ba76fd33c7d7817e096d580288", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 14405, "upload_time": "2019-08-26T03:35:11", "url": "https://files.pythonhosted.org/packages/20/d4/5fe713810afb588f983af6640e0c12c46742f34ff692627ad6019c153575/pysh-lib-0.0.1.tar.gz" } ] }