From: Коренберг Марк (ноутбук дома) Date: Mon, 4 Jun 2012 17:20:24 +0000 (+0600) Subject: Code cleanups X-Git-Tag: libnl3_2_11~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb890a5b5e769a6ca7e639e004c06c6e3bbc46d3;p=libnl Code cleanups 1. unused "import struct" removed 2. AddressFamily.__len__ is defined, but why in so way? removed. 3. comparison against instancemethod type fixed --- diff --git a/python/netlink/core.py b/python/netlink/core.py index b6cf7e9..0ffa22f 100644 --- a/python/netlink/core.py +++ b/python/netlink/core.py @@ -32,7 +32,6 @@ from __future__ import absolute_import from . import capi import sys import socket -import struct __all__ = ['Message', 'Socket', 'DumpParams', 'Object', 'Cache', 'KernelError', 'NetlinkError'] @@ -619,9 +618,6 @@ class AddressFamily(object): def __str__(self): return capi.nl_af2str(self._family, 32)[0] - def __len__(self): - return len(str(self)) - def __int__(self): return self._family diff --git a/python/netlink/util.py b/python/netlink/util.py index f6e7dec..73a211d 100644 --- a/python/netlink/util.py +++ b/python/netlink/util.py @@ -13,6 +13,7 @@ from __future__ import absolute_import from . import core as netlink from . import capi as capi from string import Formatter +import types __version__ = "1.0" @@ -82,7 +83,7 @@ class MyFormatter(Formatter): value = getattr(self._obj, key) title = None - if type(value) == 'instancemethod': + if isinstance(value, types.MethodType): value = value() try: @@ -144,9 +145,6 @@ class MyFormatter(Formatter): raise ValueError("Unknown converion specifier {0!s}".format(conversion)) - def nl(self): - return '\n' + self._indent - def nl(self, format_string=''): return '\n' + self._indent + self.format(format_string)