@@ -33,25 +33,32 @@ def Scriptit(psct):
3333 # init needed vars
3434 psctcopy = psct
3535 psctcopy .lower ()
36- convtuple = ("error" , "tuple not changed" , "" )
36+ convtuple = ("error" , 100 , "tuple not changed" , "" )
3737
3838 # until scriptranslate is out of targets
39- while convtuple [1 ] != "" :
39+ while convtuple [1 ] != 0 :
40+ #find a scriptable bit of psct
4041 convtuple = scriptranslate (psctcopy )
41- # remove the scripted bit from the psct
42+ #remove scriptable bit from psct
4243 psctcopy = psctcopy .replace (convtuple [0 ], "" ,1 )
43- print (convtuple [0 ])
4444
45+ # stop scripting if an error is returned
46+ if convtuple [0 ] == "error" :
47+ print (convtuple )
48+ return
49+
4550 # iterate over the replacements to do
46- for i in range (2 , len (convtuple ), 2 ):
51+ print (convtuple [0 ])
52+ for i in range (3 , len (convtuple ), 2 ):
4753 # select output
4854 with open (filename , 'r' ) as file :
4955 filedata = file .read ()
5056 # Replace the target string
51- filedata = filedata .replace (convtuple [i - 1 ], convtuple [i ],1 )
57+ filedata = filedata .replace (convtuple [i - 1 ], convtuple [i ], convtuple [ 1 ] )
5258 # Write replacement in
5359 with open (filename , 'w' ) as file :
5460 file .write (filedata )
61+
5562
5663 # if psct has text left, print it
5764 if re .search ('[a-z1-9]' , psctcopy ) is not None :
0 commit comments