aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/vppapigen/vppapigen.py
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-02-01 19:37:45 -0800
committerOle Trøan <otroan@employees.org>2019-02-02 07:33:35 +0000
commit7e0c48e3a941ce874361b442a02624e586db810b (patch)
tree263dee49f92dacc27b1960a5ac2a185164d86901 /src/tools/vppapigen/vppapigen.py
parent652d2e139443cea073da9b7bef8ee21e41a14111 (diff)
Python3: Move vppapigen to python3.
Change-Id: I26846d0c12211a29ccfca7c269b9094f6fdbd95c Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/tools/vppapigen/vppapigen.py')
-rwxr-xr-xsrc/tools/vppapigen/vppapigen.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py
index 4ca9b954e67..431a9dc7f93 100755
--- a/src/tools/vppapigen/vppapigen.py
+++ b/src/tools/vppapigen/vppapigen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import print_function
import ply.lex as lex
@@ -133,11 +133,11 @@ def crc_block(block):
class Service():
- def __init__(self, caller, reply, events=[], stream=False):
+ def __init__(self, caller, reply, events=None, stream=False):
self.caller = caller
self.reply = reply
self.stream = stream
- self.events = events
+ self.events = [] if events is None else events
class Typedef():
@@ -170,8 +170,8 @@ class Using():
else:
a = { 'type': alias.fieldtype }
self.alias = a
- self.crc = binascii.crc32(str(alias)) & 0xffffffff
- global_crc = binascii.crc32(str(alias), global_crc)
+ self.crc = binascii.crc32(str(alias).encode()) & 0xffffffff
+ global_crc = binascii.crc32(str(alias).encode(), global_crc)
global_type_add(name)
def __repr__(self):
@@ -759,12 +759,17 @@ def main():
if sys.version[0] == '2':
cliparser.add_argument('--input', type=argparse.FileType('r'),
default=sys.stdin)
+ cliparser.add_argument('--output', nargs='?',
+ type=argparse.FileType('w'),
+ default=sys.stdout)
+
else:
cliparser.add_argument('--input',
type=argparse.FileType('r', encoding='UTF-8'),
default=sys.stdin)
- cliparser.add_argument('--output', nargs='?', type=argparse.FileType('w'),
- default=sys.stdout)
+ cliparser.add_argument('--output', nargs='?',
+ type=argparse.FileType('w', encoding='UTF-8'),
+ default=sys.stdout)
cliparser.add_argument('output_module', nargs='?', default='C')
cliparser.add_argument('--debug', action='store_true')