[ARVADOS] created: 9cd1bd27bada41cd13fb9813144fe694a67c2d00
Git user
git at public.curoverse.com
Thu May 11 15:37:52 EDT 2017
at 9cd1bd27bada41cd13fb9813144fe694a67c2d00 (commit)
commit 9cd1bd27bada41cd13fb9813144fe694a67c2d00
Author: Tom Clegg <tom at curoverse.com>
Date: Thu May 11 15:37:32 2017 -0400
11681: Return native str type from KeepLocator.__str__() and Collection.portable_data_hash()
diff --git a/sdk/python/arvados/collection.py b/sdk/python/arvados/collection.py
index 1f50673..d4f2404 100644
--- a/sdk/python/arvados/collection.py
+++ b/sdk/python/arvados/collection.py
@@ -360,7 +360,7 @@ class CollectionWriter(CollectionBase):
def portable_data_hash(self):
stripped = self.stripped_manifest().encode()
- return hashlib.md5(stripped).hexdigest() + '+' + str(len(stripped))
+ return '{}+{}'.format(hashlib.md5(stripped).hexdigest(), len(stripped))
def manifest_text(self):
self.finish_current_stream()
diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index b0413eb..4b5aa75 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import
from __future__ import division
from future import standard_library
+from future.utils import native_str
standard_library.install_aliases()
from builtins import next
from builtins import str
@@ -73,8 +74,9 @@ class KeepLocator(object):
def __str__(self):
return '+'.join(
- str(s) for s in [self.md5sum, self.size,
- self.permission_hint()] + self.hints
+ native_str(s)
+ for s in [self.md5sum, self.size,
+ self.permission_hint()] + self.hints
if s is not None)
def stripped(self):
diff --git a/sdk/python/tests/test_collections.py b/sdk/python/tests/test_collections.py
index 77ec7bb..b40ba57 100644
--- a/sdk/python/tests/test_collections.py
+++ b/sdk/python/tests/test_collections.py
@@ -55,6 +55,10 @@ class ArvadosCollectionsTest(run_test_server.TestCaseWithServers,
cw.finish()
return cw.portable_data_hash()
+ def test_pdh_is_native_str(self):
+ pdh = self.write_foo_bar_baz()
+ self.assertEqual(type(''), type(pdh))
+
def test_keep_local_store(self):
self.assertEqual(self.keep_client.put(b'foo'), 'acbd18db4cc2f85cedef654fccc4a4d8+3', 'wrong md5 hash from Keep.put')
self.assertEqual(self.keep_client.get('acbd18db4cc2f85cedef654fccc4a4d8+3'), b'foo', 'wrong data from Keep.get')
diff --git a/sdk/python/tests/test_keep_locator.py b/sdk/python/tests/test_keep_locator.py
index 9b9c4b6..4c3d920 100644
--- a/sdk/python/tests/test_keep_locator.py
+++ b/sdk/python/tests/test_keep_locator.py
@@ -63,6 +63,11 @@ class ArvadosKeepLocatorTest(unittest.TestCase):
locator = '+'.join((base,) + loc_hints)
self.assertEqual(locator, str(KeepLocator(locator)))
+ def test_str_type(self):
+ base = next(self.base_locators(1))
+ locator = KeepLocator(base)
+ self.assertEqual(type(''), type(locator.__str__()))
+
def test_expiry_passed(self):
base = next(self.base_locators(1))
signature = next(self.signatures(1))
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list