summaryrefslogtreecommitdiffstats
path: root/src/script/scons-time.py
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 (GMT)
commit59ed0a109bf5add2efcef459080837b11066c6fb (patch)
treefff879b4f9676a72e16c0f7b4dd969f050038b4f /src/script/scons-time.py
parent00a3188193ba1feef927cf18e7f5fc20ad71b848 (diff)
downloadSCons-59ed0a109bf5add2efcef459080837b11066c6fb.zip
SCons-59ed0a109bf5add2efcef459080837b11066c6fb.tar.gz
SCons-59ed0a109bf5add2efcef459080837b11066c6fb.tar.bz2
http://scons.tigris.org/issues/show_bug.cgi?id=2329
Applied a number of idiomatic changes. Uses of the 'sort()' method were converted into calls of 'sorted()' when possible and the sorted() expression was inserted into a subsequent statement whenever that made sense. The statement 'while 1:' was changed to 'while True:'. Names from the 'types' module (e.g., 'types.FooType') were converted to the equivalent build-in type (e.g., 'foo'). Comparisons between types were changed to use 'isinstance()'.
Diffstat (limited to 'src/script/scons-time.py')
-rw-r--r--src/script/scons-time.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/script/scons-time.py b/src/script/scons-time.py
index c75bc13..04fa573 100644
--- a/src/script/scons-time.py
+++ b/src/script/scons-time.py
@@ -59,6 +59,32 @@ except NameError:
import __builtin__
__builtin__.True = not 0
+try:
+ sorted
+except NameError:
+ # Pre-2.4 Python has no sorted() function.
+ #
+ # The pre-2.4 Python list.sort() method does not support
+ # list.sort(key=) nor list.sort(reverse=) keyword arguments, so
+ # we must implement the functionality of those keyword arguments
+ # by hand instead of passing them to list.sort().
+ def sorted(iterable, cmp=None, key=None, reverse=False):
+ if key is not None:
+ result = [(key(x), x) for x in iterable]
+ else:
+ result = iterable[:]
+ if cmp is None:
+ # Pre-2.3 Python does not support list.sort(None).
+ result.sort()
+ else:
+ result.sort(cmp)
+ if key is not None:
+ result = [t1 for t0,t1 in result]
+ if reverse:
+ result.reverse()
+ return result
+ __builtin__.sorted = sorted
+
def make_temp_file(**kw):
try:
result = tempfile.mktemp(**kw)
@@ -505,9 +531,7 @@ class SConsTimer:
"""
files = []
for a in args:
- g = glob.glob(a)
- g.sort()
- files.extend(g)
+ files.extend(sorted(glob.glob(a)))
if tail:
files = files[-tail:]
@@ -589,10 +613,7 @@ class SConsTimer:
"""
gp = Gnuplotter(self.title, self.key_location)
- indices = results.keys()
- indices.sort()
-
- for i in indices:
+ for i in sorted(results.keys()):
try:
t = self.run_titles[i]
except IndexError: