summaryrefslogtreecommitdiffstats
path: root/QMTest
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2010-04-18 14:03:36 (GMT)
committerSteven Knight <knight@baldmt.com>2010-04-18 14:03:36 (GMT)
commitae1e7c742dcd1ed0b521640455794172fe275c65 (patch)
tree15f668e70035c926caa062d91f2fd806b7b65528 /QMTest
parente254cdf344ed0a466661b319dc019f2400ad12f3 (diff)
downloadSCons-ae1e7c742dcd1ed0b521640455794172fe275c65.zip
SCons-ae1e7c742dcd1ed0b521640455794172fe275c65.tar.gz
SCons-ae1e7c742dcd1ed0b521640455794172fe275c65.tar.bz2
Replace remaining os.path.walk() calls with os.walk().
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/TestCmd.py73
-rw-r--r--QMTest/TestSCons.py9
2 files changed, 34 insertions, 48 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index 1dff4a6..ab1c212 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -221,7 +221,6 @@ __version__ = "0.37"
import errno
import os
-import os.path
import re
import shutil
import stat
@@ -317,13 +316,6 @@ except ImportError:
else:
atexit.register(_clean)
-class Collector:
- def __init__(self, top):
- self.entries = [top]
- def __call__(self, arg, dirname, names):
- pathjoin = lambda n: os.path.join(dirname, n)
- self.entries.extend(list(map(pathjoin, names)))
-
def _caller(tblist, skip):
string = ""
arr = []
@@ -1461,29 +1453,21 @@ class TestCmd(object):
# It's a directory and we're trying to turn on read
# permission, so it's also pretty easy, just chmod the
# directory and then chmod every entry on our walk down the
- # tree. Because os.path.walk() is top-down, we'll enable
- # read permission on any directories that have it disabled
- # before os.path.walk() tries to list their contents.
- do_chmod(top)
-
- def chmod_entries(arg, dirname, names, do_chmod=do_chmod):
- for n in names:
- do_chmod(os.path.join(dirname, n))
-
- os.path.walk(top, chmod_entries, None)
+ # tree.
+ for dirpath, dirnames, filenames in os.walk(top):
+ do_chmod(dirpath)
+ for fn in filenames:
+ do_chmod(os.path.join(dirpath, fn))
else:
# It's a directory and we're trying to turn off read
- # permission, which means we have to chmod the directoreis
+ # permission, which means we have to chmod the directories
# in the tree bottom-up, lest disabling read permission from
# the top down get in the way of being able to get at lower
- # parts of the tree. But os.path.walk() visits things top
- # down, so we just use an object to collect a list of all
- # of the entries in the tree, reverse the list, and then
- # chmod the reversed (bottom-up) list.
- col = Collector(top)
- os.path.walk(top, col, None)
- col.entries.reverse()
- for d in col.entries: do_chmod(d)
+ # parts of the tree.
+ for dirpath, dirnames, filenames in os.walk(top, topdown=0):
+ for fn in filenames:
+ do_chmod(os.path.join(dirpath, fn))
+ do_chmod(dirpath)
def writable(self, top, write=1):
"""Make the specified directory tree writable (write == 1)
@@ -1517,9 +1501,10 @@ class TestCmd(object):
if os.path.isfile(top):
do_chmod(top)
else:
- col = Collector(top)
- os.path.walk(top, col, None)
- for d in col.entries: do_chmod(d)
+ for dirpath, dirnames, filenames in os.walk(top, topdown=0):
+ for fn in filenames:
+ do_chmod(os.path.join(dirpath, fn))
+ do_chmod(dirpath)
def executable(self, top, execute=1):
"""Make the specified directory tree executable (execute == 1)
@@ -1550,29 +1535,21 @@ class TestCmd(object):
# It's a directory and we're trying to turn on execute
# permission, so it's also pretty easy, just chmod the
# directory and then chmod every entry on our walk down the
- # tree. Because os.path.walk() is top-down, we'll enable
- # execute permission on any directories that have it disabled
- # before os.path.walk() tries to list their contents.
- do_chmod(top)
-
- def chmod_entries(arg, dirname, names, do_chmod=do_chmod):
- for n in names:
- do_chmod(os.path.join(dirname, n))
-
- os.path.walk(top, chmod_entries, None)
+ # tree.
+ for dirpath, dirnames, filenames in os.walk(top):
+ do_chmod(dirpath)
+ for fn in filenames:
+ do_chmod(os.path.join(dirpath, fn))
else:
# It's a directory and we're trying to turn off execute
# permission, which means we have to chmod the directories
# in the tree bottom-up, lest disabling execute permission from
# the top down get in the way of being able to get at lower
- # parts of the tree. But os.path.walk() visits things top
- # down, so we just use an object to collect a list of all
- # of the entries in the tree, reverse the list, and then
- # chmod the reversed (bottom-up) list.
- col = Collector(top)
- os.path.walk(top, col, None)
- col.entries.reverse()
- for d in col.entries: do_chmod(d)
+ # parts of the tree.
+ for dirpath, dirnames, filenames in os.walk(top, topdown=0):
+ for fn in filenames:
+ do_chmod(os.path.join(dirpath, fn))
+ do_chmod(dirpath)
def write(self, file, content, mode = 'wb'):
"""Writes the specified content text (second argument) to the
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index 561dcda..307c118 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -650,6 +650,15 @@ class TestSCons(TestCommon):
self.skip_test("Could not find Java rmic, skipping non-simulated test(s).\n")
return where_rmic
+ def java_get_class_files(self, dir):
+ result = []
+ for dirpath, dirnames, filenames in os.walk(dir):
+ for fname in filenames:
+ if fname.endswith('.class'):
+ result.append(os.path.join(dirpath, fname))
+ return sorted(result)
+
+
def Qt_dummy_installation(self, dir='qt'):
# create a dummy qt installation