import time
from pyroute2.common import ANCIENT
from pyroute2.netlink import NetlinkError
# How long should we wait on EACH commit() checkpoint: for ipaddr,
# ports etc. That's not total commit() timeout.
SYNC_TIMEOUT = 5


class DeprecationException(Exception):
    pass


class CommitException(Exception):
    pass


class CreateException(Exception):
    pass


def bypass(f):
    if ANCIENT:
        return f
    else:
        return lambda *x, **y: None


class compat(object):
    '''
    A namespace to keep all compat-related methods.
    '''
    @bypass
    @classmethod
    def fix_timeout(timeout):
        time.sleep(timeout)

    @bypass
    @classmethod
    def fix_check_link(nl, index):
        # check, if the link really exists --
        # on some old kernels you can receive
        # broadcast RTM_NEWLINK after the link
        # was deleted
        try:
            nl.get_links(index)
        except NetlinkError as e:
            if e.code == 19:  # No such device
                # just drop this message then
                return True

@@ -430,16 +430,29 @@
  return 
+staticmethod(
 lambda *
@@ -463,16 +463,17 @@
 *y: None
+)
 %0A%0A%0Aclass

fix compat bypass for Python2