From 4be1ae2ae22e100e6bbc4bd127af49296efbd763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3=20?= =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=BA=20=28=D0=BD=D0=BE=D1=83=D1=82=D0=B1?= =?UTF-8?q?=D1=83=D0=BA=20=D0=B4=D0=BE=D0=BC=D0=B0=29?= Date: Mon, 4 Jun 2012 22:54:16 +0600 Subject: Introduce Python's absolute_imports Helps greatly when porting to Python 3 --- python/netlink/core.py | 5 ++++- python/netlink/route/address.py | 13 ++++++++----- python/netlink/route/link.py | 12 +++++++----- python/netlink/route/links/dummy.py | 5 +++-- python/netlink/route/links/inet.py | 9 +++++---- python/netlink/route/links/vlan.py | 6 ++++-- python/netlink/route/qdisc/htb.py | 10 ++++++---- python/netlink/route/tc.py | 12 ++++++------ python/netlink/util.py | 6 ++++-- 9 files changed, 47 insertions(+), 31 deletions(-) diff --git a/python/netlink/core.py b/python/netlink/core.py index e311d5f..26ea6ca 100644 --- a/python/netlink/core.py +++ b/python/netlink/core.py @@ -25,8 +25,11 @@ The following exceptions are defined: All other classes or functions in this module are considered implementation details. """ +from __future__ import absolute_import -import capi + + +from . import capi import sys import socket import struct diff --git a/python/netlink/route/address.py b/python/netlink/route/address.py index 3654834..29b8072 100644 --- a/python/netlink/route/address.py +++ b/python/netlink/route/address.py @@ -5,17 +5,20 @@ """Module providing access to network addresses """ +from __future__ import absolute_import + + __version__ = "1.0" __all__ = [ 'AddressCache', 'Address'] import datetime -import netlink.core as netlink -import netlink.capi as core_capi -import netlink.route.capi as capi -import netlink.route.link as Link -import netlink.util as util +from .. import core as netlink +from .. import capi as core_capi +from . import capi as capi +from . import link as Link +from .. import util as util ########################################################################### # Address Cache diff --git a/python/netlink/route/link.py b/python/netlink/route/link.py index 3a428c9..fce2cd7 100644 --- a/python/netlink/route/link.py +++ b/python/netlink/route/link.py @@ -34,6 +34,8 @@ The following public functions exist: """ +from __future__ import absolute_import + __version__ = "0.1" __all__ = [ 'LinkCache', @@ -42,11 +44,11 @@ __all__ = [ import socket import sys -import netlink.core as netlink -import netlink.capi as core_capi -import netlink.route.capi as capi -import netlink.route.links.inet as inet -import netlink.util as util +from .. import core as netlink +from .. import capi as core_capi +from . import capi as capi +from .links import inet as inet +from .. import util as util ########################################################################### # Link statistics definitions diff --git a/python/netlink/route/links/dummy.py b/python/netlink/route/links/dummy.py index 8210413..6c96617 100644 --- a/python/netlink/route/links/dummy.py +++ b/python/netlink/route/links/dummy.py @@ -5,13 +5,14 @@ """Dummy """ +from __future__ import absolute_import __version__ = "1.0" __all__ = ['init'] -import netlink.core as netlink -import netlink.route.capi as capi +from ... import core as netlink +from .. import capi as capi class DummyLink(object): def __init__(self, link): self._rtnl_link = link diff --git a/python/netlink/route/links/inet.py b/python/netlink/route/links/inet.py index 63c234f..73bde6b 100644 --- a/python/netlink/route/links/inet.py +++ b/python/netlink/route/links/inet.py @@ -6,12 +6,13 @@ """ -__all__ = [''] +from __future__ import absolute_import -import netlink.core as netlink -import netlink.route.capi as capi -import netlink.util as util +__all__ = [''] +from ... import core as netlink +from .. import capi as capi +from ... import util as util DEVCONF_FORWARDING = 1 DEVCONF_MC_FORWARDING = 2 DEVCONF_PROXY_ARP = 3 diff --git a/python/netlink/route/links/vlan.py b/python/netlink/route/links/vlan.py index 7f28247..134e721 100644 --- a/python/netlink/route/links/vlan.py +++ b/python/netlink/route/links/vlan.py @@ -6,9 +6,11 @@ """ -import netlink.core as netlink -import netlink.route.capi as capi +from __future__ import absolute_import + +from ... import core as netlink +from .. import capi as capi class VLANLink(object): def __init__(self, link): self._link = link diff --git a/python/netlink/route/qdisc/htb.py b/python/netlink/route/qdisc/htb.py index 13e10f2..23c7f75 100644 --- a/python/netlink/route/qdisc/htb.py +++ b/python/netlink/route/qdisc/htb.py @@ -6,10 +6,12 @@ """ -import netlink.core as netlink -import netlink.util as util -import netlink.route.capi as capi -import netlink.route.tc as tc +from __future__ import absolute_import + +from ... import core as netlink +from ... import util as util +from .. import capi as capi +from .. import tc as tc class HTBQdisc(object): def __init__(self, qdisc): diff --git a/python/netlink/route/tc.py b/python/netlink/route/tc.py index bae9bca..0d20e79 100644 --- a/python/netlink/route/tc.py +++ b/python/netlink/route/tc.py @@ -1,6 +1,7 @@ # # Copyright (c) 2011 Thomas Graf # +from __future__ import absolute_import __all__ = [ 'TcCache', @@ -12,12 +13,11 @@ __all__ = [ import socket import sys -import netlink.core as netlink -import netlink.capi as core_capi -import netlink.route.capi as capi -import netlink.util as util - -import netlink.route.link as Link +from .. import core as netlink +from .. import capi as core_capi +from . import capi as capi +from .. import util as util +from . import link as Link TC_PACKETS = 0 TC_BYTES = 1 diff --git a/python/netlink/util.py b/python/netlink/util.py index 191c531..0a73db4 100644 --- a/python/netlink/util.py +++ b/python/netlink/util.py @@ -8,8 +8,10 @@ """ -import netlink.core as netlink -import netlink.capi as capi +from __future__ import absolute_import + +from . import core as netlink +from . import capi as capi from string import Formatter __version__ = "1.0" -- cgit v0.12