Merge branch '18943-created-at-index' refs #18943
[arvados.git] / sdk / python / arvados / _ranges.py
index 5532ea011ee8c5244e15add14425ad526941fc90..bb245ab2bf3f0cce8e374e8215a3f73200e9bded 100644 (file)
@@ -1,3 +1,9 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+from __future__ import division
+from builtins import object
 import logging
 
 _logger = logging.getLogger('arvados.ranges')
@@ -24,14 +30,14 @@ class Range(object):
                 self.segment_offset == other.segment_offset)
 
 def first_block(data_locators, range_start):
-    block_start = 0L
+    block_start = 0
 
     # range_start/block_start is the inclusive lower bound
     # range_end/block_end is the exclusive upper bound
 
     hi = len(data_locators)
     lo = 0
-    i = int((hi + lo) / 2)
+    i = (hi + lo) // 2
     block_size = data_locators[i].range_size
     block_start = data_locators[i].range_start
     block_end = block_start + block_size
@@ -47,7 +53,7 @@ def first_block(data_locators, range_start):
             lo = i
         else:
             hi = i
-        i = int((hi + lo) / 2)
+        i = (hi + lo) // 2
         block_size = data_locators[i].range_size
         block_start = data_locators[i].range_start
         block_end = block_start + block_size
@@ -190,7 +196,7 @@ def replace_range(data_locators, new_range_start, new_range_size, new_locator, n
             # range ends before this segment starts, so don't look at any more locators
             break
 
-        if  old_segment_start <= new_range_start and new_range_end <= old_segment_end:
+        if old_segment_start <= new_range_start and new_range_end <= old_segment_end:
             # new range starts and ends in old segment
             # split segment into up to 3 pieces
             if (new_range_start-old_segment_start) > 0: