Merge pull request #4240 from RonnyPfannschmidt/perf-example-collect-files

add script to generate a example folder for collecting many files
This commit is contained in:
Bruno Oliveira 2018-10-26 19:19:02 -03:00 committed by GitHub
commit ebba3ebe67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1 @@
foo_*

View File

@ -0,0 +1,28 @@
import argparse
import pathlib
HERE = pathlib.Path(__file__).parent
TEST_CONTENT = (HERE / "template_test.py").read_bytes()
parser = argparse.ArgumentParser()
parser.add_argument("numbers", nargs="*", type=int)
def generate_folders(root, elements, *more_numbers):
fill_len = len(str(elements))
if more_numbers:
for i in range(elements):
new_folder = root.joinpath(f"foo_{i:0>{fill_len}}")
new_folder.mkdir()
new_folder.joinpath("__init__.py").write_bytes(TEST_CONTENT)
generate_folders(new_folder, *more_numbers)
else:
for i in range(elements):
new_test = root.joinpath(f"test_{i:0<{fill_len}}.py")
new_test.write_bytes(TEST_CONTENT)
if __name__ == "__main__":
args = parser.parse_args()
generate_folders(HERE, *(args.numbers or (10, 100)))

View File

@ -0,0 +1,2 @@
def test_x():
pass