# HG changeset patch # User catherine@cordelia # Date 1212493306 14400 # Node ID 67cde3f501de25343896f24a4322d539e5c9cfc2 # Parent b66372883bb437bc239255b7d85c13444511758f findpipe tested diff -r b66372883bb4 -r 67cde3f501de cmd2.py --- a/cmd2.py Mon May 26 13:54:45 2008 -0400 +++ b/cmd2.py Tue Jun 03 07:41:46 2008 -0400 @@ -175,11 +175,16 @@ result = "\n".join('%s: %s' % (sc[0], sc[1]) for sc in self.shortcuts.items()) self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) - pipeFinder = pyparsing.SkipTo(pyparsing.Literal('|') ^ pyparsing.StringEnd()) - pipeFinder.ignore(pyparsing.sglQuotedString) - pipeFinder.ignore(pyparsing.dblQuotedString) - pipeFinder.ignore("--" + pyparsing.ZeroOrMore(pyparsing.CharsNotIn("\n"))) # sql-style comment - pipeFinder.ignore(pyparsing.cStyleComment) + notAPipe = pyparsing.SkipTo('|') + notAPipe.ignore(pyparsing.sglQuotedString) + notAPipe.ignore(pyparsing.dblQuotedString) + pipeFinder = notAPipe + '|' + pyparsing.SkipTo(pyparsing.StringEnd()) + def findPipe(self, statement): + try: + statement, pipe, destination = pipeFinder.parseString(statement) + return statement, destination + except pyparsing.ParseException: + return statement, None legalFileName = re.compile(r'''^[^"'\s]+$''') def parseRedirector(self, statement, symbol, mustBeTerminated=False):