{ "info": { "author": "Marcin Sztolcman", "author_email": "marcin@urzenia.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Other Audience", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Text Processing", "Topic :: Utilities" ], "description": "subst\n=====\n\n``subst`` is simple utility to replace one string into another in given\nlist of files.\n\nCurrent stable version\n----------------------\n\n0.4.0\n\nBut why?\n--------\n\n1. There is ``sed`` for example?\n\n Yes, it is. But ``sed`` use regexps engine called \"Basic Regular\n Expressions\", or \"Extended Regular Expression\". PCRE is much more\n widely used dialect.\n\n2. So I can use Perl!\n\n Of course you can. But not everyone know how to use Perl. I know, but\n ``subst`` is IMHO simpler to use.\n\nOK, so how to use it?\n---------------------\n\nSimple\n------\n\n::\n\n echo 'Hello World!' | subst -s 's/Hello/Hi/' -\n\nor:\n\n::\n\n subst -p '(192\\.168)\\.1\\.(10)' -r '\\1.0.\\2' /etc/hosts\n\nMore\n----\n\nEverything is in help :) Just execute:\n\n::\n\n subst --help\n\nLook at result:\n\n::\n\n % subst --help\n usage: subst.py [-h] [-p PATTERN] [-r REPLACE] [--eval-replace] [-t STRING]\n [-s \"s/PAT/REP/gixsm\"] [-c COUNT] [-l] [-i]\n [--pattern-dot-all] [--pattern-verbose] [--pattern-multiline]\n [--utf8] [--encoding-input ENCODING_INPUT]\n [--encoding-file ENCODING_FILE]\n [--encoding-filesystem ENCODING_FILESYSTEM] [-b] [-e EXT]\n [--stdin] [--stdout] [--verbose] [--debug] [-v]\n [files [files ...]]\n\n Replace PATTERN with REPLACE in many files.\n\n positional arguments:\n files file to parse.\n\n optional arguments:\n -h, --help show this help message and exit\n -p PATTERN, --pattern PATTERN\n pattern to replace for. Supersede --pattern-and-\n replace. Required if --replace is specified.\n -r REPLACE, --replace REPLACE\n replacement. Supersede --pattern-and-replace. Required\n if --pattern is specified.\n --eval-replace if specified, make eval data from --replace(should be\n valid Python code). Ignored with --pattern-and-replace\n argument.\n -t STRING, --string STRING\n if specified, treats --pattern as string, not as\n regular expression. Ignored with --pattern-and-replace\n argument.\n -s \"s/PAT/REP/gixsm\", --pattern-and-replace \"s/PAT/REP/gixsm\", --pattern-and-replace \"s/PAT/REP/gixsm\"\n pattern and replacement in one:\n s/pattern/replace/g(pattern is always regular\n expression, /g is optional and stands for --count=0,\n /i == --ignore-case, /s == --pattern-dot-all, /m ==\n --pattern-multiline).\n -c COUNT, --count COUNT\n make COUNT replacements for every file (0 makes\n unlimited changes, default).\n -l, --linear apply pattern for every line separately. Without this\n flag whole file is read into memory.\n -i, --ignore-case ignore case of characters when matching\n --pattern-dot-all with this flag, dot(.) character in pattern match also\n new line character (see:\n http://docs.python.org/2/library/re.html#re.DOTALL).\n --pattern-verbose with this flag pattern can be passed as verbose(see:\n http://docs.python.org/2/library/re.html#re.VERBOSE).\n --pattern-multiline with this flag pattern can be passed as multiline(see:\n http://docs.python.org/2/library/re.html#re.MULTILINE)\n .\n --utf8, -u Use UTF-8 in --encoding-input, --encoding-file and\n --encoding-filesystem\n --encoding-input ENCODING_INPUT\n set encoding for parameters like --pattern etc\n (default for your system: ascii)\n --encoding-file ENCODING_FILE\n set encoding for content of processed files (default\n for your system: ascii)\n --encoding-filesystem ENCODING_FILESYSTEM\n set encoding for paths and filenames (default for your\n system: utf-8)\n -b, --no-backup disable creating backup of modified files.\n -e EXT, --backup-extension EXT\n extension for backup files(ignore if no backup is\n created), without leading dot. Defaults to: \"bak\".\n --stdin read data from STDIN(implies --stdout)\n --stdout output data to STDOUT instead of change files in-\n place(implies --no-backup)\n --verbose show files and how many replacements was done\n --debug show more informations\n -v, --version show version and exit\n\n Miscellaneous notes:\n * regular expressions engine used here is PCRE, dialect from Python\n * is required to pass either --pattern and -replace, or --pattern-and-\n replace argument\n * if pattern passed to --pattern-and-replace has /g modifier, it\n overwrites --count value\n * if neither /g modifier nor --count argument is passed, assume that\n --count is equal 1\n * if only --count is given, this value is used\n * if --eval-replace is given, --replace must be valid Python code, where\n can be used m variable.m holds MatchObject instance (see:\n http://http://docs.python.org/2/library/re.html#match-objects, for\n example:\n --eval-replace --replace 'm.group(1).lower()'\n * regular expressions with non linear search read whole file to yours\n computer memory - if file size is bigger then you have memory in your\n computer, it fails\n * parsing expression passed to --pattern-and-replace argument is very\n simple - if you use / as delimiter, then in your expression can't be\n used this character anymore. If you need to use same character as\n delimiter and in expression, then better use --pattern and --replace\n argument\n\n Security notes:\n * be carefull with --eval-replace argument. When it's given, value\n passed to --replace is eval-ed, so any not safe code will be executed!\n\n Author:\n Marcin Sztolcman // http://urzenia.net\n\n HomePage:\n http://mysz.github.io/subst/\n\nSome examples?\n--------------\n\nSimple replace word 'Hello' with 'Hi' in data read from STDIN:\n\n::\n\n echo 'Hello World!' | subst -s 's/Hello/Hi/' -\n\nReplace every IP address in form: 192.168.1.X (where X is few digits -\nsingle octet) with 192.168.0.X in ``/etc/hosts``:\n\n::\n\n subst -p '(192\\.168)\\.1\\.(10)' -r '\\1.0.\\2' /etc/hosts\n\nInstallation\n------------\n\n``subst`` should work on any platform where\n`Python `__ is available, it means Linux, Windows,\nMacOS X etc. There is no dependencies, plain Python power :)\n\nTo install, go to `GitHub\nreleases `__, download newest\nrelease, unpack and put somewhere in ``PATH`` (ie. ``~/bin`` or\n``/usr/local/bin``).\n\nIf You want to install newest unstable version, then just copy file to\nyour PATH, for example:\n\n::\n\n curl https://raw.github.com/mysz/subst/master/subst.py > /usr/local/bin/subst\n\nor:\n\n::\n\n wget https://raw.github.com/mysz/subst/master/subst.py -O /usr/local/bin/subst\n\nVoila!\n\nAuthors\n-------\n\nMarcin Sztolcman marcin@urzenia.net\n\nContact\n-------\n\nIf you like or dislike this software, please do not hesitate to tell me\nabout this me via email (marcin@urzenia.net).\n\nIf you find bug or have an idea to enhance this tool, please use\nGitHub's `issues `__.\n\nLicense\n-------\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Marcin Sztolcman\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nChangeLog\n---------\n\nv0.4.0\n~~~~~~\n\n- PEP8 improvements (coding style)\n- Makefile added\n- improved pylintrc\n\nv0.3.1\n~~~~~~\n\n- prepared and uploaded to PYPI\n- typos and editorials\n\nv0.3\n~~~~\n\n- better handling of non-ascii encoding in files, patterns etc\n- higher priority for --pattern-\\* switches then modifiers in\n --pattern-and-replace\n- unified switches syntax (was --pattern\\_and\\_replace, but other\n switches used dashes)\n- pep8\n- typos and editorials\n\nv0.2\n~~~~\n\n- second public version", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://mysz.github.io/subst/", "keywords": "sed text processing", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "subst", "package_url": "https://pypi.org/project/subst/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/subst/", "project_urls": { "Homepage": "http://mysz.github.io/subst/" }, "release_url": "https://pypi.org/project/subst/0.4.0/", "requires_dist": [ "argparse" ], "requires_python": null, "summary": "`subst` is simple utility to replace one string into another in given list of files.", "version": "0.4.0" }, "last_serial": 1548005, "releases": { "0.3.1": [ { "comment_text": "", "digests": { "md5": "2d9584658670bc588d4b089e68a57922", "sha256": "e92ae55e7eeeec42ee5fbbe4579e90c752589dfd7d1f6c64207b5a217b9ab71b" }, "downloads": -1, "filename": "subst-0.3.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "2d9584658670bc588d4b089e68a57922", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14619, "upload_time": "2014-11-14T22:41:12", "url": "https://files.pythonhosted.org/packages/37/bd/91d78e5c0a14b491cac07032f8665b1b73bfc41bb9820db7c0bdc28d2d39/subst-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "60d7a8a92af62bb5540c08c689645cec", "sha256": "d05586bbf3984aff9284a137c6964839881ace33ba16c3184c512c4466019904" }, "downloads": -1, "filename": "subst-0.3.1.tar.gz", "has_sig": true, "md5_digest": "60d7a8a92af62bb5540c08c689645cec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13972, "upload_time": "2014-11-14T22:41:16", "url": "https://files.pythonhosted.org/packages/e2/7b/f568bf8229f95fb7f4279e1779e94f9dc6389f771e102bba466f0ff13022/subst-0.3.1.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "78126c90fc66bb863a050fe1541dfbbd", "sha256": "a6f8564da04835a6e7cd133122c5453f7705d427ee6ed47cf09a733114aa5f56" }, "downloads": -1, "filename": "subst-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "78126c90fc66bb863a050fe1541dfbbd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14849, "upload_time": "2015-05-15T05:53:21", "url": "https://files.pythonhosted.org/packages/7b/f7/c56d07bca5ea51d206c03789f9e1827db56a4f41213d153158c34e2b1eac/subst-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c08e82d970844662c30b48edb2614d62", "sha256": "489165efa1b5ab140fc26de0f577885be3a4f7507b0a3484496fb8bda039f229" }, "downloads": -1, "filename": "subst-0.4.0.tar.gz", "has_sig": false, "md5_digest": "c08e82d970844662c30b48edb2614d62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11526, "upload_time": "2015-05-15T05:53:25", "url": "https://files.pythonhosted.org/packages/e6/ea/72047d83ae4e15bf181b0d274bce1a00a9c8e7b78ba7a9b413a34e9d3627/subst-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "78126c90fc66bb863a050fe1541dfbbd", "sha256": "a6f8564da04835a6e7cd133122c5453f7705d427ee6ed47cf09a733114aa5f56" }, "downloads": -1, "filename": "subst-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "78126c90fc66bb863a050fe1541dfbbd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14849, "upload_time": "2015-05-15T05:53:21", "url": "https://files.pythonhosted.org/packages/7b/f7/c56d07bca5ea51d206c03789f9e1827db56a4f41213d153158c34e2b1eac/subst-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c08e82d970844662c30b48edb2614d62", "sha256": "489165efa1b5ab140fc26de0f577885be3a4f7507b0a3484496fb8bda039f229" }, "downloads": -1, "filename": "subst-0.4.0.tar.gz", "has_sig": false, "md5_digest": "c08e82d970844662c30b48edb2614d62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11526, "upload_time": "2015-05-15T05:53:25", "url": "https://files.pythonhosted.org/packages/e6/ea/72047d83ae4e15bf181b0d274bce1a00a9c8e7b78ba7a9b413a34e9d3627/subst-0.4.0.tar.gz" } ] }