#!/usr/bin/python

from pyparsing import *
from optparse import OptionParser
import os
from os.path import join,exists
from shutil import copy

usage = "usage: %prog --old <old namespace> --new <new namespace> <directory root>"

parser = OptionParser(usage=usage)

parser.add_option("-q", "--quiet",
                          action="store_false", dest="verbose",
                          help="be vewwy quiet (I'm hunting wabbits)")

parser.add_option("-o", "--old", 
                          metavar="old", help="Old namespace")

parser.add_option("-n", "--new",
                          default="new", help="New namespace")

(options, args) = parser.parse_args()

old_ns = options.old
new_ns = options.new

# grammar

comment = '#' + SkipTo(lineEnd)

module_ns = Word(alphanums + '-' + '_' + '.')
old_module_ns = Combine(old_ns + Optional(Combine('.'+module_ns)))
end_of_python_line = Or([lineEnd,comment])

as_suffix = 'as' + module_ns

import_pure = 'import' + old_module_ns 
import_pure_line = import_pure + Optional(as_suffix) + end_of_python_line

import_from = 'from' + old_module_ns + 'import' + module_ns 
import_from_line = import_from + Optional(as_suffix) + end_of_python_line

import_line = Or([import_pure_line, import_from_line])

# Make a list of Python files to deal with

try:
    f = args[0]
except IndexError:
    print 'Specify a directory root'
    exit(1)

for root, dirs, files in os.walk(f):
    for n in files:
        if (n.endswith('.py')):
            full_path = '/'.join([root,n])
            orig_path = full_path + '.orig'
            print 'Working on %s:'%full_path
            if (not os.path.exists(orig_path)):
                print 'Copying %s->%s:'%(full_path,orig_path)
                copy(full_path, orig_path)
            f_contents = open(orig_path).read()
            new_contents = []
            for l in f_contents.splitlines():
                try:
                    match = import_line.parseString(l)
                    l = l.replace(old_ns, new_ns)
                except ParseException:
                    pass
                new_contents.append(l)

            new_file = '\n'.join(new_contents)
            if (f_contents.endswith('\n')):
                new_file+='\n'
            open(full_path,'w').write(new_file)
