コード例 #1
0
ファイル: test_parse.py プロジェクト: inouekazu/crmsh
 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
ファイル: parse.py プロジェクト: aomoriringo/crmsh
 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