import os
import sys
import zipfile

from nose import core as nose_core

if sys.argv[1] == "remove_extension":
    so_names = """
        tracer.so
        tracer.cpython-32m.so
        """.split()

    for filename in so_names:
        try:
            os.remove(os.path.join("coverage", filename))
        except OSError:
            pass

elif sys.argv[1] == "test_with_tracer":
    os.environ["COVERAGE_TEST_TRACER"] = sys.argv[2]
    del sys.argv[1:3]
    nose_core.main()

elif sys.argv[1] == "zip_mods":
    zipfile.ZipFile("test/zipmods.zip", "w").write("test/covmodzip1.py", "covmodzip1.py")

@@ -1,114 +1,329 @@
-import os%0Aimport sys%0Aimport zipfile%0A%0Afrom nose import core as nose_core%0A%0Aif sys.argv%5B1%5D == %22remove_extension%22:
+%22%22%22Helper for building, testing, and linting coverage.py.%0A%0ATo get portability, all these operations are written in Python here instead%0Aof in shell scripts, batch files, or Makefiles.%0A%0A%22%22%22%0A%0Aimport os%0Aimport sys%0Aimport zipfile%0A%0Adef do_remove_extension(args):%0A    %22%22%22Remove the compiled C extension, no matter what its name.%22%22%22%0A
 %0A   
@@ -554,47 +554,109 @@
 ss%0A%0A
-elif sys.argv%5B1%5D == %22
+def do_test_with_tracer(args):%0A    %22%22%22Run nose
 test
-_
+s 
 with
-_tracer%22:
+ a particular tracer.%22%22%22%0A    import nose.core
 %0A   
@@ -697,40 +697,55 @@
 %5D = 
-sys.argv%5B2%5D%0A    del sys.argv
+args%5B0%5D%0A    nose_args = %5B%22nosetests%22%5D + args
 %5B1:
-3
 %5D%0A  
@@ -750,17 +750,17 @@
     nose
-_
+.
 core.mai
@@ -765,46 +765,94 @@
 ain(
-)%0A%0Aelif sys.argv%5B1%5D == %22
+argv=nose_args)%0A%0Adef do_zip_mods(args):%0A    %22%22%22Build the 
 zip
-_
 mods
-%22:%0A   
+.zip file.%22%22%22%0A    zf =
  zip
@@ -888,16 +888,23 @@
 p%22, %22w%22)
+%0A    zf
 .write(%22
@@ -941,8 +941,249 @@
 p1.py%22)%0A
+%0A%0Adef main(args):%0A    handler = globals().get('do_'+args%5B0%5D)%0A    if handler is None:%0A        print(%22*** No handler for %25r%22 %25 args%5B0%5D)%0A        return 1%0A    return handler(args%5B1:%5D)%0A%0Aif __name__ == '__main__':%0A    sys.exit(main(sys.argv%5B1:%5D))%0A

Make igor more respectable.