diff options
author | Коренберг Марк (ноутбук дома) <socketpair@gmail.com> | 2012-06-04 23:12:26 +0600 |
---|---|---|
committer | Коренберг Марк (ноутбук дома) <socketpair@gmail.com> | 2012-06-08 22:26:35 +0600 |
commit | 38fefc5c1b005c518d0d511c0921169b92faa86c (patch) | |
tree | 8429324b253a26eb04b11bea6226492b5ffe38e2 /python | |
parent | b369d22f9276d4279081b9dff13953adb8f57e07 (diff) | |
download | libnl-38fefc5c1b005c518d0d511c0921169b92faa86c.tar.gz |
Fixed various str-related logick
Diffstat (limited to 'python')
-rw-r--r-- | python/netlink/core.py | 8 | ||||
-rw-r--r-- | python/netlink/route/link.py | 4 | ||||
-rw-r--r-- | python/netlink/route/links/inet.py | 2 | ||||
-rw-r--r-- | python/netlink/route/links/vlan.py | 2 | ||||
-rw-r--r-- | python/netlink/util.py | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/python/netlink/core.py b/python/netlink/core.py index ea78691..b6cf7e9 100644 --- a/python/netlink/core.py +++ b/python/netlink/core.py @@ -92,14 +92,14 @@ class NetlinkError(Exception): class KernelError(NetlinkError): def __str__(self): - return "Kernel returned: " + self._msg + return "Kernel returned: {0}".format(self._msg) class ImmutableError(NetlinkError): def __init__(self, msg): self._msg = msg def __str__(self): - return "Immutable attribute: " + self._msg + return "Immutable attribute: {0}".format(self._msg) class Message(object): """Netlink message""" @@ -162,7 +162,7 @@ class Socket(object): capi.nl_socket_free(self._sock) def __str__(self): - return "nlsock<" + str(self.localPort) + ">" + return "nlsock<{0}>".format(self.localPort) @property def local_port(self): @@ -626,7 +626,7 @@ class AddressFamily(object): return self._family def __repr__(self): - return 'AddressFamily(\'' + str(self) + '\')' + return 'AddressFamily({0!r})'.format(str(self)) ########################################################################### diff --git a/python/netlink/route/link.py b/python/netlink/route/link.py index 74ec2f9..8c87971 100644 --- a/python/netlink/route/link.py +++ b/python/netlink/route/link.py @@ -127,7 +127,7 @@ class LinkCache(netlink.Cache): def __getitem__(self, key): if type(key) is int: link = capi.rtnl_link_get(self._nl_cache, key) - elif type(key) is str: + else: link = capi.rtnl_link_get_by_name(self._nl_cache, key) if link is None: @@ -227,7 +227,7 @@ class Link(netlink.Object): @flags.setter def flags(self, value): - if type(value) is list: + if not (type(value) is str): for flag in value: self._set_flag(flag) else: diff --git a/python/netlink/route/links/inet.py b/python/netlink/route/links/inet.py index 76a9e92..b5b1152 100644 --- a/python/netlink/route/links/inet.py +++ b/python/netlink/route/links/inet.py @@ -52,7 +52,7 @@ class InetLink(object): self._link = link def details(self, fmt): - buf = '\n' + fmt.nl('\t%s\n\t' % util.title('Configuration:')) + buf = fmt.nl('\n\t{0}\n\t'.format(util.title('Configuration:'))) for i in range(DEVCONF_FORWARDING,DEVCONF_MAX+1): if i & 1 and i > 1: diff --git a/python/netlink/route/links/vlan.py b/python/netlink/route/links/vlan.py index 134e721..c9fe2a7 100644 --- a/python/netlink/route/links/vlan.py +++ b/python/netlink/route/links/vlan.py @@ -57,7 +57,7 @@ class VLANLink(object): # - egress map def brief(self): - return 'vlan-id ' + self.id + return 'vlan-id {0}'.format(self.id) def init(link): link.vlan = VLANLink(link._link) diff --git a/python/netlink/util.py b/python/netlink/util.py index a8c831f..f6e7dec 100644 --- a/python/netlink/util.py +++ b/python/netlink/util.py @@ -17,7 +17,7 @@ from string import Formatter __version__ = "1.0" def _color(t, c): - return chr(0x1b)+"["+str(c)+"m"+str(t)+chr(0x1b)+"[0m" + return b'{esc}[{color}m{text}{esc}[0m'.format(esc=b'\x1b', color=c, text=t) def black(t): return _color(t, 30) @@ -126,7 +126,7 @@ class MyFormatter(Formatter): if include_title: if not title: title = key # fall back to key as title - value = kw(title) + ' ' + value + value = '{0} {1}'.format(kw(title), value) return value |