diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index e6de8e13..0ecc2f27 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -1402,8 +1402,8 @@ def put_postamble(MyDriver): txt += [' handle_exception ${catch_status} ${catch_message}'] txt += ['}'] txt += [''] - txt += ['clientput "file evaluation of sct_%s.tcl"' % MyDriver['name']] - txt += ['%s::sics_log 9 "file evaluation of sct_%s.tcl"' % (MyDriver['namespace'], MyDriver['name'])] + txt += ['clientput "file evaluation of %s"' % MyDriver['filename']] + txt += ['%s::sics_log 9 "file evaluation of %s"' % (MyDriver['namespace'], MyDriver['filename'])] emit(txt) def put_read_config(MyDriver): @@ -1532,10 +1532,16 @@ def generate_driver(MyDriver): global NumberOfLinesOut global fdo 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: - full_filename = os.path.join(MyDriver['PathName'], filename) - fdo = open(full_filename, 'w') + full_old_name = os.path.join(MyDriver['PathName'], old_name) + 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_standard_code(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'] for l in MyDriver['Funcs'][f]['text']: 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): if Verbose: @@ -1605,6 +1622,7 @@ def process_source(source_files): def main(): global Verbose + global Move global DriverDump global CodeDump import argparse @@ -1614,6 +1632,8 @@ def main(): action="store_true") parser.add_argument("-d", "--driver", help="dump driver", action="store_true") + parser.add_argument("-m", "--move", help="generate move commands", + action="store_true") parser.add_argument("-v", "--verbose", help="verbose output", action="store_true") parser.add_argument("driver_source", help="driver source file", nargs="*") @@ -1627,6 +1647,10 @@ def main(): DriverDump = True else: DriverDump = False + if args.move: + Move = True + else: + Move = False if args.verbose: Verbose = True else: