Mercurial > repos > dvanzessen > bcbio_nextgen_emc
comparison make_html.py @ 0:2ed60a09d6b6 draft
Uploaded
author | dvanzessen |
---|---|
date | Mon, 15 Jul 2019 05:11:46 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2ed60a09d6b6 |
---|---|
1 import os | |
2 import argparse | |
3 from jinja2 import Template | |
4 | |
5 | |
6 def main(): | |
7 # --workdir `pwd` --output-dir `pwd`/output --input | |
8 parser = argparse.ArgumentParser() | |
9 | |
10 parser.add_argument("--input-dir", "-d", required=True) | |
11 parser.add_argument("--root-html", "-o", required=True) | |
12 | |
13 args = parser.parse_args() | |
14 | |
15 input_dir = args.input_dir | |
16 root_html = args.root_html | |
17 | |
18 with open(root_html, 'w') as root_html_handle: | |
19 root_html_handle.write("<ol>") | |
20 for root, dirs, files in os.walk(input_dir, followlinks=True): | |
21 print(root, dirs, files) | |
22 relative_root = root.replace(input_dir, "")[:-1] | |
23 print(relative_root) | |
24 for f in files: | |
25 f = "{0}/{1}".format(relative_root, f) | |
26 if f.startswith("/"): | |
27 f = f[1:] | |
28 root_html_handle.write("<li>{0}</li>".format( | |
29 f | |
30 )) | |
31 | |
32 if __name__ == "__main__": | |
33 main() |