SEESenv/scripts/changenames.py
author amit@thunder
Wed, 10 Mar 2010 00:04:25 +0530
changeset 44 d0e9b52bda73
parent 43 134b87b382f5
permissions -rw-r--r--
Changed the algorithm for getting the titles ... Also added the ability to navigate to the next chapters
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)
44
d0e9b52bda73 Changed the algorithm for getting the titles ... Also added the ability to navigate to the next chapters
amit@thunder
parents: 43
diff changeset
    13
       
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
    14
    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
    15
        changed_name=name    
44
d0e9b52bda73 Changed the algorithm for getting the titles ... Also added the ability to navigate to the next chapters
amit@thunder
parents: 43
diff changeset
    16
    command="mv %s %s" %(name ,changed_name) 
d0e9b52bda73 Changed the algorithm for getting the titles ... Also added the ability to navigate to the next chapters
amit@thunder
parents: 43
diff changeset
    17
    subprocess.Popen(command,shell=True)
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
    18
    time.sleep(2)
44
d0e9b52bda73 Changed the algorithm for getting the titles ... Also added the ability to navigate to the next chapters
amit@thunder
parents: 43
diff changeset
    19