{ "info": { "author": "", "author_email": "rafa.cassau@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# pycommands\n[![CircleCI](https://circleci.com/gh/rafaelcassau/pycommands.svg?style=shield)](https://circleci.com/gh/rafaelcassau/pycommands)\n[![Codecov](https://codecov.io/gh/rafaelcassau/pycommands/branch/master/graph/badge.svg)](https://codecov.io/gh/rafaelcassau/pycommands)\n\nHandle a list of commands that should be executed easily and with undo support.\n\n# How to use\n\n## Install\npycommands is available on PyPI\n\n```bash\npip install pycommands\n```\n\n## Basic usage\n\n#### Definition of commands\n```python\nfrom commands.base import BaseCommand\nfrom commands.exceptions import CommandException\nfrom commands.invoker import Invoker\n\n\nclass Command1(BaseCommand):\n def build(self):\n return \"touch content.txt\"\n\n def build_undo(self):\n return \"rm content.txt\"\n\n\nclass Command2(BaseCommand):\n def build(self):\n return \"mv content.txt content-replaced.txt\"\n\n def build_undo(self):\n return \"mv content-replaced.txt content.txt\"\n\n\nclass InvalidCommand(BaseCommand):\n def build(self):\n raise CommandException()\n```\n\n#### Simple default execution with success commands\n\n```python\nfrom commands.invoker import Invoker\n\n\ninvoker = Invoker()\n\ninvoker.execute([\n Command1(),\n Command2(),\n], run_undo=False)\n\n# output\nrunning command: touch content.txt\nrunning command: mv content.txt content-replaced.txt\n\n\n# If a invoker.undo() is called then all commands undo operation will be done in the LIFO order.\n\ninvoker.undo()\n\n# output\nrunning undo command: mv content-replaced.txt content.txt\nrunning undo command: rm content.txt\n\n\n# If a invoker.execute() is called with run_undo as True, then the undo operation will be done always\n# that a command raise CommandException\n\ninvoker = Invoker()\n\ninvoker.execute([\n Command1(),\n Command2(),\n InvalidCommand(),\n], run_undo=True)\n\n# output\nrunning command: touch content.txt\nrunning command: mv content.txt content-replaced.txt\nrunning command: touch content.txt\nrunning command: mv content.txt content-replaced.txt\nrunning undo command: mv content-replaced.txt content.txt\nrunning undo command: rm content.txt\n```\n## How to contribute\n\nWe welcome contributions of many forms, for example:\n- Code (by submitting pull requests)\n- Documentation improvements\n- Bug reports and feature requests\n\n## Setting up for local development\n\nWe use pipenv to manage dependencies, so make sure you have it installed.\n\nCreating environment\n```bash\n//pipenv install --python=3\n```\n\nActiving environment\n```bash\n//pipenv shell\n```\n\nInstall pre-commit hooks:\n```bash\npre-commit install\n```\n\nRun tests by evoking pytest:\n```\npytest\n```\n\nThat's it! You're ready from development\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/rafaelcassau/pycommands", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pycommands", "package_url": "https://pypi.org/project/pycommands/", "platform": "", "project_url": "https://pypi.org/project/pycommands/", "project_urls": { "Homepage": "https://github.com/rafaelcassau/pycommands" }, "release_url": "https://pypi.org/project/pycommands/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Pycommands help you to build system remote call commands", "version": "0.0.1" }, "last_serial": 5636943, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d809083cab13c5b9dd815682e0047da3", "sha256": "91f34d88b260a55bf8a946cdd78dc5385c16a020d929dc6b82eb9101a782207c" }, "downloads": -1, "filename": "pycommands-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d809083cab13c5b9dd815682e0047da3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6835, "upload_time": "2019-08-05T23:55:17", "url": "https://files.pythonhosted.org/packages/56/d1/4dfecd568f2558b166974ad372df9a4e188b207e010ddc8657b4e3c7cdad/pycommands-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0dacc5f398199db86cb83e31ec068ad7", "sha256": "4f00d2dfd3022f0d219b5eaddf49912cffab67f8016dd46140f0743543bb42d6" }, "downloads": -1, "filename": "pycommands-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0dacc5f398199db86cb83e31ec068ad7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3750, "upload_time": "2019-08-05T23:55:19", "url": "https://files.pythonhosted.org/packages/dc/ff/d004782d95f7201957452a14933a4268f369af3ebd475dfc4f39217004ea/pycommands-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d809083cab13c5b9dd815682e0047da3", "sha256": "91f34d88b260a55bf8a946cdd78dc5385c16a020d929dc6b82eb9101a782207c" }, "downloads": -1, "filename": "pycommands-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d809083cab13c5b9dd815682e0047da3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6835, "upload_time": "2019-08-05T23:55:17", "url": "https://files.pythonhosted.org/packages/56/d1/4dfecd568f2558b166974ad372df9a4e188b207e010ddc8657b4e3c7cdad/pycommands-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0dacc5f398199db86cb83e31ec068ad7", "sha256": "4f00d2dfd3022f0d219b5eaddf49912cffab67f8016dd46140f0743543bb42d6" }, "downloads": -1, "filename": "pycommands-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0dacc5f398199db86cb83e31ec068ad7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3750, "upload_time": "2019-08-05T23:55:19", "url": "https://files.pythonhosted.org/packages/dc/ff/d004782d95f7201957452a14933a4268f369af3ebd475dfc4f39217004ea/pycommands-0.0.1.tar.gz" } ] }