Пример #1
0
def _parse_parameters(text):
    def _ParserCB(d, argv):
        for param in argv:
            if param.find("=") > 0:
                key, value = param.split("=", 1)
                d[key] = value

    d = {}
    p = shparser.ShellParser(aid.partial(_ParserCB, d))
    p.feed(text)
    p.feed("\n")
    return d
Пример #2
0
    def test_shparser(self):
        argv = None

        def _check_argv(argv):
            self.assertEqual(argv[0], "echo")
            self.assertEqual(argv[1], "-q")
            self.assertEqual(argv[3], "")
            self.assertEqual(argv[9], "bogus one")
            self.assertEqual(argv[10], argv[11])

        sh = shparser.ShellParser(_check_argv)
        rv = sh.feedline(
            'echo -q -N "" -t tparm -b 1024 -f "bogus one" $PATH ${PATH}')
Пример #3
0
 def test_shparser(self):
     sh = shparser.ShellParser(_print_argv)
     args = sh.feedline(
         'echo -q -N "" -t tparm -b 1024 -f "bogus one" $PATH ${PATH}')
     print args