aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/vppapigen/vppapigen.py49
1 files changed, 15 insertions, 34 deletions
diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py
index 94696aec68d..8ae991c9c95 100755
--- a/src/tools/vppapigen/vppapigen.py
+++ b/src/tools/vppapigen/vppapigen.py
@@ -134,10 +134,6 @@ class Service():
self.stream = stream
self.events = [] if events is None else events
- def __repr__(self):
- return "Service(caller={!r}, reply={!r}, events={!r}, stream={!r})".\
- format(self.caller, self.reply, self.events, self.stream)
-
class Typedef():
def __init__(self, name, flags, block):
@@ -155,28 +151,24 @@ class Typedef():
global_type_add(name, self)
def __repr__(self):
- return "Typedef(name={!r}, flags={!r}, block={!r})".format(
- self.name, self.flags, self.block)
+ return self.name + str(self.flags) + str(self.block)
class Using():
def __init__(self, name, alias):
self.name = name
- # save constructor values for repr()
- self._alias = alias
-
if isinstance(alias, Array):
- a = {'type': alias.fieldtype,
- 'length': alias.length}
+ a = { 'type': alias.fieldtype, # noqa: E201
+ 'length': alias.length } # noqa: E202
else:
- a = {'type': alias.fieldtype}
+ a = { 'type': alias.fieldtype } # noqa: E201,E202
self.alias = a
self.crc = str(alias).encode()
global_type_add(name, self)
def __repr__(self):
- return "Using(name={!r}, alias={!r})".format(self.name, self._alias)
+ return self.name + str(self.alias)
class Union():
@@ -190,7 +182,7 @@ class Union():
global_type_add(name, self)
def __repr__(self):
- return "Union(name={!r}, block={!r})".format(self.name, self.block)
+ return str(self.block)
class Define():
@@ -221,8 +213,7 @@ class Define():
block.remove(b)
def __repr__(self):
- return "Define(name={!r}, flags={!r}, block={!r})".format(
- self.name, self.flags, self.block)
+ return self.name + str(self.flags) + str(self.block)
class Enum():
@@ -243,8 +234,7 @@ class Enum():
global_type_add(name, self)
def __repr__(self):
- return "Enum(name={!r}, block={!r}, enumtype={!r})".format(
- self.name, self.block, self.enumtype)
+ return self.name + str(self.block)
class Import():
@@ -267,7 +257,7 @@ class Import():
self.result = parser.parse_file(fd, None)
def __repr__(self):
- return "Import(filename={!r})".format(self.filename)
+ return self.filename
class Option():
@@ -276,7 +266,7 @@ class Option():
self.crc = str(option).encode()
def __repr__(self):
- return "Option({!r})".format(self.option)
+ return str(self.option)
def __getitem__(self, index):
return self.option[index]
@@ -286,11 +276,6 @@ class Array():
def __init__(self, fieldtype, name, length):
self.type = 'Array'
self.fieldtype = fieldtype
-
- # save constructor values for repr()
- self._name = name
- self._length = length
-
self.fieldname = name
if type(length) is str:
self.lengthfield = length
@@ -300,8 +285,8 @@ class Array():
self.lengthfield = None
def __repr__(self):
- return "Array(fieldtype={!r}, name={!r}, length={!r})".format(
- self.fieldtype, self._name, self._length)
+ return str([self.fieldtype, self.fieldname, self.length,
+ self.lengthfield])
class Field():
@@ -312,8 +297,7 @@ class Field():
self.limit = limit
def __repr__(self):
- return "Field(fieldtype={!r}, name={!r}, limit={!r})".format(
- self.fieldtype, self.fieldname, self.limit)
+ return str([self.fieldtype, self.fieldname])
class Coord(object):
@@ -533,13 +517,13 @@ class VPPAPIParser(object):
if len(p) == 2:
p[0] = p[1]
else:
- p[0] = {**p[1], **p[2]}
+ p[0] = { **p[1], **p[2] }
def p_field_option(self, p):
'''field_option : ID '=' assignee ','
| ID '=' assignee
'''
- p[0] = {p[1]: p[3]}
+ p[0] = { p[1]: p[3] }
def p_declaration(self, p):
'''declaration : type_specifier ID ';'
@@ -782,7 +766,6 @@ def dirlist_add(dirs):
def dirlist_get():
return dirlist
-
def foldup_blocks(block, crc):
for b in block:
# Look up CRC in user defined types
@@ -796,13 +779,11 @@ def foldup_blocks(block, crc):
pass
return crc
-
def foldup_crcs(s):
for f in s:
f.crc = foldup_blocks(f.block,
binascii.crc32(f.crc))
-
#
# Main
#