Skip to content

Commit 6f0acad

Browse files
committed
Unify tabs → 4 spaces
1 parent f2647c9 commit 6f0acad

File tree

14 files changed

+214
-214
lines changed

14 files changed

+214
-214
lines changed

multiaddr/codecs/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99

1010
class NoneCodec:
11-
SIZE = 0
12-
IS_PATH = False
11+
SIZE = 0
12+
IS_PATH = False
1313

1414

1515
CODEC_CACHE = {}
@@ -19,4 +19,4 @@ def codec_by_name(name):
1919
codec = CODEC_CACHE.get(name)
2020
if not codec:
2121
codec = CODEC_CACHE[name] = importlib.import_module(".{0}".format(name), __name__)
22-
return codec
22+
return codec

multiaddr/codecs/_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ def packed_net_bytes_to_int(b):
55
else: # PY2
66
def packed_net_bytes_to_int(b):
77
"""Convert the given big-endian byte-string to an int."""
8-
return int(b.encode('hex'), 16)
8+
return int(b.encode('hex'), 16)

multiaddr/codecs/fspath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def fsdecode(path):
2828

2929

3030
def to_bytes(proto, string):
31-
return fsencode(string)
31+
return fsencode(string)
3232

3333

3434
def to_string(proto, buf):
35-
return fsdecode(buf)
35+
return fsdecode(buf)

multiaddr/codecs/idna.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111

1212
def to_bytes(proto, string):
13-
return idna.encode(string, uts46=True)
13+
return idna.encode(string, uts46=True)
1414

1515

1616
def to_string(proto, buf):
17-
return idna.decode(buf)
17+
return idna.decode(buf)

multiaddr/codecs/ip4.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212

1313
def to_bytes(proto, string):
14-
return netaddr.IPAddress(string, version=4).packed
14+
return netaddr.IPAddress(string, version=4).packed
1515

1616

1717
def to_string(proto, buf):
18-
ip_addr = netaddr.IPAddress(packed_net_bytes_to_int(buf), version=4)
19-
return six.text_type(ip_addr)
18+
ip_addr = netaddr.IPAddress(packed_net_bytes_to_int(buf), version=4)
19+
return six.text_type(ip_addr)

multiaddr/codecs/ip6.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212

1313
def to_bytes(proto, string):
14-
return netaddr.IPAddress(string, version=6).packed
14+
return netaddr.IPAddress(string, version=6).packed
1515

1616

1717
def to_string(proto, buf):
18-
ip_addr = netaddr.IPAddress(packed_net_bytes_to_int(buf), version=6)
19-
return six.text_type(ip_addr)
18+
ip_addr = netaddr.IPAddress(packed_net_bytes_to_int(buf), version=6)
19+
return six.text_type(ip_addr)

multiaddr/codecs/onion.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@
1010

1111

1212
def to_bytes(proto, string):
13-
addr = string.split(":")
14-
if len(addr) != 2:
15-
raise ValueError("Does not contain a port number")
13+
addr = string.split(":")
14+
if len(addr) != 2:
15+
raise ValueError("Does not contain a port number")
1616

17-
# onion address without the ".onion" substring
18-
if len(addr[0]) != 16:
19-
raise ValueError("Invalid onion host address length (must be 16 characters)")
20-
try:
21-
onion_host_bytes = base64.b32decode(addr[0].upper())
22-
except Exception as exc:
23-
six.raise_from(ValueError("Cannot decode {0!r} as base32: {1}".format(addr[0], exc)), exc)
17+
# onion address without the ".onion" substring
18+
if len(addr[0]) != 16:
19+
raise ValueError("Invalid onion host address length (must be 16 characters)")
20+
try:
21+
onion_host_bytes = base64.b32decode(addr[0].upper())
22+
except Exception as exc:
23+
six.raise_from(ValueError("Cannot decode {0!r} as base32: {1}".format(addr[0], exc)), exc)
2424

25-
# onion port number
26-
try:
27-
port = int(addr[1], 10)
28-
except ValueError as exc:
29-
six.raise_from(ValueError("Port number is not a base 10 integer"), exc)
30-
if port not in range(1, 65536):
31-
raise ValueError("Port number is not in range(1, 65536)")
25+
# onion port number
26+
try:
27+
port = int(addr[1], 10)
28+
except ValueError as exc:
29+
six.raise_from(ValueError("Port number is not a base 10 integer"), exc)
30+
if port not in range(1, 65536):
31+
raise ValueError("Port number is not in range(1, 65536)")
3232

33-
return b''.join((onion_host_bytes, struct.pack('>H', port)))
33+
return b''.join((onion_host_bytes, struct.pack('>H', port)))
3434

3535

3636
def to_string(proto, buf):
37-
addr_bytes, port_bytes = (buf[:-2], buf[-2:])
38-
addr = base64.b32encode(addr_bytes).decode('ascii').lower()
39-
port = six.text_type(struct.unpack('>H', port_bytes)[0])
40-
return u':'.join([addr, port])
37+
addr_bytes, port_bytes = (buf[:-2], buf[-2:])
38+
addr = base64.b32encode(addr_bytes).decode('ascii').lower()
39+
port = six.text_type(struct.unpack('>H', port_bytes)[0])
40+
return u':'.join([addr, port])

multiaddr/codecs/p2p.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212

1313
def to_bytes(proto, string):
14-
# the address is a base58-encoded string
15-
if six.PY2 and isinstance(string, unicode):
16-
string = string.encode("ascii")
17-
mm = base58.b58decode(string)
18-
if len(mm) < 5:
19-
raise ValueError("P2P MultiHash too short: len() < 5")
20-
return mm
14+
# the address is a base58-encoded string
15+
if six.PY2 and isinstance(string, unicode):
16+
string = string.encode("ascii")
17+
mm = base58.b58decode(string)
18+
if len(mm) < 5:
19+
raise ValueError("P2P MultiHash too short: len() < 5")
20+
return mm
2121

2222

2323
def to_string(proto, buf):
24-
return base58.b58encode(buf).decode('ascii')
24+
return base58.b58encode(buf).decode('ascii')

multiaddr/codecs/uint16be.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010

1111
def to_bytes(proto, string):
12-
try:
13-
return struct.pack('>H', int(string, 10))
14-
except ValueError as exc:
15-
six.raise_from(ValueError("Not a base 10 integer"), exc)
16-
except struct.error as exc:
17-
six.raise_from(ValueError("Integer not in range(65536)"), exc)
12+
try:
13+
return struct.pack('>H', int(string, 10))
14+
except ValueError as exc:
15+
six.raise_from(ValueError("Not a base 10 integer"), exc)
16+
except struct.error as exc:
17+
six.raise_from(ValueError("Integer not in range(65536)"), exc)
1818

1919

2020
def to_string(proto, buf):
21-
if len(buf) != 2:
22-
raise ValueError("Invalid integer length (must be 2 bytes / 16 bits)")
23-
return six.text_type(struct.unpack('>H', buf)[0])
21+
if len(buf) != 2:
22+
raise ValueError("Invalid integer length (must be 2 bytes / 16 bits)")
23+
return six.text_type(struct.unpack('>H', buf)[0])

multiaddr/exceptions.py

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
class Error(Exception):
2-
pass
2+
pass
33

44

55
class LookupError(LookupError, Error):
6-
pass
6+
pass
77

88

99
class ProtocolLookupError(LookupError):
10-
"""
11-
MultiAddr did not contain a protocol with the requested code
12-
"""
13-
14-
def __init__(self, proto, string):
15-
self.proto = proto
16-
self.string = string
17-
18-
super(ProtocolLookupError, self).__init__(
19-
"MultiAddr {0!r} does not contain protocol {1}".format(string, proto)
20-
)
10+
"""
11+
MultiAddr did not contain a protocol with the requested code
12+
"""
13+
14+
def __init__(self, proto, string):
15+
self.proto = proto
16+
self.string = string
17+
18+
super(ProtocolLookupError, self).__init__(
19+
"MultiAddr {0!r} does not contain protocol {1}".format(string, proto)
20+
)
2121

2222

2323
class ParseError(ValueError, Error):
24-
pass
24+
pass
2525

2626

2727
class StringParseError(ParseError):
28-
"""
29-
MultiAddr string representation could not be parsed
30-
"""
28+
"""
29+
MultiAddr string representation could not be parsed
30+
"""
3131

32-
def __init__(self, message, string, protocol=None, original=None):
33-
self.message = message
34-
self.string = string
35-
self.protocol = protocol
36-
self.original = original
32+
def __init__(self, message, string, protocol=None, original=None):
33+
self.message = message
34+
self.string = string
35+
self.protocol = protocol
36+
self.original = original
3737

38-
if protocol:
39-
message = "Invalid MultiAddr {0!r} protocol {1}: {2}".format(string, protocol, message)
40-
else:
41-
message = "Invalid MultiAddr {0!r}: {1}".format(string, message)
38+
if protocol:
39+
message = "Invalid MultiAddr {0!r} protocol {1}: {2}".format(string, protocol, message)
40+
else:
41+
message = "Invalid MultiAddr {0!r}: {1}".format(string, message)
4242

43-
super(StringParseError, self).__init__(message)
43+
super(StringParseError, self).__init__(message)
4444

4545

4646
class BinaryParseError(ParseError):
47-
"""
48-
MultiAddr binary representation could not be parsed
49-
"""
47+
"""
48+
MultiAddr binary representation could not be parsed
49+
"""
5050

51-
def __init__(self, message, binary, protocol, original=None):
52-
self.message = message
53-
self.binary = binary
54-
self.protocol = protocol
55-
self.original = original
51+
def __init__(self, message, binary, protocol, original=None):
52+
self.message = message
53+
self.binary = binary
54+
self.protocol = protocol
55+
self.original = original
5656

57-
message = "Invalid binary MultiAddr protocol {0}: {1}".format(protocol, message)
57+
message = "Invalid binary MultiAddr protocol {0}: {1}".format(protocol, message)
5858

59-
super(BinaryParseError, self).__init__(message)
59+
super(BinaryParseError, self).__init__(message)
6060

6161

6262
class ProtocolManagerError(Error):
63-
pass
63+
pass
6464

6565

6666
class ProtocolExistsError(ProtocolManagerError):
67-
"""
68-
Protocol with the given name or code already exists
69-
"""
70-
def __init__(self, proto, kind="name"):
71-
self.proto = proto
72-
self.kind = kind
67+
"""
68+
Protocol with the given name or code already exists
69+
"""
70+
def __init__(self, proto, kind="name"):
71+
self.proto = proto
72+
self.kind = kind
7373

74-
super(ProtocolExistsError, self).__init__(
75-
"Protocol with {0} {1!r} already exists".format(kind, getattr(proto, kind))
76-
)
74+
super(ProtocolExistsError, self).__init__(
75+
"Protocol with {0} {1!r} already exists".format(kind, getattr(proto, kind))
76+
)
7777

7878
class ProtocolNotFoundError(ProtocolManagerError):
79-
"""
80-
No protocol with the given name or code found
81-
"""
82-
def __init__(self, value, kind="name"):
83-
self.value = value
84-
self.kind = kind
85-
86-
super(ProtocolNotFoundError, self).__init__(
87-
"No protocol with {0} {1!r} found".format(kind, value)
88-
)
79+
"""
80+
No protocol with the given name or code found
81+
"""
82+
def __init__(self, value, kind="name"):
83+
self.value = value
84+
self.kind = kind
85+
86+
super(ProtocolNotFoundError, self).__init__(
87+
"No protocol with {0} {1!r} found".format(kind, value)
88+
)

0 commit comments

Comments
 (0)