<commit_before># Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""ACL Generator base class."""

import copy
import re
from string import Template

from lib import policy


# generic error class
class Error(Exception):
  """Base error class."""


class NoPlatformPolicyError(Error):
  """Raised when a policy is received that doesn't support this platform."""


class UnsupportedFilter(Error):
  """Raised when we see an inappropriate filter."""


class UnknownIcmpTypeError(Error):
  """Raised when we see an unknown icmp-type."""


class MismatchIcmpInetError(Error):
  """Raised when mistmatch between icmp/icmpv6 and inet/inet6."""


class EstablishedError(Error):
  """Raised when a term has established option with inappropriate protocol."""


class UnsupportedAF(Error):
  """Raised when provided an unsupported address family."""


class DuplicateTermError(Error):
  """Raised when duplication of term names are detected."""


class UnsupportedFilterError(Error):
  """Raised when we see an inappropriate filter."""


class UnsupportedTargetOption(Error):
  """Raised when a filter has an impermissible default action specified."""


class TermNameTooLongError(Error):
  """Raised when term named can not be abbreviated."""


class Term(object):
  """Generic framework for a generator Term."""
  ICMP_TYPE = policy.Term.ICMP_TYPE
  PROTO_MAP = {'hop-by-hop': 0,
                   'icmp': 1,
               'igmp': 2,
               'ggp': 3,
               'ipencap': 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,<commit_msg>Fixed a small lint error in aclgenerator.py<commit_after># Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""ACL Generator base class."""

import copy
import re
from string import Template

from lib import policy


# generic error class
class Error(Exception):
  """Base error class."""


class NoPlatformPolicyError(Error):
  """Raised when a policy is received that doesn't support this platform."""


class UnsupportedFilter(Error):
  """Raised when we see an inappropriate filter."""


class UnknownIcmpTypeError(Error):
  """Raised when we see an unknown icmp-type."""


class MismatchIcmpInetError(Error):
  """Raised when mistmatch between icmp/icmpv6 and inet/inet6."""


class EstablishedError(Error):
  """Raised when a term has established option with inappropriate protocol."""


class UnsupportedAF(Error):
  """Raised when provided an unsupported address family."""


class DuplicateTermError(Error):
  """Raised when duplication of term names are detected."""


class UnsupportedFilterError(Error):
  """Raised when we see an inappropriate filter."""


class UnsupportedTargetOption(Error):
  """Raised when a filter has an impermissible default action specified."""


class TermNameTooLongError(Error):
  """Raised when term named can not be abbreviated."""


class Term(object):
  """Generic framework for a generator Term."""
  ICMP_TYPE = policy.Term.ICMP_TYPE
  PROTO_MAP = {'hop-by-hop': 0,
               'icmp': 1,
               'igmp': 2,
               'ggp': 3,
               'ipencap': 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,
{'fraction_non_alphanumeric': 0.10748987854251012, 'fraction_numerical': 0.01902834008097166, 'mean_word_length': 2.7150375939849622, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7515186', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1325, 'n_words': 531}