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
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
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
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