Code to generate the move/rename
This commit is contained in:
@ -1402,8 +1402,8 @@ def put_postamble(MyDriver):
|
|||||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||||
txt += ['}']
|
txt += ['}']
|
||||||
txt += ['']
|
txt += ['']
|
||||||
txt += ['clientput "file evaluation of sct_%s.tcl"' % MyDriver['name']]
|
txt += ['clientput "file evaluation of %s"' % MyDriver['filename']]
|
||||||
txt += ['%s::sics_log 9 "file evaluation of sct_%s.tcl"' % (MyDriver['namespace'], MyDriver['name'])]
|
txt += ['%s::sics_log 9 "file evaluation of %s"' % (MyDriver['namespace'], MyDriver['filename'])]
|
||||||
emit(txt)
|
emit(txt)
|
||||||
|
|
||||||
def put_read_config(MyDriver):
|
def put_read_config(MyDriver):
|
||||||
@ -1532,10 +1532,16 @@ def generate_driver(MyDriver):
|
|||||||
global NumberOfLinesOut
|
global NumberOfLinesOut
|
||||||
global fdo
|
global fdo
|
||||||
NumberOfLinesOut = 0
|
NumberOfLinesOut = 0
|
||||||
full_filename = filename = "sct_%s.tcl" % MyDriver['name']
|
old_name = "sct_%s.tcl" % MyDriver['name']
|
||||||
|
new_name = "%s_sct.tcl" % MyDriver['name']
|
||||||
if 'PathName' in MyDriver:
|
if 'PathName' in MyDriver:
|
||||||
full_filename = os.path.join(MyDriver['PathName'], filename)
|
full_old_name = os.path.join(MyDriver['PathName'], old_name)
|
||||||
fdo = open(full_filename, 'w')
|
full_new_name = os.path.join(MyDriver['PathName'], new_name)
|
||||||
|
else:
|
||||||
|
full_old_name = old_name
|
||||||
|
full_new_name = new_name
|
||||||
|
fdo = open(full_new_name, 'w')
|
||||||
|
MyDriver['filename'] = new_name
|
||||||
put_preamble(MyDriver)
|
put_preamble(MyDriver)
|
||||||
put_standard_code(MyDriver)
|
put_standard_code(MyDriver)
|
||||||
put_mkDriver(MyDriver)
|
put_mkDriver(MyDriver)
|
||||||
@ -1549,7 +1555,18 @@ def generate_driver(MyDriver):
|
|||||||
print "Function:", f, "Type:", MyDriver['Funcs'][f]['type'], '#Uses:', MyDriver['Funcs'][f]['reference_count']
|
print "Function:", f, "Type:", MyDriver['Funcs'][f]['type'], '#Uses:', MyDriver['Funcs'][f]['reference_count']
|
||||||
for l in MyDriver['Funcs'][f]['text']:
|
for l in MyDriver['Funcs'][f]['text']:
|
||||||
print " ", l
|
print " ", l
|
||||||
print "Produced file %s with %d lines." % (filename, NumberOfLinesOut)
|
print "Produced file %s with %d lines." % ( MyDriver['filename'], NumberOfLinesOut)
|
||||||
|
# This block of code generates shell commands to help the old->new rename
|
||||||
|
if Move:
|
||||||
|
fd = open("git_mv.sh", "a")
|
||||||
|
fd.write( "git mv " + full_old_name + " " + full_new_name + "\n")
|
||||||
|
fd.close()
|
||||||
|
fd = open("grep_sed.sh", "a")
|
||||||
|
fd.write( "for f in $(grep " + old_name + " instrument -Irl" + "); do\n")
|
||||||
|
fd.write( " echo ${f}\n")
|
||||||
|
fd.write( " sed -i ${f} -e 's/" + old_name + "/" + new_name + "/'\n")
|
||||||
|
fd.write( "done\n")
|
||||||
|
fd.close()
|
||||||
|
|
||||||
def process_drivers(TheDrivers):
|
def process_drivers(TheDrivers):
|
||||||
if Verbose:
|
if Verbose:
|
||||||
@ -1605,6 +1622,7 @@ def process_source(source_files):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
global Verbose
|
global Verbose
|
||||||
|
global Move
|
||||||
global DriverDump
|
global DriverDump
|
||||||
global CodeDump
|
global CodeDump
|
||||||
import argparse
|
import argparse
|
||||||
@ -1614,6 +1632,8 @@ def main():
|
|||||||
action="store_true")
|
action="store_true")
|
||||||
parser.add_argument("-d", "--driver", help="dump driver",
|
parser.add_argument("-d", "--driver", help="dump driver",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
|
parser.add_argument("-m", "--move", help="generate move commands",
|
||||||
|
action="store_true")
|
||||||
parser.add_argument("-v", "--verbose", help="verbose output",
|
parser.add_argument("-v", "--verbose", help="verbose output",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
parser.add_argument("driver_source", help="driver source file", nargs="*")
|
parser.add_argument("driver_source", help="driver source file", nargs="*")
|
||||||
@ -1627,6 +1647,10 @@ def main():
|
|||||||
DriverDump = True
|
DriverDump = True
|
||||||
else:
|
else:
|
||||||
DriverDump = False
|
DriverDump = False
|
||||||
|
if args.move:
|
||||||
|
Move = True
|
||||||
|
else:
|
||||||
|
Move = False
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
Verbose = True
|
Verbose = True
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user