Skip to content

Commit 5d2b064

Browse files
committed
use defaults when host, port, or base == None
This permits the caller to request the default value explicitly by pasing None to either host, port, or base when instantiating ipfsApi.client.Client. Closes ipfs-shipyard#7
1 parent 1f4831f commit 5d2b064

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ipfsApi/client.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
FileCommand
99
from .exceptions import InvalidCommand
1010

11+
default_host = 'localhost'
12+
default_port = 5001
13+
default_base = 'api/v0'
1114

1215

1316
class Client(object):
@@ -16,11 +19,18 @@ class Client(object):
1619

1720

1821
def __init__(self,
19-
host='127.0.0.1',
20-
port=5001,
21-
base='api/v0',
22+
host=None,
23+
port=None,
24+
base=None,
2225
default_enc='json',
2326
**defaults):
27+
28+
if host is None:
29+
host = default_host
30+
if port is None:
31+
port = default_port
32+
if base is None:
33+
base = default_base
2434

2535
self._client = self.__client__(host, port, base, default_enc)
2636

0 commit comments

Comments
 (0)