# Path: proto/_file_info.py
# class _FileInfo(
#     collections.namedtuple(
#         "_FileInfo",
#         ["descriptor", "messages", "enums", "name", "nested", "nested_enum"],
#     )
# ):
#     def maybe_add_descriptor(cls, filename, package):
#     def proto_file_name(name):
#     def _get_manifest(self, new_class):
#     def _get_remaining_manifest(self, new_class):
#     def _calculate_salt(self, new_class, fallback):
#     def generate_file_pb(self, new_class, fallback_salt=""):
#     def ready(self, new_class):
#     def unresolved_fields(self):
# 
# Path: proto/_package_info.py
# def compile(name, attrs):
# 
# Path: proto/marshal/rules/enums.py
# class EnumRule:
#     """A marshal for converting between integer values and enum values."""
# 
#     def __init__(self, enum_class: Type[enum.IntEnum]):
#         self._enum = enum_class
# 
#     def to_python(self, value, *, absent: bool = None):
#         if isinstance(value, int) and not isinstance(value, self._enum):
#             try:
#                 # Coerce the int on the wire to the enum value.
#                 return self._enum(value)
#             except ValueError:
#                 # Since it is possible to add values to enums, we do
#                 # not want to flatly error on this.
#                 #
#                 # However, it is useful to make some noise about it so
#                 # the user realizes that an unexpected value came along.
#                 warnings.warn(
#                     "Unrecognized {name} enum value: {value}".format(
#                         name=self._enum.__name__, value=value,
#                     )
#                 )
#         return value
# 
#     def to_proto(self, value):
#         # Accept enum values and coerce to the pure integer.
#         # This is not strictly necessary (protocol buffers can take these
#         # objects as they subclass int) but nevertheless seems like the
#         # right thing to do.
#         if isinstance(value, self._enum):
#             return value.value
# 
#         # If a string is provided that matches an enum value, coerce it
#         # to the enum value.
#         if isinstance(value, str):
#             return self._enum[value].value
# 
#         # We got a pure integer; pass it on.
#         return value


import enum
from google.protobuf import descriptor_pb2
from proto import _file_info
from proto import _package_info
from proto.marshal.rules.enums import EnumRule
        # Retrieve any enum options.
        # We expect something that looks like an EnumOptions message,
        # either an actual instance or a dict-like representation.
        pb_options = "_pb_options"
        opts = attrs.pop(pb_options, {})
        # This is the only portable way to remove the _pb_options name
        # from the enum attrs.
        # In 3.7 onwards, we can define an _ignore_ attribute and do some
        # mucking around with that.
        if pb_options in attrs._member_names:
            idx = attrs._member_names.index(pb_options)
            attrs._member_names.pop(idx)

        # Make the descriptor.
        enum_desc = descriptor_pb2.EnumDescriptorProto(
            name=name,
            # Note: the superclass ctor removes the variants, so get them now.
            # Note: proto3 requires that the first variant value be zero.
            value=sorted(
                (
                    descriptor_pb2.EnumValueDescriptorProto(name=name, number=number)
                    # Minor hack to get all the enum variants out.
                    for name, number in attrs.items()
                    if isinstance(number, int)
                ),
                key=lambda v: v.number,
            ),
            options=opts,
        )


# Path: proto/_file_info.py
# class _FileInfo(
#     collections.namedtuple(
#         "_FileInfo",
#         ["descriptor", "messages", "enums", "name", "nested", "nested_enum"],
#     )
# ):
#     def maybe_add_descriptor(cls, filename, package):
#     def proto_file_name(name):
#     def _get_manifest(self, new_class):
#     def _get_remaining_manifest(self, new_class):
#     def _calculate_salt(self, new_class, fallback):
#     def generate_file_pb(self, new_class, fallback_salt=""):
#     def ready(self, new_class):
#     def unresolved_fields(self):
# 
# Path: proto/_package_info.py
# def compile(name, attrs):
# 
# Path: proto/marshal/rules/enums.py
# class EnumRule:
#     """A marshal for converting between integer values and enum values."""
# 
#     def __init__(self, enum_class: Type[enum.IntEnum]):
#         self._enum = enum_class
# 
#     def to_python(self, value, *, absent: bool = None):
#         if isinstance(value, int) and not isinstance(value, self._enum):
#             try:
#                 # Coerce the int on the wire to the enum value.
#                 return self._enum(value)
#             except ValueError:
#                 # Since it is possible to add values to enums, we do
#                 # not want to flatly error on this.
#                 #
#                 # However, it is useful to make some noise about it so
#                 # the user realizes that an unexpected value came along.
#                 warnings.warn(
#                     "Unrecognized {name} enum value: {value}".format(
#                         name=self._enum.__name__, value=value,
#                     )
#                 )
#         return value
# 
#     def to_proto(self, value):
#         # Accept enum values and coerce to the pure integer.
#         # This is not strictly necessary (protocol buffers can take these
#         # objects as they subclass int) but nevertheless seems like the
#         # right thing to do.
#         if isinstance(value, self._enum):
#             return value.value
# 
#         # If a string is provided that matches an enum value, coerce it
#         # to the enum value.
#         if isinstance(value, str):
#             return self._enum[value].value
# 
#         # We got a pure integer; pass it on.
#         return value


# Path: proto/enums.py
import enum
from google.protobuf import descriptor_pb2
from proto import _file_info
from proto import _package_info
from proto.marshal.rules.enums import EnumRule

        # Retrieve any enum options.
        # We expect something that looks like an EnumOptions message,
        # either an actual instance or a dict-like representation.
        pb_options = "_pb_options"
        opts = attrs.pop(pb_options, {})
        # This is the only portable way to remove the _pb_options name
        # from the enum attrs.
        # In 3.7 onwards, we can define an _ignore_ attribute and do some
        # mucking around with that.
        if pb_options in attrs._member_names:
            idx = attrs._member_names.index(pb_options)
            attrs._member_names.pop(idx)

        # Make the descriptor.
        enum_desc = descriptor_pb2.EnumDescriptorProto(
            name=name,
            # Note: the superclass ctor removes the variants, so get them now.
            # Note: proto3 requires that the first variant value be zero.
            value=sorted(
                (
                    descriptor_pb2.EnumValueDescriptorProto(name=name, number=number)
                    # Minor hack to get all the enum variants out.
                    for name, number in attrs.items()
                    if isinstance(number, int)
                ),
                key=lambda v: v.number,
            ),
            options=opts,
        )


        file_info = _file_info._FileInfo.maybe_add_descriptor(filename, package)