Not Logged In

massedit 0.66

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.

Warning

This tool is usefull as far as it goes but it does rely on the python
eval() function and does not check the code being executed.
It is a major security risk and one should not use this tool
in a production environment.

See Ned Batchelder’s article for a thorough discussion of the dangers
linked to eval() and ways to circumvent them. Note that None of the
counter-measure suggested in the article are implemented at this time.

Usage

You probably will need to know the basics of the Python re module (regular
expressions).

Installation

Plans

Add support for a file of expressions as an argument to allow multiple
modification at once.

Find a satisfactory way (ie. easy to use) to handle multiline regex as the
current version works on a line by line basis.

Add magic variables lineno and filename in addition to line.

Rationale

I have a hard time practicing more than a few dialects of regular
expressions.

I need something portable to Windows without being bothered by eol.

I believe Python is the ideal tool to build something more powerful than
simple regex based substitutions.

Background

I have been using runsed and checksed (from Unix Power Tools) for years and
did not find a good substitute under Windows until I came across Graham
Fawcett python recipe 437932 on ActiveState. It inspired me to write the
massedit.

The core was fleshed up a little, and here we are. If you find it useful and
enhance it please, do not forget to submit patches. Thanks!

If you are more interested in awk-like tool, you probably will find pyp a
better alternative. This is certainly a more mature tool.

License

Licensed under the term of MIT License. See attached file LICENSE.txt.