Python google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper() Examples
The following are 16 code examples for showing how to use google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
google.protobuf.internal.enum_type_wrapper
, or try the search function
.
Example 1
Project: lambda-packs Author: ryfeus File: python_message.py License: MIT License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 2
Project: auto-alt-text-lambda-api Author: abhisuri97 File: python_message.py License: MIT License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 3
Project: sklearn-theano Author: sklearn-theano File: python_message.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 4
Project: botchallenge Author: katharosada File: cpp_message.py License: MIT License | 5 votes |
def _AddEnumValues(message_descriptor, dictionary): """Sets class-level attributes for all enum fields defined in this message. Args: message_descriptor: Descriptor object for this message type. dictionary: Class dictionary that should be populated. """ for enum_type in message_descriptor.enum_types: dictionary[enum_type.name] = enum_type_wrapper.EnumTypeWrapper(enum_type) for enum_value in enum_type.values: dictionary[enum_value.name] = enum_value.number
Example 5
Project: botchallenge Author: katharosada File: python_message.py License: MIT License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 6
Project: coremltools Author: apple File: python_message.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 7
Project: go2mapillary Author: enricofer File: python_message.py License: GNU General Public License v3.0 | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 8
Project: luci-py Author: luci File: python_message.py License: Apache License 2.0 | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 9
Project: luci-py Author: luci File: python_message.py License: Apache License 2.0 | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 10
Project: luci-py Author: luci File: python_message.py License: Apache License 2.0 | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 11
Project: luci-py Author: luci File: python_message.py License: Apache License 2.0 | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 12
Project: luci-py Author: luci File: python_message.py License: Apache License 2.0 | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 13
Project: Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda Author: PacktPublishing File: python_message.py License: MIT License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 14
Project: Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda Author: PacktPublishing File: python_message.py License: MIT License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 15
Project: keras-lambda Author: sunilmallya File: python_message.py License: MIT License | 5 votes |
def _AddEnumValues(descriptor, cls): """Sets class-level attributes for all enum fields defined in this message. Also exporting a class-level object that can name enum values. Args: descriptor: Descriptor object for this message type. cls: Class we're constructing for this message type. """ for enum_type in descriptor.enum_types: setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type)) for enum_value in enum_type.values: setattr(cls, enum_value.name, enum_value.number)
Example 16
Project: python-pachyderm Author: pachyderm File: __init__.py License: Apache License 2.0 | 4 votes |
def _import_protos(path): """ Imports items selectively from the auto-generated proto package. Importing is done dynamically so we can selectively blacklist items. We also dynamically define enums that build on top of the auto-generated protobuf enums, to create a more pythonic API. More broadly, the dark magic in here allows us to maintain parity with Pachyderm protobufs when they change, without having to maintain a manual mapping of protobuf to python_pachyderm values. """ g = globals() module = _importlib.import_module(path) uppercase_letters = set(_string.ascii_uppercase) lowercase_letters = set(_string.ascii_lowercase) def import_item(g, module, key): value = getattr(module, key) if isinstance(value, _EnumTypeWrapper): # Dynamically define an enum class that is exported enum_values = _enum._EnumDict() enum_values.update(dict(value.items())) enum_class = type(key, (_enum.IntEnum,), enum_values) g[key] = enum_class else: # Export the value g[key] = value __all__.append(key) def should_import(key): return key[0] in uppercase_letters and any(c in lowercase_letters for c in key[1:]) for key in dir(module): if should_import(key): import_item(g, module, key) elif key.startswith("google_dot_protobuf_dot_"): sub_module = getattr(module, key) for key in dir(sub_module): if should_import(key): import_item(g, sub_module, key)