-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace static zip fixtures with dynamically generated zip fixtures b…
…uilt from the same modules as found on the file system.
- Loading branch information
Showing
9 changed files
with
66 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Generate zip test data files. | ||
""" | ||
|
||
import contextlib | ||
import os | ||
import pathlib | ||
import zipfile | ||
|
||
|
||
def make_zip_file(src, dst): | ||
""" | ||
Zip the files in src into a new zipfile at dst. | ||
""" | ||
with zipfile.ZipFile(dst, 'w') as zf: | ||
for src_path, rel in walk(src): | ||
dst_name = src.name / pathlib.PurePosixPath(rel.as_posix()) | ||
zf.write(src_path, dst_name) | ||
return dst | ||
|
||
|
||
def walk(datapath): | ||
for dirpath, dirnames, filenames in os.walk(datapath): | ||
with contextlib.suppress(ValueError): | ||
dirnames.remove('__pycache__') | ||
for filename in filenames: | ||
res = pathlib.Path(dirpath) / filename | ||
rel = res.relative_to(datapath) | ||
yield res, rel |
Empty file.
Binary file not shown.
Empty file.
Binary file not shown.