Created
October 20, 2017 15:26
-
-
Save Jimexist/26c66a54c457a85cba4732ca78b257c4 to your computer and use it in GitHub Desktop.
vgg download
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 python3 | |
import os | |
def gen_dir(root, d): | |
path = os.path.join(root, d) | |
print('processing', path) | |
os.makedirs(path, exist_ok=True) | |
makefile_path = os.path.join(path, 'Makefile') | |
file_ids = [] | |
urls = [] | |
with open(path+'.txt', 'r') as fin: | |
for line in fin.readlines(): | |
tokens = line.split(' ') | |
file_id, url = tokens[:2] | |
file_ids.append('_'.join([d, file_id])) | |
urls.append(url) | |
with open(makefile_path, 'w') as fout: | |
print('generating', makefile_path) | |
fout.write('all: ' + ' '.join(file_ids) + '\n\n') | |
for file_id, url in zip(file_ids, urls): | |
fout.write('{}:\n'.format(file_id)) | |
fout.write('\t-wget -nc --timeout=120 --quiet -O {} {}\n\n'.format(file_id, url)) | |
def main(): | |
for root, dirs, files in os.walk('./files'): | |
for f in files: | |
if f.endswith('.txt'): | |
gen_dir(root, f[:-4]) | |
if __name__ == '__main__': | |
main() |
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
SUBDIRS := $(wildcard files/*) | |
all: $(SUBDIRS) | |
$(SUBDIRS): | |
$(MAKE) -C $@ | |
.PHONY: all $(SUBDIRS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment