Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Side by Side Diff: third_party/protobuf/python/google/protobuf/reflection.py

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Protocol Buffers - Google's data interchange format 1 # Protocol Buffers - Google's data interchange format
2 # Copyright 2008 Google Inc. All rights reserved. 2 # Copyright 2008 Google Inc. All rights reserved.
3 # https://developers.google.com/protocol-buffers/ 3 # https://developers.google.com/protocol-buffers/
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 from google.protobuf.internal import api_implementation 51 from google.protobuf.internal import api_implementation
52 from google.protobuf import message 52 from google.protobuf import message
53 53
54 54
55 if api_implementation.Type() == 'cpp': 55 if api_implementation.Type() == 'cpp':
56 from google.protobuf.pyext import cpp_message as message_impl 56 from google.protobuf.pyext import cpp_message as message_impl
57 else: 57 else:
58 from google.protobuf.internal import python_message as message_impl 58 from google.protobuf.internal import python_message as message_impl
59 59
60 # The type of all Message classes. 60 # The type of all Message classes.
61 # Part of the public interface, but normally only used by message factories. 61 # Part of the public interface.
62 #
63 # Used by generated files, but clients can also use it at runtime:
64 # mydescriptor = pool.FindDescriptor(.....)
65 # class MyProtoClass(Message):
66 # __metaclass__ = GeneratedProtocolMessageType
67 # DESCRIPTOR = mydescriptor
62 GeneratedProtocolMessageType = message_impl.GeneratedProtocolMessageType 68 GeneratedProtocolMessageType = message_impl.GeneratedProtocolMessageType
63 69
64 70
65 def ParseMessage(descriptor, byte_str): 71 def ParseMessage(descriptor, byte_str):
66 """Generate a new Message instance from this Descriptor and a byte string. 72 """Generate a new Message instance from this Descriptor and a byte string.
67 73
68 Args: 74 Args:
69 descriptor: Protobuf Descriptor object 75 descriptor: Protobuf Descriptor object
70 byte_str: Serialized protocol buffer byte string 76 byte_str: Serialized protocol buffer byte string
71 77
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 The Message class object described by the descriptor. 111 The Message class object described by the descriptor.
106 """ 112 """
107 attributes = {} 113 attributes = {}
108 for name, nested_type in descriptor.nested_types_by_name.items(): 114 for name, nested_type in descriptor.nested_types_by_name.items():
109 attributes[name] = MakeClass(nested_type) 115 attributes[name] = MakeClass(nested_type)
110 116
111 attributes[GeneratedProtocolMessageType._DESCRIPTOR_KEY] = descriptor 117 attributes[GeneratedProtocolMessageType._DESCRIPTOR_KEY] = descriptor
112 118
113 return GeneratedProtocolMessageType(str(descriptor.name), (message.Message,), 119 return GeneratedProtocolMessageType(str(descriptor.name), (message.Message,),
114 attributes) 120 attributes)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698