Python Mass Editor is a Python module that implements a python mass editor class to process multiple files using Python code. The modification(s) is (are) shown on stdout as a diff output. One can then modify the target file(s) in place with the -w/--write option.
Usage
You probably will need to know the basics of the Python re module (regular expressions).
usage: massedit.py [-h] [-v] [-w] [-V] [-e EXPRESSIONS] file [file ...]
Python based mass file editor
positional arguments:
file file to process with the expression. Modified in
place.
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-w, --write modify target file(s) in place
-V, --verbose increases log verbosity (can be specified multiple
times)
-e EXPRESSIONS, --expression EXPRESSIONS
Python expressions to be applied on all files. Use the
line variable to reference the current line.
example: massedit.py -e "re.sub('failIf', 'assertFalse', line)" test*.py
or if massedit is installed as a package (from pypi for instance) :
python -mmassedit -e "re.sub('assertEquals', 'assertEqual', line)" test_pre_python_33.py
Installation
Download massedit.py from http://github.com/elmotec/massedit or :
pip install massedit
Product's homepage
Requirements:
· Python
What's New in This Release: [ read full changelog ]
· Added massedit.edit_files function to ease usage as library instead of as a command line tool (suggested by Maxim Veksler).