mirror of
https://github.com/python/cpython.git
synced 2025-09-18 06:30:38 +00:00
Replace instances of os.path.walk with os.walk
This commit is contained in:
parent
e3b1940eb9
commit
9ec4aa01f9
2 changed files with 9 additions and 13 deletions
|
@ -95,18 +95,16 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue