def solve_arg(self, name, arg, ns):
        if name in ns:
            return (True, None, ns[name])

        if arg['type'] == 'interface':
            iname = arg['name']
            int_query = 'filter_type="interface" and name="%s"' % iname
            iface = self.api._model_query('filters', int_query)
            if len(iface) == 0:
                return (False, 'unknown interface "%s"' % iname, None)

            if len(iface) > 1:
                return (False, 'multiple definitions of iface "%s"' % iname,
                        None)

            iface_query = iface[0]['full_expr']
            nodes = self.api._model_query('nodes', iface_query)

            if len(nodes) == 0:
                return (False, 'unsatisifed interface "%s"' % iname, None)

            if len(nodes) == 1:
                return (True, None, nodes[0]['id'])

            return (False, 'Multiple interfaces for "%s"' % arg['name'],
                    [x['id'] for x in nodes])

        return (False, 'I cannot solve for type "%s"' % arg['type'], None)
dataset/ETHPy150Open rcbops/opencenter/opencenter/webapp/solver.py/Solver.solve_arg/original