srcanamdw_os/leavescan/test/LET/initcase.py
changeset 0 83f4b4db085c
child 2 99082257a271
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 import time
       
     2 import sys
       
     3 import os
       
     4 from os.path import isdir
       
     5 def getCurTime():
       
     6 	curTime = time.localtime()
       
     7 	return str(curTime[0])+"-"+str(curTime[1])+"-"+str(curTime[2])+" "+str(curTime[3])+":"+str(curTime[4])+":"+str(curTime[5])
       
     8 
       
     9 def getForamtIndex(index):
       
    10 	if index<0:
       
    11 		return '000'
       
    12 	elif index<10:
       
    13 		return '00'+str(index)
       
    14 	elif index<100:
       
    15 		return '0'+str(index)
       
    16 	else:
       
    17 		return str(index)
       
    18 if __name__ == '__main__':
       
    19 	#init
       
    20 	cur_time = getCurTime()
       
    21 	type = 'CT'
       
    22 	USAGE = 'initcase outputdir name copies author'
       
    23 	copies = 10
       
    24 	args = sys.argv[1:]
       
    25 	args_len = len(args)
       
    26 	ok  = True
       
    27 	if args_len >= 3:
       
    28 		output_dir = args[0]
       
    29 		name = args[1]
       
    30 		copies = int(args[2])
       
    31 		if args_len>3:
       
    32 			author = args[3]
       
    33 		else:
       
    34 			author = 'Bolow'
       
    35 	else:
       
    36 		print USAGE
       
    37 
       
    38 	
       
    39 	#dir
       
    40 	if not os.path.exists(output_dir):
       
    41 		#mkdir
       
    42 		os.makedirs(output_dir)
       
    43 
       
    44 	elif not os.path.isdir(output_dir):
       
    45 		print output_dir, 'is not a dir'
       
    46 		ok = False
       
    47 	if ok:
       
    48 		index = 0
       
    49 		while copies>0:
       
    50 			copies=copies-1
       
    51 			index = index + 1
       
    52 			outfile_name = output_dir+'\\'+name+'-'+getForamtIndex(index)+'.cpp'
       
    53 			print outfile_name
       
    54 			outfile = open(outfile_name,"w")
       
    55 			outfile.write ( '//desc:\n' )
       
    56 			outfile.write ( '//option:\n' )
       
    57 			outfile.write ('//date:'+cur_time+'\n')
       
    58 			outfile.write ('//author:'+author+'\n')
       
    59 			outfile.write ('//type: CT\n')
       
    60 			outfile.close()
       
    61 			
       
    62 	
       
    63