示例#1
0
 def _parse_lines(self, lines):
     out = []
     for line in lines2cli(lines):
         if line:
             tmp = self.parser.parse(line.strip())
             self.assertNotEqual(tmp, False)
             if tmp:
                 out.append(tmp.to_list())
     return out
示例#2
0
 def _parse_lines(self, lines):
     out = []
     for line in lines2cli(lines):
         if line is not None:
             tmp = self.parser.parse(line.strip())
             self.assertNotEqual(tmp, False)
             if tmp is not None:
                 out.append(tmp)
     return out
示例#3
0
 def _xml_lex(self, s):
     try:
         l = lines2cli(s)
         a = []
         for p in l:
             a += p.split()
         return a
     except ValueError, e:
         common_err(e)
         return False
示例#4
0
 def _xml_lex(self, s):
     try:
         l = lines2cli(s)
         a = []
         for p in l:
             a += p.split()
         return a
     except ValueError, e:
         common_err(e)
         return False
示例#5
0
def mk_cli_list(cli):
    'Sometimes we get a string and sometimes a list.'
    if isinstance(cli, basestring):
        cp = parse.CliParser()
        mv = MockValidation()
        for p in cp.parsers.values():
            p.validation = mv
        # what follows looks strange, but the last string actually matters
        # the previous ones may be comments and are collected by the parser
        for s in utils.lines2cli(cli):
            cli_list = cp.parse2(s)
        return cli_list
    else:
        return cli