Antoni Segura Puimedon has posted comments on this change.
Change subject: Functional Tests [2/3]: Added ipwrapper.ruleExists+routeExists ......................................................................
Patch Set 3:
(2 comments)
.................................................... File lib/vdsm/ipwrapper.py Line 251: command += route Line 252: _execCmd(command) Line 253: Line 254: Line 255: def _getValidEntries(ofType, outOf): How about this:
def _getValidEntries(constructor, iterator): for element in iterator: try: yield constructor(iterator) except ValueError: pass
So using code reads:
return route in _getValidEntries(Route.fromText, routeShowTable('all')) return rule in _getValidEntries(Rule.fromText, ruleList()) Line 256: for entry in outOf: Line 257: try: Line 258: yield ofType.fromText(entry) Line 259: except ValueError:
Line 260: pass Line 261: Line 262: Line 263: def routeExists(route): Line 264: return route in _getValidEntries(ofType=Route, sorry that my comment was not clearer. I meant something easier:
return route in (Route.fromText(entry) for entry in routeShowTable('all') if _validate(Route, entry))
The same below. Anyway, I guess this is okay too. Line 265: outOf=routeShowTable('all')) Line 266: Line 267: Line 268: def ruleList():