]>
code.delx.au - transcoding/blob - batchrun.py
3 import optparse
, shlex
, subprocess
, sys
, itertools
6 parser
= optparse
.OptionParser(usage
="%prog batchfile1 [batchfile2] ...")
7 opts
, args
= parser
.parse_args(sys
.argv
[1:])
11 subprocess
.Popen(args
).wait()
14 def _countIndentationLevel(s
):
25 continue # Ignore blank lines
26 level
= _countIndentationLevel(line
)
27 line
= line
[level
:] # Slice off the indentation
33 for level
, line
in getblocks(fd
):
34 oldLevel
= len(opts
) - 1
36 run(itertools
.chain(*opts
))
38 opts
= opts
[:level
] # Delete all options that belong to groups that are indented more than this one
39 assert len(opts
) == level
, 'Seems we missed some options somewhere'
41 opts
.append(shlex
.split(line
))
44 run(itertools
.chain(*opts
))
50 batchProcess(open(name
))
52 if __name__
== "__main__":