~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/svn_relocate.py

  • Committer: William Grant
  • Date: 2009-01-13 01:36:15 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1123
Merge setup-refactor branch. This completely breaks existing installations;
every path (both filesystem and Python) has changed. Do not upgrade without
knowing what you are doing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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