{ "info": { "author": "J\u00e9r\u00f4me Lecomte", "author_email": "elmotec@gmx.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development", "Topic :: Software Development :: Code Generators", "Topic :: Text Editors :: Text Processing", "Topic :: Text Processing :: Filters", "Topic :: Utilities" ], "description": ".. image:: https://img.shields.io/pypi/v/massedit.svg\n :target: https://pypi.python.org/pypi/massedit/\n :alt: PyPi version\n\n.. image:: https://img.shields.io/pypi/pyversions/massedit.svg\n :target: https://pypi.python.org/pypi/massedit/\n :alt: Python compatibility\n\n.. image:: https://img.shields.io/travis/elmotec/massedit.svg\n :target: https://travis-ci.org/elmotec/massedit\n :alt: Build Status\n\n.. image:: https://img.shields.io/pypi/dm/massedit.svg\n :alt: PyPi\n :target: https://pypi.python.org/pypi/massedit\n\n.. image:: https://coveralls.io/repos/elmotec/massedit/badge.svg\n :target: https://coveralls.io/r/elmotec/massedit\n :alt: Coverage\n\n.. image:: https://img.shields.io/codacy/474b0af6853a4c5f8f9214d3220571f9.svg\n :target: https://www.codacy.com/app/elmotec/massedit/dashboard\n :alt: Codacy\n\n\n========\nmassedit\n========\n\n*formerly known as Python Mass Editor*\n\nImplements a python mass editor to process text files using Python\ncode. The modification(s) is (are) shown on stdout as a diff output. One\ncan then modify the target file(s) in place with the -w/--write option.\nThis is very similar to 2to3 tool that ships with Python 3.\n\n\n+--------------------------------------------------------------------------+\n| **WARNING**: A word of caution about the usage of ``eval()`` |\n+--------------------------------------------------------------------------+\n| This tool is useful as far as it goes but it does rely on the python |\n| ``eval()`` function and does not check the code being executed. |\n| **It is a major security risk** and one should not use this tool in a |\n| production environment. |\n| |\n| See `Ned Batchelder's article`_ for a thorough discussion of the dangers |\n| linked to ``eval()`` and ways to circumvent them. Note that None of the |\n| counter-measure suggested in the article are implemented at this time. |\n+--------------------------------------------------------------------------+\n\nUsage\n-----\n\nYou probably will need to know the basics of the `Python re module`_ (regular\nexpressions).\n\n::\n\n usage: massedit.py [-h] [-V] [-w] [-v] [-e EXPRESSIONS] [-f FUNCTIONS]\n [-x EXECUTABLES] [-s START_DIRS] [-m MAX_DEPTH] [-o output]\n pattern [pattern ...]\n\n Python mass editor\n\n positional arguments:\n pattern shell-like file name patterns to process.\n\n optional arguments:\n -h, --help show this help message and exit\n -V, --version show program's version number and exit\n -w, --write modify target file(s) in place. Shows diff otherwise.\n -v, --verbose increases log verbosity (can be specified multiple\n times)\n -e EXPRESSIONS, --expression EXPRESSIONS\n Python expressions applied to target files. Use the\n line variable to reference the current line.\n -f FUNCTIONS, --function FUNCTIONS\n Python function to apply to target file. Takes file\n content as input and yield lines. Specify function as\n [module]:?.\n -x EXECUTABLES, --executable EXECUTABLES\n Python executable to apply to target file.\n -s START_DIRS, --start START_DIRS\n Directory(ies) from which to look for targets.\n -m MAX_DEPTH, --max-depth-level MAX_DEPTH\n Maximum depth when walking subdirectories.\n -o FILE, --output FILE\n redirect output to a file\n -g FILE, --generate FILE\n generate input file suitable for -f option\n --encoding ENCODING Encoding of input and output files\n --newline NEWLINE Newline charachter for output files\n\n Examples:\n # Simple string substitution (-e). Will show a diff. No changes applied.\n massedit.py -e \"re.sub('failIf', 'assertFalse', line)\" *.py\n\n # File level modifications (-f). Overwrites the files in place (-w).\n massedit.py -w -f fixer:main *.py\n\n # Will change all test*.py in subdirectories of tests.\n massedit.py -e \"re.sub('failIf', 'assertFalse', line)\" -s tests test*.py\n\n\nIf massedit is installed as a package (from pypi for instance), one can interact with it as a command line tool:\n\n::\n\n python -m massedit -e \"re.sub('assertEquals', 'assertEqual', line)\" test.py\n\n\nOr as a library (command line option above to be passed as kewyord arguments):\n\n::\n\n >>> import massedit\n >>> filenames = ['massedit.py']\n >>> massedit.edit_files(filenames, [\"re.sub('Jerome', 'J.', line)\"])\n\n\nLastly, there is a convenient ``massedit.bat`` wrapper for Windows included in\nthe distribution.\n\n\nInstallation\n------------\n\nDownload ``massedit.py`` from ``http://github.com/elmotec/massedit`` or :\n\n::\n\n pip install massedit\n\n\nPoor man source-to-source manipulation\n--------------------------------------\n\nI find myself using massedit mostly for source to source modification of\nlarge code bases like this:\n\nFirst create a ``fixer.py`` python module with the function that will\nprocess your source code. For instance, to add a header:\n\n::\n\n def add_header(lines, file_name):\n yield '// This is my header' # will be the first line of the file.\n for line in lines:\n yield line\n\n\nAdds the location of ``fixer.py`` to your ``$PYTHONPATH``, then simply\ncall ``massedit.py`` like this:\n\n::\n\n massedit.py -f fixer:add_header *.h\n\n\nYou can add the ``-s .`` option to process all the ``.h`` files reccursively.\n\n\nPlans\n-----\n\n- Add support for 3rd party tool (e.g. `autopep8`_) to process the files.\n- Add support for a file of expressions as an argument to allow multiple\n modification at once.\n- Find a satisfactory way (ie. easy to use) to handle multiline regex as the\n current version works on a line by line basis.\n\n\nRationale\n---------\n\n- I have a hard time practicing more than a few dialects of regular\n expressions.\n- I need something portable to Windows without being bothered by eol.\n- I believe Python is the ideal tool to build something more powerful than\n simple regex based substitutions.\n\n\nBackground\n----------\n\nI have been using runsed and checksed (from Unix Power Tools) for years and\ndid not find a good substitute under Windows until I came across Graham\nFawcett python recipe 437932_ on ActiveState. It inspired me to write the\nmassedit.\n\nThe core was fleshed up a little, and here we are. If you find it useful and\nenhance it please, do not forget to submit patches. Thanks!\n\nIf you are more interested in awk-like tool, you probably will find pyp_ a\nbetter alternative. This is certainly a more mature tool.\n\n\nLicense\n-------\n\nLicensed under the term of `MIT License`_. See attached file LICENSE.txt.\n\n\nChanges\n-------\n\n0.68.5 (2019-04-13)\n Added --newline option to force newline output. Thanks @ALFNeT!\n\n0.68.4 (2017-10-24)\n Fixed bug that would cause changes to be missed when the -w option is\n ommited. Thanks @tgoodlet!\n\n0.68.3 (2017-09-20)\n Added --generate option to quickly generate a fixer.py template file\n to be modified to be used with -f fixer.fixit option. Added official\n support for Python 3.6\n\n0.68.1 (2016-06-04)\n Fixed encoding issues when processing non-ascii files.\n Added --encoding option to force the value of the encoding if need be.\n Listed support for Python 3.5\n\n0.67.1 (2015-06-28)\n Documentation fixes.\n\n0.67 (2015-06-23)\n Added file_name argument to processing functions.\n Fixed incorrect closing of sys.stdout/stderr.\n Improved diagnostic when the processing function does not take 2 arguments.\n Swapped -v and -V option to be consistent with Python.\n Pylint fixes.\n Added support for Python 3.4.\n Dropped support for Python 3.2.\n\n0.66 (2013-07-14)\n Fixed lost executable bit with -f option (thanks myint).\n\n0.65 (2013-07-12)\n Added -f option to execute code in a separate file/module. Added Travis continuous integration (thanks myint). Fixed python 2.7 support (thanks myint).\n\n0.64 (2013-06-01)\n Fixed setup.py so that massedit installs as a script. Fixed eol issues (thanks myint).\n\n0.63 (2013-05-27)\n Renamed to massedit. Previous version are still known as Python-Mass-Editor.\n\n0.62 (2013-04-11)\n Fixed bug that caused an EditorError to be raised when the result of the\n expression is an empty string.\n\n0.61 (2012-07-06)\n Added massedit.edit_files function to ease usage as library instead of as\n a command line tool (suggested by Maxim Veksler).\n\n0.60 (2012-07-04)\n Treats arguments as patterns rather than files to ease processing of\n multiple files in multiple subdirectories. Added -s (start directory)\n and -m (max depth) options.\n\n0.52 (2012-06-05)\n Upgraded for python 3. Still compatible with python 2.7.\n\n0.51 (2012-05)\n Initial release (Beta).\n\n\nContributor acknowledgement\n---------------------------\n\nSteven Myint, https://github.com/myint\ntgoodlet, https://github/tgoodlet\n\n\n\n.. _437932: http://code.activestate.com/recipes/437932-pyline-a-grep-like-sed-like-command-line-tool/\n.. _Python re module: http://docs.python.org/library/re.html\n.. _Pyp: http://code.google.com/p/pyp/\n.. _MIT License: http://en.wikipedia.org/wiki/MIT_License\n.. _autopep8: http://pypi.python.org/pypi/autopep8\n.. _Ned Batchelder's article: http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/elmotec/massedit", "keywords": "sed editor stream python edit mass", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "massedit", "package_url": "https://pypi.org/project/massedit/", "platform": "", "project_url": "https://pypi.org/project/massedit/", "project_urls": { "Homepage": "http://github.com/elmotec/massedit" }, "release_url": "https://pypi.org/project/massedit/0.68.5/", "requires_dist": null, "requires_python": "", "summary": "Edit multiple files using Python text processing modules", "version": "0.68.5" }, "last_serial": 5138054, "releases": { "0.63": [ { "comment_text": "", "digests": { "md5": "a897e3aa3652dc4772ad86ff1dfc94ea", "sha256": "e30a051aec19c40cc3bab58e78de20226f007931e9899d5f0756c84dcf1f6dca" }, "downloads": -1, "filename": "massedit-0.63.zip", "has_sig": false, "md5_digest": "a897e3aa3652dc4772ad86ff1dfc94ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10190, "upload_time": "2013-05-28T01:39:05", "url": "https://files.pythonhosted.org/packages/c2/a9/7f3541ae1c92e09775faf079dc3cec4607053c9ec533228481b1468da97c/massedit-0.63.zip" } ], "0.64": [ { "comment_text": "", "digests": { "md5": "2c4106b55199e8d6707338e49a5cfb79", "sha256": "c0f4ec75401486e221915e0d920196d972c77ca67f53e334f79e46911a430e84" }, "downloads": -1, "filename": "massedit-0.64.zip", "has_sig": false, "md5_digest": "2c4106b55199e8d6707338e49a5cfb79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14758, "upload_time": "2013-06-01T14:36:17", "url": "https://files.pythonhosted.org/packages/8a/43/0c05350e42372e4a42a764e6f021422da96fc450727d8e9bb5dfb65e1ff6/massedit-0.64.zip" } ], "0.65": [ { "comment_text": "", "digests": { "md5": "396cfd75e94039a0f3926323b927dc0f", "sha256": "597b954aada7610b3423e64debe518dfbebe2056617fe57f789b27418c4b5d73" }, "downloads": -1, "filename": "massedit-0.65.zip", "has_sig": false, "md5_digest": "396cfd75e94039a0f3926323b927dc0f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22653, "upload_time": "2013-07-13T02:33:28", "url": "https://files.pythonhosted.org/packages/00/c6/ecbbe8d887487291e1786e4a93e5e9bbc6dc98011e59ea593f20ff157318/massedit-0.65.zip" } ], "0.66": [ { "comment_text": "", "digests": { "md5": "d096eb2442184a98bf576c99fa60d471", "sha256": "382a93953911851a9df073a229ba40d27c23983a147c268efc86d093eb0a39a1" }, "downloads": -1, "filename": "massedit-0.66.zip", "has_sig": false, "md5_digest": "d096eb2442184a98bf576c99fa60d471", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23010, "upload_time": "2013-07-14T23:14:38", "url": "https://files.pythonhosted.org/packages/49/48/14abbfd87d89f1f61f579000d79ef9bac94498b2ae42ddef65a6702217ae/massedit-0.66.zip" } ], "0.67": [ { "comment_text": "", "digests": { "md5": "331d7d3fdc2666aaaf235e33bc066b50", "sha256": "4cccf3f5a5198924c009c0d52fc16d7390b2515330a0db2b07154a269251372a" }, "downloads": -1, "filename": "massedit-0.67.win-amd64.exe", "has_sig": false, "md5_digest": "331d7d3fdc2666aaaf235e33bc066b50", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 280622, "upload_time": "2015-06-24T01:23:23", "url": "https://files.pythonhosted.org/packages/db/49/b1bea63ce1f3ab5231d4935e463aed54108c14ff0bbea3dcd015d967ed20/massedit-0.67.win-amd64.exe" }, { "comment_text": "", "digests": { "md5": "8d3bd3a177e0733f6d4f415101321615", "sha256": "6612a3427fe9dd49f931c9699d58308614fb8ac952b2d3d678e902ab3a8f371b" }, "downloads": -1, "filename": "massedit-0.67.zip", "has_sig": false, "md5_digest": "8d3bd3a177e0733f6d4f415101321615", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25015, "upload_time": "2015-06-24T01:23:19", "url": "https://files.pythonhosted.org/packages/0b/47/51a705941158fabb78761f38ba2c7f336659faa03bc18414fcfdc6e100cf/massedit-0.67.zip" } ], "0.67.1": [ { "comment_text": "", "digests": { "md5": "442c8ebafe2554e64af557a66422b133", "sha256": "831afab36d2e7b63792d3f7519506088a917a517754f372506e8e6db0ff4bc50" }, "downloads": -1, "filename": "massedit-0.67.1.win-amd64.exe", "has_sig": false, "md5_digest": "442c8ebafe2554e64af557a66422b133", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 281825, "upload_time": "2015-06-29T02:31:07", "url": "https://files.pythonhosted.org/packages/11/c5/8279b059acbba14cb4b24f1dca8a543314a54a83a292290a69d5bd7bf8a3/massedit-0.67.1.win-amd64.exe" }, { "comment_text": "", "digests": { "md5": "2d6f65651bc1e6e647830b56d01ee869", "sha256": "d055ad595c27c58d9d4352ee52f16e1a68340e731976bbe0f6036dddd5be1d3a" }, "downloads": -1, "filename": "massedit-0.67.1.zip", "has_sig": false, "md5_digest": "2d6f65651bc1e6e647830b56d01ee869", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25731, "upload_time": "2015-06-29T02:31:03", "url": "https://files.pythonhosted.org/packages/1d/00/9b79214ab12bf17c62ddde5b66f75b91d52f4fa2891c8ea09558a50bb491/massedit-0.67.1.zip" } ], "0.68.1": [ { "comment_text": "", "digests": { "md5": "50c455244136e6750e2f5d5d4949a658", "sha256": "61351560f009038a9de9d6b69c64d500ce3666893a216b8c45f151478e2e08fd" }, "downloads": -1, "filename": "massedit-0.68.1.zip", "has_sig": false, "md5_digest": "50c455244136e6750e2f5d5d4949a658", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27902, "upload_time": "2016-06-05T00:25:46", "url": "https://files.pythonhosted.org/packages/7b/84/96a8b87a4f240b986ebceda59a5ee3fae55bd7c4cd9da8ffdf58daa3122e/massedit-0.68.1.zip" } ], "0.68.2": [ { "comment_text": "", "digests": { "md5": "2c66b3c46a35663a31321f4c0fd4ece4", "sha256": "19d6a2831b726cb476c20e7e632fe8a7f409b5981096bacdc057b08645ded59b" }, "downloads": -1, "filename": "massedit-0.68.2.tar.gz", "has_sig": false, "md5_digest": "2c66b3c46a35663a31321f4c0fd4ece4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21687, "upload_time": "2017-09-20T23:21:52", "url": "https://files.pythonhosted.org/packages/e2/fc/5b870c39799026732e14caf48543dba1dec9e5061f995fed04f486d805f7/massedit-0.68.2.tar.gz" } ], "0.68.3": [ { "comment_text": "", "digests": { "md5": "4a7f008b9a1e9c54ab4c89a72d441425", "sha256": "6ad0f3bb84d5f311c8bddb9a7c691382364be3a3927e15ee4305f47c88287e45" }, "downloads": -1, "filename": "massedit-0.68.3.tar.gz", "has_sig": false, "md5_digest": "4a7f008b9a1e9c54ab4c89a72d441425", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21734, "upload_time": "2017-09-20T23:36:55", "url": "https://files.pythonhosted.org/packages/54/e0/3573d5fcd2fa2c98ea5bfff17439513526c0be3e38e1f0c2f73018ebe5a9/massedit-0.68.3.tar.gz" } ], "0.68.4": [ { "comment_text": "", "digests": { "md5": "032939fab3a89720f61a9ca89392b1d0", "sha256": "0b7c146b8fee2328969d42dcdc7132c78df2d15878d9173c1fc59bcadfbbfd6e" }, "downloads": -1, "filename": "massedit-0.68.4.tar.gz", "has_sig": false, "md5_digest": "032939fab3a89720f61a9ca89392b1d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22250, "upload_time": "2017-10-25T02:10:27", "url": "https://files.pythonhosted.org/packages/bb/9e/db1c72d178fd9b9bf3252deac63b9822423f8a4390e697d20173311891dc/massedit-0.68.4.tar.gz" } ], "0.68.5": [ { "comment_text": "", "digests": { "md5": "b957cfa79470dad5be967ec369d3b28a", "sha256": "5957d820d009f8d147ea658dfc7ed737cc372d66e1dba9f3290a620f401eca57" }, "downloads": -1, "filename": "massedit-0.68.5.tar.gz", "has_sig": false, "md5_digest": "b957cfa79470dad5be967ec369d3b28a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18781, "upload_time": "2019-04-13T13:08:51", "url": "https://files.pythonhosted.org/packages/99/33/9743b63e1937ada6381c17a96f914d26aae0935411b4020916e05f5aa423/massedit-0.68.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b957cfa79470dad5be967ec369d3b28a", "sha256": "5957d820d009f8d147ea658dfc7ed737cc372d66e1dba9f3290a620f401eca57" }, "downloads": -1, "filename": "massedit-0.68.5.tar.gz", "has_sig": false, "md5_digest": "b957cfa79470dad5be967ec369d3b28a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18781, "upload_time": "2019-04-13T13:08:51", "url": "https://files.pythonhosted.org/packages/99/33/9743b63e1937ada6381c17a96f914d26aae0935411b4020916e05f5aa423/massedit-0.68.5.tar.gz" } ] }