From 48ae19e9096fab98b14eaddaaa73e1b54bcbda8d Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Thu, 7 Mar 2019 11:28:32 +0100 Subject: API: Add python2.7 support for enum flags via aenum Change-Id: I77a43bfb37d827727c331cd65eee77536cc15953 Signed-off-by: Ole Troan --- src/vpp-api/python/vpp_papi/vpp_serializer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/vpp-api/python/vpp_papi') diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py index d62e3a4a57a..e6012018f08 100644 --- a/src/vpp-api/python/vpp_papi/vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py @@ -15,11 +15,15 @@ import struct import collections -from enum import IntEnum +import sys +if sys.version[0] == '2': + from aenum import IntEnum, IntFlag +else: + from enum import IntEnum, IntFlag import logging from . import vpp_format import ipaddress -import sys + import socket # @@ -276,7 +280,7 @@ class VPPEnumType(object): continue ename, evalue = f e_hash[ename] = evalue - self.enum = IntEnum(name, e_hash) + self.enum = IntFlag(name, e_hash) types[name] = self def __getattr__(self, name): -- cgit 1.2.3-korg