1 |
#!/usr/bin/python |
2 |
# $Id$ |
3 |
import modelframe |
4 |
|
5 |
#commandline utility to take an xml file, parse it, and run a simulation. |
6 |
# invoke this by doing ./runmodel.py <filename.xml> |
7 |
|
8 |
import optparse |
9 |
|
10 |
parser = optparse.OptionParser(usage="\n%prog [options]\n%prog files...") |
11 |
parser.add_option('-f', '--file', dest='filename', |
12 |
help='the FILE', metavar='FILE') |
13 |
parser.add_option('-n', '--old-name', action="store", |
14 |
help='the old filename, used in aup', |
15 |
dest='old_name', default='') |
16 |
def main(): |
17 |
(options, args) = parser.parse_args() |
18 |
if options.filename and args: |
19 |
parser.usage("Please only specifiy 1 file if using --file=") |
20 |
if options.filename: |
21 |
files = [(file(options.filename), options.filename)] |
22 |
elif args: |
23 |
files = [(file(arg), arg) for arg in args] |
24 |
else: |
25 |
parser.usage() |
26 |
|
27 |
for f, filename in files: |
28 |
|
29 |
simstring = f.read() |
30 |
sim = modelframe.parse(simstring) |
31 |
print sim |
32 |
|
33 |
if __name__=='__main__': |
34 |
main() |
35 |
|