Created
July 17, 2020 15:06
-
-
Save thiagodasilva/56a8ca956f1f76e819d90433eac9608a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import sys | |
import os | |
from optparse import OptionParser | |
def main(): | |
parser = OptionParser('%prog') | |
parser.add_option('-n', type="int", dest="num_files", default=1, | |
help="number of files to write") | |
parser.add_option('-s', type="int", dest="size", default=10, | |
help="size of files to write") | |
parser.add_option('-d', type="str", dest="dest_dir", default='rand_data', | |
help="directory path to write files") | |
parser.add_option('-p', type="str", dest="prefix", default='Object_', | |
help="file name prefix") | |
parser.add_option('-i', type="int", dest="start_idx", default=1, | |
help="Starting index") | |
options, args = parser.parse_args() | |
num_files = options.num_files | |
prefix = options.prefix | |
dest_dir = options.dest_dir | |
size = options.size | |
start_idx = options.start_idx | |
os.makedirs(dest_dir, exist_ok=True) | |
for i in range(start_idx, start_idx+num_files): | |
filename = prefix + str(i) | |
filepath = os.path.join(dest_dir, filename) | |
with open(filepath, 'wb') as f: | |
f.write(os.urandom(size)) | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment