aboutsummaryrefslogtreecommitdiff
path: root/cros_utils
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2019-07-24 23:20:57 -0700
committerGeorge Burgess <gbiv@chromium.org>2019-07-25 16:08:53 +0000
commit9a6dae865659ce5e32694ae92bd3f1f7310d0049 (patch)
treefb35dd1b9746822d1d98e6777744e288ba20bd8d /cros_utils
parentadcb8bff41c7f3756756cbe581547897ad49d098 (diff)
downloadtoolchain-utils-9a6dae865659ce5e32694ae92bd3f1f7310d0049.tar.gz
toolchain-utils: remove all xranges
This removes all mention of xrange from toolchain-utils (modulo ones being changed in other CLs that are in flight). It's now an apparent lint error to use xrange, and it hinders our move to python3. As commented on If90d26664c70ccb73750f17573b89933fdb048f4, xrange -> range in python2 is really only a space concern (or speed in pathological cases), so migrations of this nature are generally super straightforward. I glanced at each of these callsites, and none of them appear to be pathological, so my hope is that this should all be Just Fine :) (Also fun to note that this includes a .diff file that has python code embedded in it.) BUG=None TEST=Presubmit tests Change-Id: Ic9f3ac3a5044d7a07da8a249bc505278d98203de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1717130 Commit-Queue: George Burgess <gbiv@chromium.org> Commit-Queue: Luis Lozano <llozano@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'cros_utils')
-rwxr-xr-xcros_utils/buildbot_json.py6
-rw-r--r--cros_utils/tabulator.py10
2 files changed, 8 insertions, 8 deletions
diff --git a/cros_utils/buildbot_json.py b/cros_utils/buildbot_json.py
index 8a9d9cb8..42a27744 100755
--- a/cros_utils/buildbot_json.py
+++ b/cros_utils/buildbot_json.py
@@ -316,7 +316,7 @@ class NonAddressableNodeList(VirtualNodeList): # pylint: disable=W0223
@property
def cached_children(self):
if self.parent.cached_data is not None:
- for i in xrange(len(self.parent.cached_data[self.subkey])):
+ for i in range(len(self.parent.cached_data[self.subkey])):
yield self[i]
@property
@@ -352,7 +352,7 @@ class NonAddressableNodeList(VirtualNodeList): # pylint: disable=W0223
def __iter__(self):
"""Enables 'for i in obj:'. It returns children."""
if self.data:
- for i in xrange(len(self.data)):
+ for i in range(len(self.data)):
yield self[i]
def __getitem__(self, key):
@@ -868,7 +868,7 @@ class Builds(AddressableNodeList):
# Only cache keys here.
self.cache_keys()
if self._keys:
- for i in xrange(max(self._keys), -1, -1):
+ for i in range(max(self._keys), -1, -1):
yield self[i]
def cache_keys(self):
diff --git a/cros_utils/tabulator.py b/cros_utils/tabulator.py
index e2f27bc4..59e4d426 100644
--- a/cros_utils/tabulator.py
+++ b/cros_utils/tabulator.py
@@ -340,17 +340,17 @@ class SamplesTableGenerator(TableGenerator):
row = [None] * len(header)
row[0] = '%s (samples)' % k
row[1] = 'N/A'
- for label_index in xrange(2, len(row)):
+ for label_index in range(2, len(row)):
row[label_index] = [0] * iterations
for cur_row in table[1:]:
# Iterate through each benchmark
if len(cur_row) > 1:
- for label_index in xrange(2, len(cur_row)):
+ for label_index in range(2, len(cur_row)):
# Iterate through each run in a single benchmark
# each result should look like ((pass, fail), [values_list])
bench_runs = cur_row[label_index][1]
- for index in xrange(iterations):
+ for index in range(iterations):
# Accumulate each run result to composite benchmark run
# If any run fails, then we set this run for composite benchmark
# to None so that we know it fails.
@@ -360,11 +360,11 @@ class SamplesTableGenerator(TableGenerator):
row[label_index][index] = None
else:
# One benchmark totally fails, no valid data will be in final result
- for label_index in xrange(2, len(row)):
+ for label_index in range(2, len(row)):
row[label_index] = [None] * iterations
break
# Calculate pass and fail count for composite benchmark
- for label_index in xrange(2, len(row)):
+ for label_index in range(2, len(row)):
run_pass = 0
run_fail = 0
for run in row[label_index]: