Code Review
/
apps
/
agl-service-can-low-level.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Publishing nanopb-0.3.3
[apps/agl-service-can-low-level.git]
/
generator
/
nanopb_generator.py
diff --git
a/generator/nanopb_generator.py
b/generator/nanopb_generator.py
index
eebe540
..
364a22c
100755
(executable)
--- a/
generator/nanopb_generator.py
+++ b/
generator/nanopb_generator.py
@@
-1,9
+1,10
@@
#!/usr/bin/python
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
#!/usr/bin/python
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
-nanopb_version = "nanopb-0.3.3
-dev
"
+nanopb_version = "nanopb-0.3.3"
import sys
import sys
+import re
try:
# Add some dummy imports to keep packaging tools happy.
try:
# Add some dummy imports to keep packaging tools happy.
@@
-1164,9
+1165,13
@@
def read_options_file(infile):
[(namemask, options), ...]
'''
results = []
[(namemask, options), ...]
'''
results = []
- for i, line in enumerate(infile):
+ data = infile.read()
+ data = re.sub('/\*.*?\*/', '', data, flags = re.MULTILINE)
+ data = re.sub('//.*?$', '', data, flags = re.MULTILINE)
+ data = re.sub('#.*?$', '', data, flags = re.MULTILINE)
+ for i, line in enumerate(data.split('\n')):
line = line.strip()
line = line.strip()
- if not line
or line.startswith('//') or line.startswith('#')
:
+ if not line:
continue
parts = line.split(None, 1)
continue
parts = line.split(None, 1)
@@
-1379,8
+1384,15
@@
def main_plugin():
data = sys.stdin.read()
request = plugin_pb2.CodeGeneratorRequest.FromString(data)
data = sys.stdin.read()
request = plugin_pb2.CodeGeneratorRequest.FromString(data)
+ try:
+ # Versions of Python prior to 2.7.3 do not support unicode
+ # input to shlex.split(). Try to convert to str if possible.
+ params = str(request.parameter)
+ except UnicodeEncodeError:
+ params = request.parameter
+
import shlex
import shlex
- args = shlex.split(
request.parameter
)
+ args = shlex.split(
params
)
options, dummy = optparser.parse_args(args)
Globals.verbose_options = options.verbose
options, dummy = optparser.parse_args(args)
Globals.verbose_options = options.verbose