Python google.protobuf.descriptor_pb2.FileOptions() Examples
The following are 1
code examples of google.protobuf.descriptor_pb2.FileOptions().
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 also want to check out all available functions/classes of the module
google.protobuf.descriptor_pb2
, or try the search function
.
Example #1
Source File: nanopb_generator.py From myelin-acorn-electron-hardware with Apache License 2.0 | 5 votes |
def get_nanopb_suboptions(subdesc, options, name): '''Get copy of options, and merge information from subdesc.''' new_options = nanopb_pb2.NanoPBOptions() new_options.CopyFrom(options) if hasattr(subdesc, 'syntax') and subdesc.syntax == "proto3": new_options.proto3 = True # Handle options defined in a separate file dotname = '.'.join(name.parts) for namemask, options in Globals.separate_options: if fnmatch(dotname, namemask): Globals.matched_namemasks.add(namemask) new_options.MergeFrom(options) # Handle options defined in .proto if isinstance(subdesc.options, descriptor.FieldOptions): ext_type = nanopb_pb2.nanopb elif isinstance(subdesc.options, descriptor.FileOptions): ext_type = nanopb_pb2.nanopb_fileopt elif isinstance(subdesc.options, descriptor.MessageOptions): ext_type = nanopb_pb2.nanopb_msgopt elif isinstance(subdesc.options, descriptor.EnumOptions): ext_type = nanopb_pb2.nanopb_enumopt else: raise Exception("Unknown options type") if subdesc.options.HasExtension(ext_type): ext = subdesc.options.Extensions[ext_type] new_options.MergeFrom(ext) if Globals.verbose_options: sys.stderr.write("Options for " + dotname + ": ") sys.stderr.write(text_format.MessageToString(new_options) + "\n") return new_options # --------------------------------------------------------------------------- # Command line interface # ---------------------------------------------------------------------------