# Path: capirca/lib/aclgenerator.py
# class Error(Exception):
# class NoPlatformPolicyError(Error):
# class UnknownIcmpTypeError(Error):
# class MismatchIcmpInetError(Error):
# class EstablishedError(Error):
# class UnsupportedAFError(Error):
# class DuplicateTermError(Error):
# class UnsupportedFilterError(Error):
# class UnsupportedTargetOptionError(Error):
# class TermNameTooLongError(Error):
# class Term:
# class ACLGenerator:
#   ICMP_TYPE = policy.Term.ICMP_TYPE
#   PROTO_MAP = {'hopopt': 0,
#                'icmp': 1,
#                'igmp': 2,
#                'ggp': 3,
#                'ipip': 4,
#                'tcp': 6,
#                'egp': 8,
#                'igp': 9,
#                'udp': 17,
#                'rdp': 27,
#                'ipv6': 41,
#                'ipv6-route': 43,
#                'fragment': 44,
#                'rsvp': 46,
#                'gre': 47,
#                'esp': 50,
#                'ah': 51,
#                'icmpv6': 58,
#                'ipv6-nonxt': 59,
#                'ipv6-opts': 60,
#                'ospf': 89,
#                'pim': 103,
#                'vrrp': 112,
#                'l2tp': 115,
#                'sctp': 132,
#                'udplite': 136,
#                'all': -1,  # Used for GCE default deny, do not use in pol file.
#               }
#   AF_MAP = {'inet': 4,
#             'inet6': 6,
#             'bridge': 4  # if this doesn't exist, output includes v4 & v6
#            }
#   ALWAYS_PROTO_NUM = ['ipip']
#   PROTO_MAP_BY_NUMBER = dict([(v, k) for (k, v) in PROTO_MAP.items()])
#   AF_MAP_BY_NUMBER = dict([(v, k) for (k, v) in AF_MAP.items()])
#   NO_AF_LOG_ADDR = string.Template('Term $term will not be rendered, as it has'
#                                    ' $direction address match specified but no'
#                                    ' $direction addresses of $af address family'
#                                    ' are present.')
#   NO_AF_LOG_PROTO = string.Template('Term $term will not be rendered, as it has'
#                                     ' $proto match specified but the ACL is of'
#                                     ' $af address family.')
#   _PLATFORM = None
#   _DEFAULT_PROTOCOL = 'ip'
#   _SUPPORTED_AF = {'inet', 'inet6'}
#   _FILTER_BLACKLIST = {}
#   WARN_IF_UNSUPPORTED = {
#       'restrict_address_family',
#       'counter',
#       'destination_tag',
#       'filter_term',
#       'logging',
#       'loss_priority',
#       'owner',
#       'qos',
#       'routing_instance',
#       'policer',
#       'source_tag'
#   }
#   _ABBREVIATION_TABLE = [
#       # Service abbreviations first.
#       ('experiment', 'EXP'),
#       ('wifi-radius', 'W-R'),
#       ('customer', 'CUST'),
#       ('server', 'SRV'),
#       # Next, common routing terms
#       ('global', 'GBL'),
#       ('google', 'GOOG'),
#       ('service', 'SVC'),
#       ('router', 'RTR'),
#       ('internal', 'INT'),
#       ('external', 'EXT'),
#       ('transit', 'TRNS'),
#       ('management', 'MGMT'),
#       # State info
#       ('established', 'EST'),
#       ('unreachable', 'UNR'),
#       ('fragment', 'FRAG'),
#       ('accept', 'ACC'),
#       ('discard', 'DISC'),
#       ('reject', 'REJ'),
#       ('replies', 'RPL'),
#       ('request', 'REQ'),
#   ]
#   _TERM_MAX_LENGTH = 62
#   def __init__(self, term):
#   def NormalizeAddressFamily(self, af):
#   def NormalizeIcmpTypes(self, icmp_types, protocols, af):
#   def __init__(self, pol, exp_info):
#   def _TranslatePolicy(self, pol, exp_info):
#   def _BuildTokens(self):
#   def _GetSupportedTokens(self):
#   def FixHighPorts(self, term, af='inet', all_protocols_stateful=False):
#   def FixTermLength(self, term_name, abbreviate=False, truncate=False):
# def ProtocolNameToNumber(protocols, proto_to_num, name_to_num_map):
# def AddRepositoryTags(prefix='', rid=True, date=True, revision=True,
#                       wrap=False):
# def WrapWords(textlist, size, joiner='\n'):


import datetime
from absl import logging
from capirca.lib import aclgenerator
      self.term.action[0].value = self.default_action
    if str(self.term.action[0]) not in self._ACTION_TABLE:
      raise aclgenerator.UnsupportedFilterError('%s %s %s %s' % (
          '\n', self.term.name, self.term.action[0],
          'action not currently supported.'))

    # source address
    term_saddrs = self._CheckAddressAf(self.term.source_address)
    if not term_saddrs:
      logging.debug(self.NO_AF_LOG_ADDR.substitute(term=self.term.name,
                                                   direction='source',
                                                   af=self.af))
      return ''

    conditions.append(self._GenerateAddrStatement(
        term_saddrs, self.term.source_address_exclude))

    # destination address
    term_daddrs = self._CheckAddressAf(self.term.destination_address)
    if not term_daddrs:
      logging.debug(self.NO_AF_LOG_ADDR.substitute(term=self.term.name,
                                                   direction='destination',
                                                   af=self.af))
      return ''

    conditions.append(self._GenerateAddrStatement(
        term_daddrs, self.term.destination_address_exclude))

    # protocol
    if self.term.protocol_except:

# Path: capirca/lib/aclgenerator.py
# class Error(Exception):
# class NoPlatformPolicyError(Error):
# class UnknownIcmpTypeError(Error):
# class MismatchIcmpInetError(Error):
# class EstablishedError(Error):
# class UnsupportedAFError(Error):
# class DuplicateTermError(Error):
# class UnsupportedFilterError(Error):
# class UnsupportedTargetOptionError(Error):
# class TermNameTooLongError(Error):
# class Term:
# class ACLGenerator:
#   ICMP_TYPE = policy.Term.ICMP_TYPE
#   PROTO_MAP = {'hopopt': 0,
#                'icmp': 1,
#                'igmp': 2,
#                'ggp': 3,
#                'ipip': 4,
#                'tcp': 6,
#                'egp': 8,
#                'igp': 9,
#                'udp': 17,
#                'rdp': 27,
#                'ipv6': 41,
#                'ipv6-route': 43,
#                'fragment': 44,
#                'rsvp': 46,
#                'gre': 47,
#                'esp': 50,
#                'ah': 51,
#                'icmpv6': 58,
#                'ipv6-nonxt': 59,
#                'ipv6-opts': 60,
#                'ospf': 89,
#                'pim': 103,
#                'vrrp': 112,
#                'l2tp': 115,
#                'sctp': 132,
#                'udplite': 136,
#                'all': -1,  # Used for GCE default deny, do not use in pol file.
#               }
#   AF_MAP = {'inet': 4,
#             'inet6': 6,
#             'bridge': 4  # if this doesn't exist, output includes v4 & v6
#            }
#   ALWAYS_PROTO_NUM = ['ipip']
#   PROTO_MAP_BY_NUMBER = dict([(v, k) for (k, v) in PROTO_MAP.items()])
#   AF_MAP_BY_NUMBER = dict([(v, k) for (k, v) in AF_MAP.items()])
#   NO_AF_LOG_ADDR = string.Template('Term $term will not be rendered, as it has'
#                                    ' $direction address match specified but no'
#                                    ' $direction addresses of $af address family'
#                                    ' are present.')
#   NO_AF_LOG_PROTO = string.Template('Term $term will not be rendered, as it has'
#                                     ' $proto match specified but the ACL is of'
#                                     ' $af address family.')
#   _PLATFORM = None
#   _DEFAULT_PROTOCOL = 'ip'
#   _SUPPORTED_AF = {'inet', 'inet6'}
#   _FILTER_BLACKLIST = {}
#   WARN_IF_UNSUPPORTED = {
#       'restrict_address_family',
#       'counter',
#       'destination_tag',
#       'filter_term',
#       'logging',
#       'loss_priority',
#       'owner',
#       'qos',
#       'routing_instance',
#       'policer',
#       'source_tag'
#   }
#   _ABBREVIATION_TABLE = [
#       # Service abbreviations first.
#       ('experiment', 'EXP'),
#       ('wifi-radius', 'W-R'),
#       ('customer', 'CUST'),
#       ('server', 'SRV'),
#       # Next, common routing terms
#       ('global', 'GBL'),
#       ('google', 'GOOG'),
#       ('service', 'SVC'),
#       ('router', 'RTR'),
#       ('internal', 'INT'),
#       ('external', 'EXT'),
#       ('transit', 'TRNS'),
#       ('management', 'MGMT'),
#       # State info
#       ('established', 'EST'),
#       ('unreachable', 'UNR'),
#       ('fragment', 'FRAG'),
#       ('accept', 'ACC'),
#       ('discard', 'DISC'),
#       ('reject', 'REJ'),
#       ('replies', 'RPL'),
#       ('request', 'REQ'),
#   ]
#   _TERM_MAX_LENGTH = 62
#   def __init__(self, term):
#   def NormalizeAddressFamily(self, af):
#   def NormalizeIcmpTypes(self, icmp_types, protocols, af):
#   def __init__(self, pol, exp_info):
#   def _TranslatePolicy(self, pol, exp_info):
#   def _BuildTokens(self):
#   def _GetSupportedTokens(self):
#   def FixHighPorts(self, term, af='inet', all_protocols_stateful=False):
#   def FixTermLength(self, term_name, abbreviate=False, truncate=False):
# def ProtocolNameToNumber(protocols, proto_to_num, name_to_num_map):
# def AddRepositoryTags(prefix='', rid=True, date=True, revision=True,
#                       wrap=False):
# def WrapWords(textlist, size, joiner='\n'):


# Path: capirca/lib/pcap.py
import datetime
from absl import logging
from capirca.lib import aclgenerator

      self.term.action[0].value = self.default_action
    if str(self.term.action[0]) not in self._ACTION_TABLE:
      raise aclgenerator.UnsupportedFilterError('%s %s %s %s' % (
          '\n', self.term.name, self.term.action[0],
          'action not currently supported.'))

    # source address
    term_saddrs = self._CheckAddressAf(self.term.source_address)
    if not term_saddrs:
      logging.debug(self.NO_AF_LOG_ADDR.substitute(term=self.term.name,
                                                   direction='source',
                                                   af=self.af))
      return ''

    conditions.append(self._GenerateAddrStatement(
        term_saddrs, self.term.source_address_exclude))

    # destination address
    term_daddrs = self._CheckAddressAf(self.term.destination_address)
    if not term_daddrs:
      logging.debug(self.NO_AF_LOG_ADDR.substitute(term=self.term.name,
                                                   direction='destination',
                                                   af=self.af))
      return ''

    conditions.append(self._GenerateAddrStatement(
        term_daddrs, self.term.destination_address_exclude))

    # protocol
    if self.term.protocol_except:

      raise aclgenerator.UnsupportedFilterError('%s %s %s' % (