From 3b4a206f5439a4db2797a3fa4f8c5e265e5728d7 Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Tue, 21 May 2019 13:28:23 -0700 Subject: [PATCH 1/2] Drop git dependency for pypi release --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3e4f38cd97..3f94a347d5 100644 --- a/setup.py +++ b/setup.py @@ -96,7 +96,7 @@ 'libp2p': [ "base58>=1.0.3", # use the forked multiaddr temporarily until the fixing changes are released - "multiaddr @ git+https://git@github.com/mhchia/py-multiaddr@feature/add-unix-proto", + "multiaddr>=0.0.7,<0.1.0", "protobuf>=3.6.1", "pymultihash>=0.8.2", ], From ce11779dad2944330644e994cadbd584d2459395 Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Tue, 21 May 2019 13:39:24 -0700 Subject: [PATCH 2/2] Bugfix trim_middle utility on short strings --- p2p/_utils.py | 5 ++++- tests/p2p/test_utils.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/p2p/_utils.py b/p2p/_utils.py index 3a2bdbbc6f..afa9336348 100644 --- a/p2p/_utils.py +++ b/p2p/_utils.py @@ -117,5 +117,8 @@ def trim_middle(arbitrary_string: str, max_length: int) -> str: half_len, is_odd = divmod(max_length, 2) first_half = arbitrary_string[:half_len - 1] last_half_len = half_len - 2 + is_odd - last_half = arbitrary_string[last_half_len * -1:] + if last_half_len > 0: + last_half = arbitrary_string[last_half_len * -1:] + else: + last_half = '' return f"{first_half}✂✂✂{last_half}" diff --git a/tests/p2p/test_utils.py b/tests/p2p/test_utils.py index c770cce307..1a0790813e 100644 --- a/tests/p2p/test_utils.py +++ b/tests/p2p/test_utils.py @@ -14,6 +14,7 @@ ("notcut", 6, "notcut"), ("tobecut", 6, "to✂✂✂t"), ("tobecut", 5, "t✂✂✂t"), + ("0000", 3, "✂✂✂"), ("really long thing with a bunch of garbage", 20, "really lo✂✂✂ garbage"), ) )