{ "info": { "author": "Panos Mavrogiorgos", "author_email": "pmav99@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development", "Topic :: System", "Topic :: Utilities" ], "description": "# fxr\n\n[![Travis](https://travis-ci.org/pmav99/fxr.svg?branch=master)](https://travis-ci.org/pmav99/fxr)\n[![coveralls](https://coveralls.io/repos/pmav99/fxr/badge.svg?branch=master&service=github)](https://coveralls.io/r/pmav99/fxr)\n\n`fxr` (pronounced \"fixer\") is a CLI utility that can be used to find matching patterns in text files\nand:\n\n* append/prepend lines\n* delete lines before/after the matching line.\n* replace text\n\nIn other words, you can consider it as a replacement for `ag`, `xargs` and `sed` (with a nicer API!)\n\n**Warning**: *`fxr` currently has no dry-run mode and by default changes files inplace. If you want\nbackups, you need to explicitly enable them!\n\n## Installation\n\nAll you need is Python `2.7+/3.3+` and a search program like\n[`ag`](https://github.com/ggreer/the_silver_searcher):\n\n```\npip install -U fxr\npip install --user -U fxr # this will install fxr on ~/.local/\n```\n\nThe latest version is `0.2.5`:\n\n## Modes of operation\n\n`fxr` has three modes of operations:\n\n* `fxr add`\n* `fxr delete`\n* `fxr replace`\n\n### `fxr add`\n\nIn this mode you search for lines matching `` and you append/prepend text to them.\n\n```\nfxr add # Appends text to lines matching pattern\nfxr add --prepend # Prepends text to lines matching pattern\n```\n\n### `fxr delete`\n\nIn this mode you search for lines matching `` and you can:\n\n1. delete N lines preceding the matching line\n2. delete M lines following the matching line\n3. delete the matching line itself\n4. or any combination of the above!\n\nE.g. to delete 3 lines before the line matching pattern, 2 lines after it and the matching line\nitself:\n\n```\nfxr delete --before 3 --after 2 --include_line \n```\n\n### `fxr replace`\n\nIn this mode you can replace text on a single line. This is more or less equivalent to:\n\n```\nag -l | xargs sed -i 's///g'\n```\n\nYou can use it like this:\n\n```\nfxr replace \n```\n\n## Common interface\n\nAll the above subcommands share the following flags/arguments:\n\n* `--backup`: The provided value is used as a prefix for the backup files. If it is not provided,\n the changes are being done in-place.\n* `--literal`: When you set this flag, the pattern will not be parsed as a regex.\n* `--raise-if-no-change`: When you set this flag, an exception will be raised if there were no\n changes in the file.\n* `--single `: When you specify this argument, fxr will only try to do its magic on the\n specified file. I.e. `ag` will not be used.\n* `--search_prog`: If you don't like `ag` you can specify an alternate program (e.g. `rg`).\n* `--search_args`: You can specify additional arguments for the search program.\n\n## Notes\n\n### Rationale\n\nThere were two compelling arguments that made me write this:\n\n1. `sed` regex engine is quite limited. E.g. there is no support for look-aheads and other more\n advanced features, which you don't really need, until you need them!\n ([link](https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html)).\n\n2. The API for combining `ag`, `sed` and `xargs` is clunky at best (e.g. repeating `` both\n in `ag` and `sed` etc). E.g.:\n `ag -l | xargs sed -i 's///g'`\n\n\n### Performance\n\nThe script has not been written with performance in mind. Since the search for matching files is\nbeing done using `ag`, performance shouldn't be too bad, but keep in mind that the main use case\nis to make changes to source code and configuration files; not a multi-GB CSV file/database dump.\n\n### Search programs\n\nIf you wish to use a different program than `ag` you can do so by using the appropriate `CLI` argument.\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pmav99/fxr", "keywords": "fxr,search,find,replace,find and replace,search and replace", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "fxr", "package_url": "https://pypi.org/project/fxr/", "platform": "", "project_url": "https://pypi.org/project/fxr/", "project_urls": { "Homepage": "https://github.com/pmav99/fxr" }, "release_url": "https://pypi.org/project/fxr/0.2.5/", "requires_dist": null, "requires_python": "", "summary": "Pythonic Find and Replacetest", "version": "0.2.5" }, "last_serial": 3478841, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "e6e029af48b4579fed9f4b3e59e935a5", "sha256": "98e18c59a7e5720be36fa62f7770ea7de46ef606ad959bd84cb00c8ae45d02e5" }, "downloads": -1, "filename": "fxr-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e6e029af48b4579fed9f4b3e59e935a5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8799, "upload_time": "2017-08-21T19:41:02", "url": "https://files.pythonhosted.org/packages/12/91/ccdd1f6442139970b8c0ce1a6377b2f8ec1741164ef7441b0064ec570fe3/fxr-0.2.0-py2.py3-none-any.whl" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "153cb44fa043575987705a76f4e36ef5", "sha256": "ab427db04b82936c97a7fe6cdd94f1e0ff49a44699c8aae0c7d9069e75263c90" }, "downloads": -1, "filename": "fxr-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "153cb44fa043575987705a76f4e36ef5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8890, "upload_time": "2017-08-21T20:35:38", "url": "https://files.pythonhosted.org/packages/96/ed/c88237cd37de045b3626d1481d1a73c96369d8f0723c75917bc465b3b3fd/fxr-0.2.1-py2.py3-none-any.whl" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "a9594aaf1c7d189517eec7306ed662c7", "sha256": "ec78fee369243b413b50198b9948041ed4ed7e876decf06b9ddea94a4e31ef24" }, "downloads": -1, "filename": "fxr-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a9594aaf1c7d189517eec7306ed662c7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9112, "upload_time": "2017-08-22T07:04:45", "url": "https://files.pythonhosted.org/packages/71/55/d80499d8de3116247d96a3b24cca621ead010008dded439ac92c651c7f14/fxr-0.2.2-py2.py3-none-any.whl" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "02ea790222522eb4fb642a368ff140af", "sha256": "ed18f0d5394df445a31a41a61ce530eff8ae6801eba5eb11e96ded2e874b686c" }, "downloads": -1, "filename": "fxr-0.2.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "02ea790222522eb4fb642a368ff140af", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9197, "upload_time": "2017-08-22T08:46:15", "url": "https://files.pythonhosted.org/packages/2a/11/9595d615d010d3feef24b5e1036dffa7d51a66e8f9208edb2b1c5202a5bc/fxr-0.2.3-py2.py3-none-any.whl" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "677c7f4bf1c01e3d3f3c5ab9e6cc0023", "sha256": "fe25bdc10e3276b3769880cf56bdebaddc1733df975d27954b57e8490f1f9f25" }, "downloads": -1, "filename": "fxr-0.2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "677c7f4bf1c01e3d3f3c5ab9e6cc0023", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8643, "upload_time": "2018-01-10T20:51:47", "url": "https://files.pythonhosted.org/packages/88/38/df4f28fa90e634615af50f2feec46eebac99855fe14394308de6cf3312fa/fxr-0.2.4-py2.py3-none-any.whl" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "5e9e498cbf36e01cbd71a398bb3510b3", "sha256": "0f16bf103fd83d433c583c971e8d2ae70ddd3bda5c9a5c39a5e7c12965b64d4b" }, "downloads": -1, "filename": "fxr-0.2.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5e9e498cbf36e01cbd71a398bb3510b3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8632, "upload_time": "2018-01-10T20:56:35", "url": "https://files.pythonhosted.org/packages/d3/34/619225a557219a88f92ddf190599df94185a1f1677e3da56f0242ac7361d/fxr-0.2.5-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5e9e498cbf36e01cbd71a398bb3510b3", "sha256": "0f16bf103fd83d433c583c971e8d2ae70ddd3bda5c9a5c39a5e7c12965b64d4b" }, "downloads": -1, "filename": "fxr-0.2.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5e9e498cbf36e01cbd71a398bb3510b3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8632, "upload_time": "2018-01-10T20:56:35", "url": "https://files.pythonhosted.org/packages/d3/34/619225a557219a88f92ddf190599df94185a1f1677e3da56f0242ac7361d/fxr-0.2.5-py2.py3-none-any.whl" } ] }