X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/55a0e060233385a9be029d0e75c152307950e268..95d1231a25637c5ba0fd07b116876b17711ec201:/sdk/python/arvados/collection.py diff --git a/sdk/python/arvados/collection.py b/sdk/python/arvados/collection.py index 82ef15689f..3a90d6d3b0 100644 --- a/sdk/python/arvados/collection.py +++ b/sdk/python/arvados/collection.py @@ -51,7 +51,7 @@ def normalize_stream(s, stream): fout = f.replace(' ', '\\040') for segment in stream[f]: segmentoffset = blocks[segment[arvados.LOCATOR]] + segment[arvados.OFFSET] - if current_span == None: + if current_span is None: current_span = [segmentoffset, segmentoffset + segment[arvados.SEGMENTSIZE]] else: if segmentoffset == current_span[1]: @@ -60,7 +60,7 @@ def normalize_stream(s, stream): stream_tokens.append("{0}:{1}:{2}".format(current_span[0], current_span[1] - current_span[0], fout)) current_span = [segmentoffset, segmentoffset + segment[arvados.SEGMENTSIZE]] - if current_span != None: + if current_span is not None: stream_tokens.append("{0}:{1}:{2}".format(current_span[0], current_span[1] - current_span[0], fout)) if not stream[f]: @@ -185,7 +185,7 @@ class CollectionReader(CollectionBase): error_via_keep = self._populate_from_keep() if not self._manifest_text: error_via_api = self._populate_from_api_server() - if error_via_api != None and not should_try_keep: + if error_via_api is not None and not should_try_keep: raise error_via_api if (not self._manifest_text and not error_via_keep and @@ -348,9 +348,8 @@ class CollectionWriter(CollectionBase): def _work_trees(self): path, stream_name, max_manifest_depth = self._queued_trees[0] - make_dirents = (util.listdir_recursive if (max_manifest_depth == 0) - else os.listdir) - d = make_dirents(path) + d = util.listdir_recursive( + path, max_depth = (None if max_manifest_depth == 0 else 0)) if d: self._queue_dirents(stream_name, d) else: @@ -418,7 +417,7 @@ class CollectionWriter(CollectionBase): return self._current_file_name def finish_current_file(self): - if self._current_file_name == None: + if self._current_file_name is None: if self._current_file_pos == self._current_stream_length: return raise errors.AssertionError( @@ -489,10 +488,7 @@ class CollectionWriter(CollectionBase): manifest += ' ' + ' '.join("%d:%d:%s" % (sfile[0], sfile[1], sfile[2].replace(' ', '\\040')) for sfile in stream[2]) manifest += "\n" - if manifest: - return manifest - else: - return "" + return manifest def data_locators(self): ret = []