5 req: local directory full_lists/
7 make_inp_lists.py [num files total] [num files per list]
9 new_dir: new directory named 'in_lists_[num files total]_by_[num files per list]'
10 input files lists: [new_dir]/dst_*_[num files per list]_[0,1,...]
11 new queue file: [queue_[num file total]_by_[num files per list].list]
23 lines_per_output = argv[1]
29 n_files = int(argv[2])
33 inp_dir =
'full_lists'
41 print (f
"inp_dir: {inp_dir}")
42 if not inp_dir ==
"full_lists":
43 print (f
"odir_tag: {odir_tag} 0")
44 if "_lists" in inp_dir:
45 odir_tag = inp_dir[:inp_dir.find(
"_lists")]
46 print (f
"odir_tag: {odir_tag} 1")
49 print (f
"odir_tag: {odir_tag} 2")
53 odir = f
'{odir_tag}_{lines_per_output}x{n_files}'
55 odir = f
'{odir_tag}_{lines_per_output}xAll'
57 print (f
"odir: {odir}")
60 print(f
'replacing contents of {odir}');
61 for f
in glob(f
'{odir}/*'):
66 queue =
open(f
'{odir}/queue.list',
'w')
72 if (len(glob(f
'{inp_dir}/dst_*.list')) == 0):
73 print(f
"fatal error: no lists in {inp_dir}")
76 for file
in glob(f
'{inp_dir}/dst_*.list'):
77 in_files .append(
open(file,
'r'))
78 in_tags .append(file.split('/')[-1][:-5])
83 if n_files != -1
and n_file == n_files:
89 name = f
'{tag}_{n_file}.list'
91 queue.write(f
'{name}')
94 queue.write(f
', {name}')
95 o_files.append(
open(f
'{odir}/{name}',
'w'))
97 for n
in range (int(lines_per_output)):
98 for i_file, o_file
in zip(in_files, o_files):
99 line = i_file.readline()
107 except StopIteration:
110 with
open(f
'{odir}/last_list_is_{n_file}',
'w')
as fout:
111 fout.write(f
'There are {n_file+2} lists')
118 if __name__ ==
'__main__':