summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 +0000
committerGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 +0000
commiteb7e67b1e6e7315a945edf79ebd2ec160ee85588 (patch)
treefff879b4f9676a72e16c0f7b4dd969f050038b4f /bin
parentd5d9fceff1591065e13c1fcd283468fb0a288a36 (diff)
downloadscons-eb7e67b1e6e7315a945edf79ebd2ec160ee85588.tar.gz
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 'bin')
-rw-r--r--bin/Command.py6
-rw-r--r--bin/SConsDoc.py6
-rw-r--r--bin/import-test.py7
-rw-r--r--bin/objcounts.py12
-rw-r--r--bin/scons-diff.py4
-rw-r--r--bin/scons-doc.py7
-rw-r--r--bin/scons-test.py7
-rw-r--r--bin/scons-unzip.py2
-rw-r--r--bin/time-scons.py8
-rwxr-xr-xbin/xmlagenda.py3
10 files changed, 21 insertions, 41 deletions
diff --git a/bin/Command.py b/bin/Command.py
index efaa3569..28fb110a 100644
--- a/bin/Command.py
+++ b/bin/Command.py
@@ -44,7 +44,7 @@ class CommandRunner:
return string
def do_display(self, string):
- if type(string) == type(()):
+ if isinstance(string, tuple):
func = string[0]
args = string[1:]
s = '%s(%s)' % (func.__name__, ', '.join(map(repr, args)))
@@ -59,14 +59,14 @@ class CommandRunner:
pass
def do_execute(self, command):
- if type(command) == type(''):
+ if isinstance(command, str):
command = self.subst(command)
cmdargs = shlex.split(command)
if cmdargs[0] == 'cd':
command = (os.chdir,) + tuple(cmdargs[1:])
elif cmdargs[0] == 'mkdir':
command = (os.mkdir,) + tuple(cmdargs[1:])
- if type(command) == type(()):
+ if isinstance(command, tuple):
func = command[0]
args = command[1:]
return func(*args)
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py
index d164d11e..298e2521 100644
--- a/bin/SConsDoc.py
+++ b/bin/SConsDoc.py
@@ -354,15 +354,13 @@ class SConsDocHandler(xml.sax.handler.ContentHandler,
def start_uses(self, attrs):
self.begin_collecting([])
def end_uses(self):
- self.current_object.uses = ''.join(self.collect).split()
- self.current_object.uses.sort()
+ self.current_object.uses = sorted(''.join(self.collect).split())
self.end_collecting()
def start_sets(self, attrs):
self.begin_collecting([])
def end_sets(self):
- self.current_object.sets = ''.join(self.collect).split()
- self.current_object.sets.sort()
+ self.current_object.sets = sorted(''.join(self.collect).split())
self.end_collecting()
# Stuff for the ErrorHandler portion.
diff --git a/bin/import-test.py b/bin/import-test.py
index fe5ea2fd..69e6cc7d 100644
--- a/bin/import-test.py
+++ b/bin/import-test.py
@@ -40,11 +40,8 @@ class Dir:
self.path = path
self.entries = {}
def call_for_each_entry(self, func):
- entries = self.entries
- names = entries.keys()
- names.sort()
- for name in names:
- func(name, entries[name])
+ for name in sorted(self.entries.keys()):
+ func(name, self.entries[name])
def lookup(dirname):
global Top, TopPath
diff --git a/bin/objcounts.py b/bin/objcounts.py
index c1f2dd56..06620126 100644
--- a/bin/objcounts.py
+++ b/bin/objcounts.py
@@ -86,20 +86,14 @@ def printline(c1, c2, classname):
diffstr(c1[3], c2[3]) + \
' ' + classname
-keys = common.keys()
-keys.sort()
-for k in keys:
+for k in sorted(common.keys()):
c = common[k]
printline(c[0], c[1], k)
-keys = c1.keys()
-keys.sort()
-for k in keys:
+for k in sorted(list(c1.keys())):
printline(c1[k], ['--']*4, k)
-keys = c2.keys()
-keys.sort()
-for k in keys:
+for k in sorted(list(c2.keys())):
printline(['--']*4, c2[k], k)
# Local Variables:
diff --git a/bin/scons-diff.py b/bin/scons-diff.py
index d1e48cf5..52bd51b1 100644
--- a/bin/scons-diff.py
+++ b/bin/scons-diff.py
@@ -173,9 +173,7 @@ def diff_dir(left, right):
u[l] = 1
for r in rlist:
u[r] = 1
- clist = [ x for x in u.keys() if x[-4:] != '.pyc' ]
- clist.sort()
- for x in clist:
+ for x in sorted([ x for x in u.keys() if x[-4:] != '.pyc' ]):
if x in llist:
if x in rlist:
do_diff(os.path.join(left, x),
diff --git a/bin/scons-doc.py b/bin/scons-doc.py
index f140743e..03c66fa5 100644
--- a/bin/scons-doc.py
+++ b/bin/scons-doc.py
@@ -241,7 +241,7 @@ def Str(target, source, env, cmd=""):
class ToolSurrogate:
def __init__(self, tool, variable, func, varlist):
self.tool = tool
- if not type(variable) is type([]):
+ if not isinstance(variable, list):
variable = [variable]
self.variable = variable
self.func = func
@@ -477,10 +477,7 @@ def command_edit(args, c, test, dict):
def command_ls(args, c, test, dict):
def ls(a):
- files = os.listdir(a)
- files = [x for x in files if x[0] != '.']
- files.sort()
- return [' '.join(files)]
+ return [' '.join(sorted([x for x in os.listdir(a) if x[0] != '.']))]
if args:
l = []
for a in args:
diff --git a/bin/scons-test.py b/bin/scons-test.py
index 8d1950f1..0089e247 100644
--- a/bin/scons-test.py
+++ b/bin/scons-test.py
@@ -82,7 +82,7 @@ if outdir is None:
def outname(n, outdir=outdir):
l = []
- while 1:
+ while True:
n, tail = os.path.split(n)
if not n:
break
@@ -204,10 +204,7 @@ if format == '--xml':
]
print " <environment>"
- #keys = os.environ.keys()
- keys = environ_keys
- keys.sort()
- for key in keys:
+ for key in sorted(environ_keys):
value = os.environ.get(key)
if value:
print " <variable>"
diff --git a/bin/scons-unzip.py b/bin/scons-unzip.py
index c0eb8aa9..d4ec4bff 100644
--- a/bin/scons-unzip.py
+++ b/bin/scons-unzip.py
@@ -45,7 +45,7 @@ if outdir is None:
def outname(n, outdir=outdir):
l = []
- while 1:
+ while True:
n, tail = os.path.split(n)
if not n:
break
diff --git a/bin/time-scons.py b/bin/time-scons.py
index 78d26e54..c1c8e8e8 100644
--- a/bin/time-scons.py
+++ b/bin/time-scons.py
@@ -81,11 +81,11 @@ class CommandRunner:
def display(self, command, stdout=None, stderr=None):
if not self.verbose:
return
- if type(command) == type(()):
+ if isinstance(command, tuple):
func = command[0]
args = command[1:]
s = '%s(%s)' % (func.__name__, ', '.join(map(repr, args)))
- if type(command) == type([]):
+ if isinstance(command, list):
# TODO: quote arguments containing spaces
# TODO: handle meta characters?
s = ' '.join(command)
@@ -102,12 +102,12 @@ class CommandRunner:
"""
if not self.active:
return 0
- if type(command) == type(''):
+ if isinstance(command, str):
command = self.subst(command)
cmdargs = shlex.split(command)
if cmdargs[0] == 'cd':
command = (os.chdir,) + tuple(cmdargs[1:])
- if type(command) == type(()):
+ if isinstance(command, tuple):
func = command[0]
args = command[1:]
return func(*args)
diff --git a/bin/xmlagenda.py b/bin/xmlagenda.py
index 3009e4c6..fb62f9a2 100755
--- a/bin/xmlagenda.py
+++ b/bin/xmlagenda.py
@@ -17,8 +17,7 @@
# The team members
# FIXME: These names really should be external to this script
-team = 'Bill Greg Steven Gary Ken Brandon Sohail Jim David'.split()
-team.sort()
+team = sorted('Steven Gary Greg Ken Jim David Bill Sergey Jason'.split())
# The elements to be picked out of the issue
PickList = [