[Python-checkins] r62904 - in python/trunk/Lib: distutils/archive_util.py test/test_repr.py
benjamin.peterson
python-checkins at python.org
Fri May 9 00:09:55 CEST 2008
Author: benjamin.peterson
Date: Fri May 9 00:09:54 2008
New Revision: 62904
Log:
Replace instances of os.path.walk with os.walk
Modified:
python/trunk/Lib/distutils/archive_util.py
python/trunk/Lib/test/test_repr.py
Modified: python/trunk/Lib/distutils/archive_util.py
==============================================================================
--- python/trunk/Lib/distutils/archive_util.py (original)
+++ python/trunk/Lib/distutils/archive_util.py Fri May 9 00:09:54 2008
@@ -95,18 +95,16 @@
log.info("creating '%s' and adding '%s' to it",
zip_filename, base_dir)
- def visit (z, dirname, names):
- for name in names:
- path = os.path.normpath(os.path.join(dirname, name))
- if os.path.isfile(path):
- z.write(path, path)
- log.info("adding '%s'" % path)
-
if not dry_run:
z = zipfile.ZipFile(zip_filename, "w",
compression=zipfile.ZIP_DEFLATED)
- os.path.walk(base_dir, visit, z)
+ for dirpath, dirnames, filenames in os.walk(base_dir):
+ for name in filenames:
+ path = os.path.normpath(os.path.join(dirpath, name))
+ if os.path.isfile(path):
+ z.write(path, path)
+ log.info("adding '%s'" % path)
z.close()
return zip_filename
Modified: python/trunk/Lib/test/test_repr.py
==============================================================================
--- python/trunk/Lib/test/test_repr.py (original)
+++ python/trunk/Lib/test/test_repr.py Fri May 9 00:09:54 2008
@@ -211,10 +211,6 @@
fp.write(text)
fp.close()
-def zap(actions, dirname, names):
- for name in names:
- actions.append(os.path.join(dirname, name))
-
class LongReprTest(unittest.TestCase):
def setUp(self):
longname = 'areallylongpackageandmodulenametotestreprtruncation'
@@ -233,7 +229,9 @@
def tearDown(self):
actions = []
- os.path.walk(self.pkgname, zap, actions)
+ for dirpath, dirnames, filenames in os.walk(self.pkgname):
+ for name in dirnames + filenames:
+ actions.append(os.path.join(dirpath, name))
actions.append(self.pkgname)
actions.sort()
actions.reverse()
More information about the Python-checkins
mailing list