# HG changeset patch # User Paul Boddie # Date 1225144169 -3600 # Node ID 690d2f3d3bd3f249274b162d5a2eb2228b936fbe # Parent 0ac9701862dff6315aab8d9ac9e1c9a94b0c3ed0 Changed the script to use more widely available Python features. Put the main program in a function to permit easier program invocation. diff -r 0ac9701862df -r 690d2f3d3bd3 astgrep.py --- a/astgrep.py Mon Oct 27 20:47:35 2008 +0100 +++ b/astgrep.py Mon Oct 27 22:49:29 2008 +0100 @@ -22,6 +22,7 @@ import compiler import os +import linecache __version__ = "0.1" @@ -108,11 +109,13 @@ # Main program. -if __name__ == "__main__": +def run_command(): + + "The functionality of the main program." + import sys import cmdsyntax import re - import linecache # Match command arguments. @@ -166,4 +169,7 @@ print format % tuple(output) +if __name__ == "__main__": + run_command() + # vim: tabstop=4 expandtab shiftwidth=4 diff -r 0ac9701862df -r 690d2f3d3bd3 scripts/astgrep --- a/scripts/astgrep Mon Oct 27 20:47:35 2008 +0100 +++ b/scripts/astgrep Mon Oct 27 22:49:29 2008 +0100 @@ -1,3 +1,7 @@ #!/bin/sh -python -m astgrep $* +# Python 2.4 and later: +#python -m astgrep $* + +# Python 2.0 and later: +python -c "import astgrep; astgrep.run_command()" $*