summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
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 efaa356..28fb110 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 d164d11..298e252 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 fe5ea2f..69e6cc7 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 c1f2dd5..0662012 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 d1e48cf..52bd51b 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 f140743..03c66fa 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 8d1950f..0089e24 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 c0eb8aa..d4ec4bf 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 78d26e5..c1c8e8e 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 3009e4c..fb62f9a 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 = [