/[escript]/trunk/escript/py_src/runmodel.py
ViewVC logotype

Diff of /trunk/escript/py_src/runmodel.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 637 by gross, Thu Mar 23 10:55:31 2006 UTC revision 918 by gross, Wed Jan 3 06:30:00 2007 UTC
# Line 27  __date__="$Date$" Line 27  __date__="$Date$"
27  from esys.escript import modelframe  from esys.escript import modelframe
28  import optparse  import optparse
29    
30  parser = optparse.OptionParser(usage="\n%prog [options]\n%prog files...")  parser = optparse.OptionParser(usage="%prog [options] <ESySXML files>")
31  parser.add_option('-f', '--file', dest='filename',  parser.add_option('-f', '--file', dest='filename',
32          help='the FILE', metavar='FILE')          help='the input ESySXML file', metavar='FILE')
33  parser.add_option('-n', '--old-name', action="store",  parser.add_option('-d', '--debug', dest='dbg', action="store_true",
34          help='the old filename, used in aup',          help='switch debug on', default=False)
35          dest='old_name', default='')  parser.add_option('-n', '--new', action="store",
36            help='output ESySXML file',
37            dest='new_file_name', default='')
38  def main():  def main():
39      (options, args) = parser.parse_args()      (options, args) = parser.parse_args()
     if options.filename and args:  
         parser.usage("Please only specifiy 1 file if using --file=")  
40      if options.filename:      if options.filename:
41          files = [(file(options.filename), options.filename)]         filenames=list(options.filename) + args
42      elif args:      else:
43          files = [(file(arg), arg) for arg in args]         filenames=args
44      else:      if len(filenames)<1:
45          parser.usage          parser.error("no input file.")
46    
47        files = [(file(arg), arg) for arg in filenames]
48      for f, filename in files:      for f, filename in files:
49                    xml = modelframe.ESySXMLParser(f.read(), debug=options.dbg)
50          simstring = f.read()          sims = xml.parse()
51          sim = modelframe.parse(simstring)          for s in sims:
52          print sim            if isinstance(s, modelframe.Simulation):
53          sim.run()                 if options.new_file_name: s.writeXML(file(options.new_file_name,'w'))
54                   s.run()
55    
56  if __name__=='__main__':  if __name__=='__main__':
57      main()      main()

Legend:
Removed from v.637  
changed lines
  Added in v.918

  ViewVC Help
Powered by ViewVC 1.1.26