SEESenv/scripts/changenames.py
author amit@thunder
Tue, 02 Mar 2010 17:07:14 +0530
changeset 41 e54725be4df6
parent 40 ef147a79b098
child 43 134b87b382f5
permissions -rw-r--r--
Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
     1
import glob
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
     2
import subprocess
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
     3
import re
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
     4
import time
41
e54725be4df6 Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
amit@thunder
parents: 40
diff changeset
     5
import os
e54725be4df6 Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
amit@thunder
parents: 40
diff changeset
     6
import sys
e54725be4df6 Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
amit@thunder
parents: 40
diff changeset
     7
repo=sys.argv[1]
e54725be4df6 Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
amit@thunder
parents: 40
diff changeset
     8
names= glob.glob(os.path.join(repo,'ch1*.html'))
40
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
     9
for name in names:
41
e54725be4df6 Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
amit@thunder
parents: 40
diff changeset
    10
    reg_obj=re.compile(os.path.join(repo,'ch1[0-9].*.html'))
40
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
    11
    if (reg_obj.match(name)):
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
    12
        changed_name=re.sub('ch1','chn1',name)
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
    13
    else:
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
    14
        changed_name=name    
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
    15
    command="cp %s %s" %(name ,changed_name)
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
    16
    subprocess.Popen(command,shell=True)
ef147a79b098 Added change names to do required changes in names such that we get the chapter names beyond 10 in proper list
amit@thunder
parents:
diff changeset
    17
    time.sleep(2)