summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/vpp_papi.py
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2020-12-02 14:34:27 -0500
committerOle Tr�an <otroan@employees.org>2020-12-03 14:12:09 +0000
commitd7adc293d377f4691b0285f62363c3958c68d235 (patch)
tree83839c8d66cf342f460aa808cfcbfacf08f9fff1 /src/vpp-api/python/vpp_papi/vpp_papi.py
parent5395c6a07996b9d852ce1e942bd2b3c094b89d27 (diff)
papi: remove python2 patterns
Type: refactor Change-Id: I541759b4b788acf08599661eb9e7abc58e9283d2 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vpp-api/python/vpp_papi/vpp_papi.py')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py
index 5c375df199d..e22b88bc3f6 100644
--- a/src/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/src/vpp-api/python/vpp_papi/vpp_papi.py
@@ -21,6 +21,7 @@ import ipaddress
import sys
import multiprocessing as mp
import os
+import queue
import logging
import functools
import json
@@ -46,11 +47,6 @@ except ModuleNotFoundError:
logger = logging.getLogger('vpp_papi')
logger.addHandler(logging.NullHandler())
-if sys.version[0] == '2':
- import Queue as queue
-else:
- import queue as queue
-
__all__ = ('FuncWrapper', 'VPP', 'VppApiDynamicMethodHolder',
'VppEnum', 'VppEnumType',
'VPPIOError', 'VPPRuntimeError', 'VPPValueError',
@@ -72,7 +68,7 @@ class VppEnumType(type):
@metaclass(VppEnumType)
-class VppEnum(object):
+class VppEnum:
pass
@@ -84,12 +80,6 @@ def vpp_atexit(vpp_weakref):
vpp_instance.disconnect()
-if sys.version[0] == '2':
- def vpp_iterator(d):
- return d.iteritems()
-else:
- def vpp_iterator(d):
- return d.items()
def add_convenience_methods():
@@ -112,11 +102,11 @@ def add_convenience_methods():
ipaddress._IPAddressBase.vapi_af_name = property(_vapi_af_name)
-class VppApiDynamicMethodHolder(object):
+class VppApiDynamicMethodHolder:
pass
-class FuncWrapper(object):
+class FuncWrapper:
def __init__(self, func):
self._func = func
self.__name__ = func.__name__
@@ -149,7 +139,7 @@ class VPPValueError(ValueError):
pass
-class VPPApiJSONFiles(object):
+class VPPApiJSONFiles:
@classmethod
def find_api_dir(cls, dirs):
"""Attempt to find the best directory in which API definition
@@ -362,7 +352,7 @@ class VPPApiJSONFiles(object):
return messages, services
-class VPPApiClient(object):
+class VPPApiClient:
"""VPP interface.
This class provides the APIs to VPP. The APIs are loaded
@@ -464,7 +454,7 @@ class VPPApiClient(object):
def get_function(self, name):
return getattr(self._api, name)
- class ContextId(object):
+ class ContextId:
"""Multiprocessing-safe provider of unique context IDs."""
def __init__(self):
self.context = mp.Value(ctypes.c_uint, 0)
@@ -506,7 +496,7 @@ class VPPApiClient(object):
self.id_names = [None] * (self.vpp_dictionary_maxid + 1)
self.id_msgdef = [None] * (self.vpp_dictionary_maxid + 1)
self._api = VppApiDynamicMethodHolder()
- for name, msg in vpp_iterator(self.messages):
+ for name, msg in self.messages.items():
n = name + '_' + msg.crc[2:]
i = self.transport.get_msg_index(n)
if i > 0: