def showlist(self, control, msg, items, prefix): if isinstance(items[0], basestring): items = [(i, '', 'OFF') for i in items] else: items = [(k, prefix + v, s) for k, v, s in items] extra = self.calc_height(msg) + flatten(items) return shlex.split(self.run(control, msg, extra).value)
def menu(self, msg='', items=(), prefix=' - '): if isinstance(items[0], basestring): items = [(i, '') for i in items] else: items = [(k, prefix + v) for k, v in items] extra = self.calc_height(msg) + flatten(items) return self.run('menu', msg, extra).value
def test_flatten(self): self.assertEqual(flatten([(0, 1), (2, 3)]), [0, 1, 2, 3])