]>
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
):
24 level
= _countIndentationLevel(line
)
25 line
= line
[level
:] # Slice off the indentation
31 for level
, line
in getblocks(fd
):
32 oldLevel
= len(opts
) - 1
34 run(itertools
.chain(*opts
))
36 opts
= opts
[:level
] # Delete all options that belong to groups that are indented more than this one
37 assert len(opts
) == level
, 'Seems we missed some options somewhere'
39 opts
.append(shlex
.split(line
))
42 run(itertools
.chain(*opts
))
48 batchProcess(open(name
))
50 if __name__
== "__main__":