PAPI: Union pad at the end of short fields instead of at head.
[vpp.git] / src / vpp-api / python / vpp_papi / vpp_papi.py
index 5ff8064..afaad48 100644 (file)
@@ -15,6 +15,7 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 import sys
 import os
 import logging
@@ -27,7 +28,8 @@ import weakref
 import atexit
 from cffi import FFI
 import cffi
-from vpp_serializer import VPPType, VPPEnumType, VPPUnionType, BaseTypes
+from . vpp_serializer import VPPType, VPPEnumType, VPPUnionType, BaseTypes
+from . vpp_serializer import VPPMessage
 
 if sys.version[0] == '2':
     import Queue as queue
@@ -91,7 +93,7 @@ def vac_error_handler(arg, msg, msg_len):
     vpp_object.logger.warning("VPP API client:: %s", ffi.string(msg, msg_len))
 
 
-class Empty(object):
+class VppApiDynamicMethodHolder(object):
     pass
 
 
@@ -104,9 +106,6 @@ class FuncWrapper(object):
         return self._func(**kwargs)
 
 
-class VPPMessage(VPPType):
-    pass
-
 class VPP():
     """VPP interface.
 
@@ -399,13 +398,14 @@ class VPP():
 
         f.__name__ = str(msg.name)
         f.__doc__ = ", ".join(["%s %s" %
-                               (msg.fieldtypes[j], k) for j, k in enumerate(msg.fields)])
+                               (msg.fieldtypes[j], k)
+                               for j, k in enumerate(msg.fields)])
         return f
 
     def _register_functions(self, async=False):
         self.id_names = [None] * (self.vpp_dictionary_maxid + 1)
         self.id_msgdef = [None] * (self.vpp_dictionary_maxid + 1)
-        self._api = Empty()
+        self._api = VppApiDynamicMethodHolder()
         for name, msg in vpp_iterator(self.messages):
             n = name + '_' + msg.crc[2:]
             i = vpp_api.vac_get_msg_index(n.encode())
@@ -562,7 +562,8 @@ class VPP():
     def validate_args(self, msg, kwargs):
         d = set(kwargs.keys()) - set(msg.field_by_name.keys())
         if d:
-            raise ValueError('Invalid argument {} to {}'.format(list(d), msg.name))
+            raise ValueError('Invalid argument {} to {}'
+                             .format(list(d), msg.name))
 
     def _call_vpp(self, i, msg, multipart, **kwargs):
         """Given a message, send the message and await a reply.