-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplaceName.py
executable file
·43 lines (36 loc) · 1.08 KB
/
replaceName.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
directory = 'test'
nombreAntiguo = 'seedApp'
nombreNuevo = ''
try:
nombreAntiguo = sys.argv[2]
except IndexError:
pass
try:
for directory in ['app','test','dist']:
nombreNuevo = sys.argv[1]
for dname, dirs, files in os.walk(directory):
for fname in files:
fpath = os.path.join(dname, fname)
with open(fpath) as f:
s = f.read()
s = s.replace(nombreAntiguo, nombreNuevo)
s.replace
with open(fpath, "w") as f:
f.write(s)
for fpath in ['Gruntfile.js','bower.json','./app/index.html']:
with open(fpath) as f:
s = f.read()
s = s.replace(nombreAntiguo, nombreNuevo)
s.replace
with open(fpath, "w") as f:
f.write(s)
sys.exit(0)
except IndexError:
print "uso: " + sys.argv[0] + " nombreNuevo [nombreAntiguo]"
print "nombreNuevo: obligatorio"
print "nombreAntiguo: opcional (default:seedApp)"
sys.exit(1)