aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/python')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_format.py8
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py26
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py13
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_stats.py2
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_transport_shmem.py2
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_transport_socket.py7
6 files changed, 18 insertions, 40 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_format.py b/src/vpp-api/python/vpp_papi/vpp_format.py
index 261683d5816..0b85eb4fcb6 100644
--- a/src/vpp-api/python/vpp_papi/vpp_format.py
+++ b/src/vpp-api/python/vpp_papi/vpp_format.py
@@ -18,10 +18,6 @@ import socket
import ipaddress
from . import macaddress
-try:
- text_type = unicode
-except NameError:
- text_type = str
# Copies from vl_api_address_t definition
ADDRESS_IP4 = 0
@@ -51,7 +47,7 @@ def format_vl_api_address_t(args):
def format_vl_api_prefix_t(args):
if isinstance(args, (ipaddress.IPv4Network, ipaddress.IPv6Network)):
return {'address': format_vl_api_address_t(
- text_type(args.network_address)),
+ str(args.network_address)),
'len': int(args.prefixlen)}
p, length = args.split('/')
return {'address': format_vl_api_address_t(p),
@@ -61,7 +57,7 @@ def format_vl_api_prefix_t(args):
def format_vl_api_address_with_prefix_t(args):
if isinstance(args, (ipaddress.IPv4Interface, ipaddress.IPv6Interface)):
return {'address': format_vl_api_address_t(
- text_type(args.network_address)),
+ str(args.network_address)),
'len': int(args.prefixlen)}
p, length = args.split('/')
return {'address': format_vl_api_address_t(p),
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:
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index d31a0bbc95e..81ce53e378d 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -29,10 +29,9 @@ from . import vpp_format
#
logger = logging.getLogger('vpp_papi.serializer')
-if sys.version[0] == '2':
- def check(d): type(d) is dict
-else:
- def check(d): type(d) is dict or type(d) is bytes
+
+def check(d):
+ return type(d) is dict or type(d) is bytes
def conversion_required(data, field_type):
@@ -57,8 +56,7 @@ def conversion_unpacker(data, field_type):
return vpp_format.conversion_unpacker_table[field_type](data)
-# TODO: post 20.01, remove inherit from object.
-class Packer(object):
+class Packer:
options = {}
def pack(self, data, kwargs):
@@ -384,9 +382,6 @@ class VPPEnumType(Packer):
def __bool__(self):
return True
- # TODO: Remove post 20.01.
- if sys.version[0] == '2':
- __nonzero__ = __bool__
def pack(self, data, kwargs=None):
if data is None: # Default to zero if not specified
diff --git a/src/vpp-api/python/vpp_papi/vpp_stats.py b/src/vpp-api/python/vpp_papi/vpp_stats.py
index 5eb2b9d91af..4b7a9bce8b0 100644
--- a/src/vpp-api/python/vpp_papi/vpp_stats.py
+++ b/src/vpp-api/python/vpp_papi/vpp_stats.py
@@ -189,7 +189,7 @@ class VPPStatsClientLoadError(RuntimeError):
pass
-class VPPStats(object):
+class VPPStats:
VPPStatsIOError = VPPStatsIOError
default_socketname = '/run/vpp/stats.sock'
diff --git a/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py b/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
index f1ab728e928..4719f23b40a 100644
--- a/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
+++ b/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
@@ -66,7 +66,7 @@ class VppTransportShmemIOError(IOError):
super(VppTransportShmemIOError, self).__init__(rv, descr)
-class VppTransport(object):
+class VppTransport:
VppTransportShmemIOError = VppTransportShmemIOError
def __init__(self, parent, read_timeout, server_address):
diff --git a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py
index d88082fa8a0..a6340d8bb9e 100644
--- a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py
+++ b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py
@@ -6,10 +6,7 @@ import struct
import threading
import select
import multiprocessing
-try:
- import queue as queue
-except ImportError:
- import Queue as queue
+import queue
import logging
from . import vpp_papi
@@ -22,7 +19,7 @@ class VppTransportSocketIOError(IOError):
pass
-class VppTransport(object):
+class VppTransport:
VppTransportSocketIOError = VppTransportSocketIOError
def __init__(self, parent, read_timeout, server_address):