# Path: capirca/lib/nacaddr.py
# def IP(ip, comment='', token='', strict=True):
# def _is_subnet_of(a, b):  # pylint: disable=invalid-name
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def AddComment(self, comment=''):
#   def supernet(self, prefixlen_diff=1):
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def supernet(self, prefixlen_diff=1):
#   def AddComment(self, comment=''):
# def _InNetList(adders, ip):
# def IsSuperNet(supernets, subnets):
# def CollapseAddrListPreserveTokens(addresses):
# def _SafeToMerge(address, merge_target, check_addresses):
# def _CollapseAddrListInternal(addresses, complements_by_network):
# def CollapseAddrList(addresses, complement_addresses=None):
# def SortAddrList(addresses):
# def RemoveAddressFromList(superset, exclude):
# def AddressListExclude(superset, excludes, collapse_addrs=True):
# class IPv4(ipaddress.IPv4Network):
# class IPv6(ipaddress.IPv6Network):
# class PrefixlenDiffInvalidError(ipaddress.NetmaskValueError):
# 
# Path: capirca/lib/port.py
# class Error(Exception):
# class BadPortValue(Error):
# class BadPortRange(Error):
# class InvalidRange(Error):
# class NotSinglePort(Error):
# class PPP:
#   def __init__(self, service):
#   def is_range(self):
#   def is_single_port(self):
#   def start(self):
#   def end(self):
#   def __contains__(self, other):
#   def __lt__(self, other):
#   def __gt__(self, other):
#   def __le__(self, other):
#   def __ge__(self, other):
#   def __eq__(self, other):
# def Port(port):


import glob
import os
import re
from absl import logging
from capirca.lib import nacaddr
from capirca.lib import port as portlib
            # One of the services in query is undefined, refine the error msg.
            raise UndefinedServiceError('%s (in %s)' % (e, query))
      else:
        expandset.add(service)
    return sorted(expandset)

  def GetPortParents(self, query, proto):
    """Returns a list of all service tokens containing the port/protocol pair.

    Args:
        query: port number ('22') as str
        proto: protocol name ('tcp') as str

    Returns:
        A list of service tokens: ['SSH', 'HTTPS']

    Raises:
      UndefinedPortError: If the port/protocol pair isn't used in any
      service tokens.
    """
    # turn the given port and protocol into a PortProtocolPair object
    given_ppp = portlib.PPP(query + '/' + proto)
    base_parents = []
    matches = set()
    # check each service token to see if it's a PPP or a nested group.
    # if it's a PPP, see if there's a match with given_ppp
    # otherwise, add nested group to a list to recurisvely check later.
    # if there's no match, do nothing.
    for service_token in self.services:
      for port_child in self.services[service_token].items:

# Path: capirca/lib/nacaddr.py
# def IP(ip, comment='', token='', strict=True):
# def _is_subnet_of(a, b):  # pylint: disable=invalid-name
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def AddComment(self, comment=''):
#   def supernet(self, prefixlen_diff=1):
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def supernet(self, prefixlen_diff=1):
#   def AddComment(self, comment=''):
# def _InNetList(adders, ip):
# def IsSuperNet(supernets, subnets):
# def CollapseAddrListPreserveTokens(addresses):
# def _SafeToMerge(address, merge_target, check_addresses):
# def _CollapseAddrListInternal(addresses, complements_by_network):
# def CollapseAddrList(addresses, complement_addresses=None):
# def SortAddrList(addresses):
# def RemoveAddressFromList(superset, exclude):
# def AddressListExclude(superset, excludes, collapse_addrs=True):
# class IPv4(ipaddress.IPv4Network):
# class IPv6(ipaddress.IPv6Network):
# class PrefixlenDiffInvalidError(ipaddress.NetmaskValueError):
# 
# Path: capirca/lib/port.py
# class Error(Exception):
# class BadPortValue(Error):
# class BadPortRange(Error):
# class InvalidRange(Error):
# class NotSinglePort(Error):
# class PPP:
#   def __init__(self, service):
#   def is_range(self):
#   def is_single_port(self):
#   def start(self):
#   def end(self):
#   def __contains__(self, other):
#   def __lt__(self, other):
#   def __gt__(self, other):
#   def __le__(self, other):
#   def __ge__(self, other):
#   def __eq__(self, other):
# def Port(port):


# Path: capirca/lib/naming.py
import glob
import os
import re
from absl import logging
from capirca.lib import nacaddr
from capirca.lib import port as portlib

            # One of the services in query is undefined, refine the error msg.
            raise UndefinedServiceError('%s (in %s)' % (e, query))
      else:
        expandset.add(service)
    return sorted(expandset)

  def GetPortParents(self, query, proto):
    """Returns a list of all service tokens containing the port/protocol pair.

    Args:
        query: port number ('22') as str
        proto: protocol name ('tcp') as str

    Returns:
        A list of service tokens: ['SSH', 'HTTPS']

    Raises:
      UndefinedPortError: If the port/protocol pair isn't used in any
      service tokens.
    """
    # turn the given port and protocol into a PortProtocolPair object
    given_ppp = portlib.PPP(query + '/' + proto)
    base_parents = []
    matches = set()
    # check each service token to see if it's a PPP or a nested group.
    # if it's a PPP, see if there's a match with given_ppp
    # otherwise, add nested group to a list to recurisvely check later.
    # if there's no match, do nothing.
    for service_token in self.services:
      for port_child in self.services[service_token].items:

        ppp = portlib.PPP(port_child)