Fix ImportError(s) with Python3

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Satoshi Kobayashi 2015-04-10 15:43:43 +09:00 committed by FUJITA Tomonori
parent 8698e09839
commit cfdba5c12d
14 changed files with 34 additions and 38 deletions

View File

@ -37,7 +37,13 @@ import inspect
# grep __init__ *.py | grep '[^_]_\>' showed that
# 'len', 'property', 'set', 'type'
# A bit more generic way is adopted
import __builtin__
try:
# Python 2
import __builtin__
except ImportError:
# Python 3
import builtins as __builtin__
_RESERVED_KEYWORD = dir(__builtin__)

View File

@ -19,7 +19,7 @@
from struct import calcsize
from ofproto_common import OFP_HEADER_SIZE
from ryu.ofproto.ofproto_common import OFP_HEADER_SIZE
# Action subtypes
NXAST_RESUBMIT = 1

View File

@ -14,16 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from . import ofproto_v1_0
from . import ofproto_v1_0_parser
from . import ofproto_v1_2
from . import ofproto_v1_2_parser
from . import ofproto_v1_3
from . import ofproto_v1_3_parser
from . import ofproto_v1_4
from . import ofproto_v1_4_parser
from . import ofproto_v1_5
from . import ofproto_v1_5_parser
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import ofproto_v1_0_parser
from ryu.ofproto import ofproto_v1_2
from ryu.ofproto import ofproto_v1_2_parser
from ryu.ofproto import ofproto_v1_3
from ryu.ofproto import ofproto_v1_3_parser
from ryu.ofproto import ofproto_v1_4
from ryu.ofproto import ofproto_v1_4_parser
from ryu.ofproto import ofproto_v1_5
from ryu.ofproto import ofproto_v1_5_parser
_versions = {

View File

@ -592,4 +592,4 @@ def nxm_nx_reg_w(idx):
NXM_HEADER_PACK_STRING = '!I'
from nicira_ext import * # For API compat
from ryu.ofproto.nicira_ext import * # For API compat

View File

@ -21,7 +21,7 @@ Decoder/Encoder implementations of OpenFlow 1.0.
import struct
import binascii
from ofproto_parser import StringifyMixin, MsgBase, msg_str_attr
from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase, msg_str_attr
from ryu.lib import addrconv
from ryu.lib import mac
from ryu.lib.pack_utils import msg_pack_into

View File

@ -25,7 +25,7 @@ from ryu.lib import addrconv
from ryu.lib import mac
from ryu.lib.pack_utils import msg_pack_into
from ryu import utils
from ofproto_parser import StringifyMixin, MsgBase, msg_str_attr
from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase, msg_str_attr
from . import ether
from . import ofproto_parser
from . import ofproto_v1_2 as ofproto

View File

@ -47,7 +47,7 @@ from ryu.lib import addrconv
from ryu.lib import mac
from ryu.lib.pack_utils import msg_pack_into
from ryu import utils
from ofproto_parser import StringifyMixin, MsgBase, msg_str_attr
from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase, msg_str_attr
from . import ether
from . import nicira_ext
from . import ofproto_parser
@ -829,9 +829,9 @@ class OFPMatch(StringifyMixin):
# OFPMatch(eth_src=('ff:ff:ff:00:00:00'), eth_type=0x800,
# ipv4_src='10.0.0.1')
kwargs = dict(ofproto.oxm_normalize_user(k, v) for
(k, v) in kwargs.iteritems())
(k, v) in kwargs.items())
fields = [ofproto.oxm_from_user(k, v) for (k, v)
in kwargs.iteritems()]
in kwargs.items()]
# assumption: sorting by OXM type values makes fields
# meet ordering requirements (eg. eth_type before ipv4_src)
fields.sort()
@ -6039,7 +6039,7 @@ class OFPSetAsync(MsgBase):
self.flow_removed_mask[0], self.flow_removed_mask[1])
import nx_actions
from ryu.ofproto import nx_actions
nx_actions.generate(
'ryu.ofproto.ofproto_v1_3',

View File

@ -25,7 +25,7 @@ from ryu.lib import addrconv
from ryu.lib import mac
from ryu.lib.pack_utils import msg_pack_into
from ryu import utils
from ofproto_parser import StringifyMixin, MsgBase, MsgInMsgBase, msg_str_attr
from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase, MsgInMsgBase, msg_str_attr
from . import ether
from . import ofproto_parser
from . import ofproto_common

View File

@ -25,7 +25,7 @@ from ryu.lib import addrconv
from ryu.lib import mac
from ryu.lib.pack_utils import msg_pack_into
from ryu import utils
from ofproto_parser import StringifyMixin, MsgBase, MsgInMsgBase, msg_str_attr
from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase, MsgInMsgBase, msg_str_attr
from . import ether
from . import ofproto_parser
from . import ofproto_common

View File

@ -62,7 +62,7 @@
import itertools
import struct
import ofproto_common
from ryu.ofproto import ofproto_common
from ryu.lib.pack_utils import msg_pack_into
from ryu.lib import type_desc
@ -138,7 +138,6 @@ class NiciraExtended1(_OxmClass):
def generate(modname):
import sys
import string
import functools
mod = sys.modules[modname]
@ -147,7 +146,7 @@ def generate(modname):
setattr(mod, k, v)
for i in mod.oxm_types:
uk = string.upper(i.name)
uk = i.name.upper()
if isinstance(i.num, tuple):
continue
oxm_class = i.num >> 7

View File

@ -17,7 +17,6 @@ import unittest
import logging
import netaddr
import functools
import new
from nose.tools import *
@ -666,8 +665,7 @@ def _add_tests_actions(cls):
func = functools.partial(_run, name=method_name, act=act, cls=cls)
func.func_name = method_name
func.__name__ = method_name
im = new.instancemethod(func, None, Test_ofctl)
setattr(Test_ofctl, method_name, im)
setattr(Test_ofctl, method_name, func)
def _add_tests_match(cls):
@ -686,8 +684,7 @@ def _add_tests_match(cls):
_run, name=method_name, attr=attr, cls=cls)
func.func_name = method_name
func.__name__ = method_name
im = new.instancemethod(func, None, Test_ofctl)
setattr(Test_ofctl, method_name, im)
setattr(Test_ofctl, method_name, func)
""" Test case """

View File

@ -227,7 +227,6 @@ def _add_tests():
import os
import os.path
import fnmatch
import new
import functools
this_dir = os.path.dirname(sys.modules[__name__].__file__)
@ -258,7 +257,6 @@ def _add_tests():
json_str=json_str)
f.func_name = method_name
f.__name__ = method_name
im = new.instancemethod(f, None, Test_Parser)
setattr(Test_Parser, method_name, im)
setattr(Test_Parser, method_name, f)
_add_tests()

View File

@ -134,7 +134,6 @@ class Test_Parser_Compat(unittest.TestCase):
def _add_tests():
import new
import functools
import itertools
@ -152,7 +151,6 @@ def _add_tests():
f.func_name = method_name
f.__name__ = method_name
cls = Test_Parser_Compat
im = new.instancemethod(f, None, cls)
setattr(cls, method_name, im)
setattr(cls, method_name, f)
_add_tests()

View File

@ -62,7 +62,6 @@ class Test_Parser_OFPMatch(unittest.TestCase):
def _add_tests():
import new
import functools
import itertools
@ -235,7 +234,6 @@ def _add_tests():
f.func_name = method_name
f.__name__ = method_name
cls = Test_Parser_OFPMatch
im = new.instancemethod(f, None, cls)
setattr(cls, method_name, im)
setattr(cls, method_name, f)
_add_tests()