-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_index_file.py
executable file
·36 lines (29 loc) · 1.6 KB
/
create_index_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
import argparse
import os
def main():
parser = argparse.ArgumentParser(description="Create overall index file that mirrors the Alliance reports S3 "
"bucket")
parser.add_argument("-i", "--input-dir", metavar="input_dir", dest="input_dir", type=str,
default="./", help="working directory where input files are located")
args = parser.parse_args()
print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
print("<ListBucketResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">")
print("\t<Name>wb-db-reports</Name>")
print("\t<Prefix></Prefix>")
print("\t<Marker></Marker>")
print("\t<MaxKeys>1000</MaxKeys>")
print("\t<IsTruncated>false</IsTruncated>")
for release_version in os.listdir(args.input_dir):
for release_type in os.listdir(os.path.join(args.input_dir, release_version)):
for release_date in os.listdir(os.path.join(args.input_dir, release_version, release_type)):
for json_file_path in os.listdir(os.path.join(args.input_dir, release_version, release_type,
release_date)):
if json_file_path.endswith(".json"):
print("\t<Contents>")
print("\t\t<Key>gene-descriptions/" + release_version + "/" + release_type + "/" +
release_date + "/" + json_file_path + "</Key>")
print("\t</Contents>")
print("</ListBucketResult>")
if __name__ == '__main__':
main()