1071
by matt.giuca
Moved all script files into newly created 'bin' directory (cleanup). |
1 |
#!/usr/bin/env python
|
2 |
||
3 |
import os, stat, sys |
|
4 |
||
5 |
def update(file, pattern, replacement, verbose=False): |
|
6 |
if verbose: |
|
7 |
print "Updating:", file |
|
8 |
||
9 |
# make sure we can write the file
|
|
10 |
old_perm = os.stat(file)[0] |
|
11 |
if not os.access(file, os.W_OK): |
|
12 |
os.chmod(file, old_perm | stat.S_IWRITE) |
|
13 |
||
14 |
# write the file
|
|
15 |
s = open(file, 'rb').read() |
|
16 |
out = open(file, 'wb') |
|
17 |
out.write(s.replace(pattern, replacement)) |
|
18 |
out.close() |
|
19 |
||
20 |
# restore permissions
|
|
21 |
os.chmod(file, old_perm) |
|
22 |
||
23 |
||
24 |
old_uuid = "4d949360-5a40-0410-921c-d637654a4d6e" # IVLE at SourceForge |
|
25 |
new_uuid = "2b9c9e99-6f39-0410-b283-7f802c844ae2" # IVLE at GoogleCode |
|
26 |
||
27 |
for root, dirs, files in os.walk('.'): |
|
28 |
if root.endswith('.svn'): |
|
29 |
update(os.path.join(root, 'entries'), old_uuid, new_uuid, True) |
|
30 |
||
31 |