def __init__(self,
               pol,
               src='any',
               dst='any',
               sport='any',
               dport='any',
               proto='any',
              ):

    self.pol_obj = pol
    self.proto = proto

    # validate source port
    if sport == 'any':
      self.sport = sport
    else:
      self.sport = port.Port(sport)

    # validate destination port
    if dport == 'any':
      self.dport = dport
    else:
      self.dport = port.Port(dport)

    # validate source address
    if src == 'any':
      self.src = src
    else:
      try:
        self.src = nacaddr.IP(src)
      except ValueError:
        raise AddressError('bad source address: %s\n' % src)

    # validate destination address
    if dst == 'any':
      self.dst = dst
    else:
      try:
        self.dst = nacaddr.IP(dst)
      except __HOLE__:
        raise AddressError('bad destination address: %s\n' % dst)

    if type(self.pol_obj) is not policy.Policy:
      raise BadPolicy('Policy object is not valid.')

    self.matches = []
    self.exact_matches = []
    for header, terms in self.pol_obj.filters:
      filtername = header.target[0].options[0]
      for term in terms:
        possible = []
        logging.debug('checking term: %s', term.name)
        if not self._AddrInside(self.src, term.source_address):
          logging.debug('srcaddr does not match')
          continue
        logging.debug('srcaddr matches: %s', self.src)
        if not self._AddrInside(self.dst, term.destination_address):
          logging.debug('dstaddr does not match')
          continue
        logging.debug('dstaddr matches: %s', self.dst)
        if (self.sport != 'any' and term.source_port and not
            self._PortInside(self.sport, term.source_port)):
          logging.debug('sport does not match')
          continue
        logging.debug('sport matches: %s', self.sport)
        if (self.dport != 'any' and term.destination_port and not
            self._PortInside(self.dport, term.destination_port)):
          logging.debug('dport does not match')
          continue
        logging.debug('dport matches: %s', self.dport)
        if (self.proto != 'any' and term.protocol and
            self.proto not in term.protocol):
          logging.debug('proto does not match')
          continue
        logging.debug('proto matches: %s', self.proto)
        if term.protocol_except and self.proto in term.protocol_except:
          logging.debug('protocol excepted by term, no match.')
          continue
        logging.debug('proto not excepted: %s', self.proto)
        if not term.action:  # avoid any verbatim
          logging.debug('term had no action (verbatim?), no match.')
          continue
        logging.debug('term has an action')
        possible = self._PossibleMatch(term)
        self.matches.append(Match(filtername, term.name, possible, term.action,
                                  term.qos))
        if possible:
          logging.debug('term has options: %s, not treating as exact match',
                        possible)
          continue

        # if we get here then we have a match, and if the action isn't next and
        # there are no possibles, then this is a "definite" match and we needn't
        # look for any further matches (i.e. later terms may match, but since
        # we'll never get there we shouldn't report them)
        if 'next' not in term.action:
          self.exact_matches.append(Match(filtername, term.name, [],
                                          term.action, term.qos))
          break
dataset/ETHPy150Open google/capirca/lib/aclcheck.py/AclCheck.__init__