Python API: Add enum and union support.
[vpp.git] / src / vpp-api / python / vpp_papi / vpp_papi.py
index 5ff8064..edc0c6a 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
@@ -104,9 +106,6 @@ class FuncWrapper(object):
         return self._func(**kwargs)
 
 
-class VPPMessage(VPPType):
-    pass
-
 class VPP():
     """VPP interface.
 
@@ -399,7 +398,8 @@ 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):
@@ -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.