eric6/Utilities/ClassBrowsers/protoclbr.py

Mon, 23 Sep 2019 19:22:12 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 23 Sep 2019 19:22:12 +0200
changeset 7259
7c017076c12e
parent 7229
53054eb5b15a
child 7360
9190402e4505
permissions
-rw-r--r--

Continued to resolve code style issue M841.

5977
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2017 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5977
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Parse a ProtoBuf protocol file and retrieve messages, enums, services and
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 rpc methods.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 It is based on the Python class browser found in this package.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import re
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import Utilities
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import Utilities.ClassBrowsers as ClassBrowsers
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from . import ClbrBaseClasses
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 SUPPORTED_TYPES = [ClassBrowsers.PROTO_SOURCE]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 _getnext = re.compile(
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 r"""
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 (?P<String>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 " [^"\\\n]* (?: \\. [^"\\\n]*)* "
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 | (?P<Comment>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 ^ [ \t]* // .*? $
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 |
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 ^ [ \t]* /\* .*? \*/
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 | (?P<Message>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 ^
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 (?P<MessageIndent> [ \t]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 message [ \t]+
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 (?P<MessageName> [a-zA-Z_] [a-zA-Z0-9_]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 [ \t]* {
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 | (?P<Enum>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 ^
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 (?P<EnumIndent> [ \t]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 enum [ \t]+
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 (?P<EnumName> [a-zA-Z_] [a-zA-Z0-9_]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 [ \t]* {
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 | (?P<Service>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 ^
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 (?P<ServiceIndent> [ \t]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 service [ \t]+
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 (?P<ServiceName> [a-zA-Z_] [a-zA-Z0-9_]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 [ \t]* {
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 | (?P<Method>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 ^
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 (?P<MethodIndent> [ \t]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 rpc [ \t]+
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 (?P<MethodName> [a-zA-Z_] [a-zA-Z0-9_]* )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 [ \t]*
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 \(
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 (?P<MethodSignature> [^)]+? )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 \)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 [ \t]+
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 returns
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 [ \t]*
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 \(
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 (?P<MethodReturn> [^)]+? )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 \)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 [ \t]*
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 | (?P<Begin>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 [ \t]* {
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 )
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 | (?P<End>
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 [ \t]* } [ \t]* ;?
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 )""",
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 re.VERBOSE | re.DOTALL | re.MULTILINE).search
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 # function to replace comments
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 _commentsub = re.compile(r"""//[^\n]*\n|//[^\n]*$""").sub
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 # function to normalize whitespace
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 _normalize = re.compile(r"""[ \t]{2,}""").sub
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 _modules = {} # cache of modules we've seen
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 class VisibilityMixin(ClbrBaseClasses.ClbrVisibilityMixinBase):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 Mixin class implementing the notion of visibility.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 def __init__(self):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 Constructor
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.setPublic()
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 class Message(ClbrBaseClasses.Module, VisibilityMixin):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Class to represent a ProtoBuf Message.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 def __init__(self, module, name, file, lineno):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 Constructor
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 @param module name of the module containing this message
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @param name name of this message
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @param file filename containing this message
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @param lineno linenumber of the message definition
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 @type int
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 ClbrBaseClasses.Module.__init__(self, module, name, file, lineno)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 VisibilityMixin.__init__(self)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 class Enum(ClbrBaseClasses.Enum, VisibilityMixin):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 Class to represent a ProtoBuf Enum.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 def __init__(self, module, name, file, lineno):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 Constructor
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 @param module name of the module containing this enum
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 @param name name of this enum
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @param file filename containing this enum
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 @param lineno linenumber of the message enum
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 @type int
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 ClbrBaseClasses.Enum.__init__(self, module, name, file, lineno)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 VisibilityMixin.__init__(self)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 class Service(ClbrBaseClasses.Class, VisibilityMixin):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 Class to represent a ProtoBuf Service.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def __init__(self, module, name, file, lineno):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 Constructor
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @param module name of the module containing this service
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 @param name name of this service
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 @param file filename containing this service
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @param lineno linenumber of the service definition
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 @type int
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 ClbrBaseClasses.Class.__init__(self, module, name, None, file,
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 lineno)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 VisibilityMixin.__init__(self)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 class ServiceMethod(ClbrBaseClasses.Function, VisibilityMixin):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Class to represent a ProtoBuf Service Method.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 def __init__(self, name, file, lineno, signature, returns):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 Constructor
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 @param name name of this service method
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 @param file filename containing this service method
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 @param lineno linenumber of the service method definition
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 @type int
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 @param signature parameter list of the service method
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @param returns return type of the service method
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 ClbrBaseClasses.Function.__init__(self, None, name, file, lineno,
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 signature,
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 annotation="-> {0}".format(returns))
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 VisibilityMixin.__init__(self)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 def readmodule_ex(module, path=None):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 Read a ProtoBuf protocol file and return a dictionary of messages, enums,
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 services and rpc methods.
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 @param module name of the ProtoBuf protocol file
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 @type str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 @param path path the file should be searched in
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 @type list of str
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @return the resulting dictionary
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 @rtype dict
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 """
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 global _modules
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 dictionary = {}
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 if module in _modules:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 # we've seen this file before...
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 return _modules[module]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 # search the path for the file
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 f = None
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 fullpath = [] if path is None else path[:]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, fullpath)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 if f:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 f.close()
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 if type not in SUPPORTED_TYPES:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 # not ProtoBuf protocol source, can't do anything with this module
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 _modules[module] = dictionary
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 return dictionary
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 _modules[module] = dictionary
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 classstack = [] # stack of (class, indent) pairs
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 indent = 0
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 try:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 src = Utilities.readEncodedFile(file)[0]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 except (UnicodeError, IOError):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 # can't do anything with this module
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 _modules[module] = dictionary
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 return dictionary
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 lineno, last_lineno_pos = 1, 0
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 lastGlobalEntry = None
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 cur_obj = None
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 i = 0
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 while True:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 m = _getnext(src, i)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 if not m:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 break
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 start, i = m.span()
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 if m.start("Method") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 # found a method definition or function
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 thisindent = indent
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 meth_name = m.group("MethodName")
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 meth_sig = m.group("MethodSignature")
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 meth_sig = meth_sig and meth_sig.replace('\\\n', '') or ''
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 meth_sig = _commentsub('', meth_sig)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 meth_sig = _normalize(' ', meth_sig)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 meth_return = m.group("MethodReturn")
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 meth_return = meth_return and meth_return.replace('\\\n', '') or ''
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 meth_return = _commentsub('', meth_return)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 meth_return = _normalize(' ', meth_return)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 lineno = lineno + src.count('\n', last_lineno_pos, start)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 last_lineno_pos = start
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 # close all interfaces/modules indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
259 while classstack and classstack[-1][1] >= thisindent:
5977
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 if classstack[-1][0] is not None:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 # record the end line
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 classstack[-1][0].setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 del classstack[-1]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 if classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 # it's an interface/module method
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 cur_class = classstack[-1][0]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 if isinstance(cur_class, Service):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 # it's a method
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 f = ServiceMethod(meth_name, file, lineno, meth_sig,
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 meth_return)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 cur_class._addmethod(meth_name, f)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 # else it's a nested def
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 else:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 f = None
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 else:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 # the file is incorrect, ignore the entry
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 continue
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 if not classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 if lastGlobalEntry:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 lastGlobalEntry.setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 lastGlobalEntry = f
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 if cur_obj and isinstance(cur_obj, ServiceMethod):
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 cur_obj.setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 cur_obj = f
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 classstack.append((f, thisindent)) # Marker for nested fns
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 elif m.start("String") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 pass
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 elif m.start("Comment") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 pass
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 elif m.start("Message") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 # we found a message definition
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 thisindent = indent
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 indent += 1
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 # close all messages/services indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
298 while classstack and classstack[-1][1] >= thisindent:
5977
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 if classstack[-1][0] is not None:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 # record the end line
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 classstack[-1][0].setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 del classstack[-1]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 lineno = lineno + src.count('\n', last_lineno_pos, start)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 last_lineno_pos = start
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 message_name = m.group("MessageName")
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 # remember this message
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 cur_class = Message(module, message_name, file, lineno)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 if not classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 dictionary[message_name] = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 else:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 msg = classstack[-1][0]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 msg._addclass(message_name, cur_class)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 if not classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 if lastGlobalEntry:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 lastGlobalEntry.setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 lastGlobalEntry = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 cur_obj = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 classstack.append((cur_class, thisindent))
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 elif m.start("Enum") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 # we found a message definition
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 thisindent = indent
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 indent += 1
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 # close all messages/services indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
325 while classstack and classstack[-1][1] >= thisindent:
5977
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 if classstack[-1][0] is not None:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 # record the end line
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 classstack[-1][0].setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 del classstack[-1]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 lineno = lineno + src.count('\n', last_lineno_pos, start)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 last_lineno_pos = start
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 enum_name = m.group("EnumName")
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 # remember this Enum
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 cur_class = Enum(module, enum_name, file, lineno)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 if not classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 dictionary[enum_name] = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 else:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 enum = classstack[-1][0]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 enum._addclass(enum_name, cur_class)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 if not classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 if lastGlobalEntry:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 lastGlobalEntry.setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 lastGlobalEntry = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 cur_obj = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 classstack.append((cur_class, thisindent))
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 elif m.start("Service") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 # we found a message definition
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 thisindent = indent
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 indent += 1
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 # close all messages/services indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
352 while classstack and classstack[-1][1] >= thisindent:
5977
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 if classstack[-1][0] is not None:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 # record the end line
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 classstack[-1][0].setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 del classstack[-1]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 lineno = lineno + src.count('\n', last_lineno_pos, start)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 last_lineno_pos = start
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 service_name = m.group("ServiceName")
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 # remember this Service
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 cur_class = Service(module, service_name, file, lineno)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 if not classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 dictionary[service_name] = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 else:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 service = classstack[-1][0]
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 service._addclass(service_name, cur_class)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 if not classstack:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 if lastGlobalEntry:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 lastGlobalEntry.setEndLine(lineno - 1)
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 lastGlobalEntry = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 cur_obj = cur_class
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 classstack.append((cur_class, thisindent))
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 elif m.start("Begin") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 # a begin of a block we are not interested in
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 indent += 1
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 elif m.start("End") >= 0:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 # an end of a block
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 indent -= 1
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 else:
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 assert 0, "regexp _getnext found something unexpected"
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
8a0ec75b0f73 Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 return dictionary

eric ide

mercurial