elif '"' not in arg and '$' not in arg:
quoted = '"%s"' % arg
else:
- raise NotImplementedError,'Unable to quote %r' % arg
+ raise NotImplementedError('Unable to quote %r' % arg)
print >>file, quoted,
# For debugging / validation.
import ShUtil
dequoted = list(ShUtil.ShLexer(quoted).lex())
if dequoted != [arg]:
- raise NotImplementedError,'Unable to quote %r' % arg
+ raise NotImplementedError('Unable to quote %r' % arg)
for r in self.redirects:
if len(r[0]) == 1:
def toShell(self, file, pipefail=False):
if pipefail != self.pipe_err:
- raise ValueError,'Inconsistent "pipefail" attribute!'
+ raise ValueError('Inconsistent "pipefail" attribute!')
if self.negate:
print >>file, '!',
for cmd in self.commands:
reference = self.lex_arg_slow(c)
if res is not None:
if res != reference:
- raise ValueError,"Fast path failure: %r != %r" % (res, reference)
+ raise ValueError("Fast path failure: %r != %r" % (
+ res, reference))
if self.pos != end:
- raise ValueError,"Fast path failure: %r != %r" % (self.pos, end)
+ raise ValueError("Fast path failure: %r != %r" % (
+ self.pos, end))
return reference
def lex_arg(self, c):
def parse_command(self):
tok = self.lex()
if not tok:
- raise ValueError,"empty command!"
+ raise ValueError("empty command!")
if isinstance(tok, tuple):
- raise ValueError,"syntax error near unexpected token %r" % tok[0]
+ raise ValueError("syntax error near unexpected token %r" % tok[0])
args = [tok]
redirects = []
op = self.lex()
arg = self.lex()
if not arg:
- raise ValueError,"syntax error near token %r" % op[0]
+ raise ValueError("syntax error near token %r" % op[0])
redirects.append((op, arg))
return Command(args, redirects)
assert isinstance(operator, tuple) and len(operator) == 1
if not self.look():
- raise ValueError, "missing argument to operator %r" % operator[0]
+ raise ValueError(
+ "missing argument to operator %r" % operator[0])
# FIXME: Operator precedence!!
lhs = Seq(lhs, operator[0], self.parse_pipeline())
res = executeShCmd(cmd.rhs, cfg, cwd, results)
return res
- raise ValueError,'Unknown shell command: %r' % cmd.op
+ raise ValueError('Unknown shell command: %r' % cmd.op)
assert isinstance(cmd, ShUtil.Pipeline)
procs = []