Pratik Vyas | c1e6e4c | 2011-06-08 14:37:15 +0530 | [diff] [blame] | 1 | import os |
| 2 | |
| 3 | def replace_code(old, new): |
| 4 | txt = os.popen("""grep "%s" ./*/*/*/*.js""" % old).read().split() |
| 5 | txt = [t.split(':')[0] for t in txt] |
| 6 | txt = list(set(filter(lambda t: t.startswith('./'), txt))) |
| 7 | for t in txt: |
| 8 | if new: |
| 9 | code = open(t,'r').read().replace(old, new) |
| 10 | open(t, 'w').write(code) |
| 11 | print "Replaced for %s" % t |
| 12 | else: |
| 13 | print 'Found in %s' % t |
| 14 | |
| 15 | if __name__=='__main__': |
| 16 | old = """\.button(""" |
| 17 | new = "" |
| 18 | replace_code(old, new) |
| 19 | |