Mercurial > repos > greg > assembly_post_processor
comparison utils.py @ 60:f7a999b3b19c draft
Uploaded
author | greg |
---|---|
date | Mon, 22 May 2017 11:38:22 -0400 |
parents | 6995393bda9f |
children | dff964aa0dd5 |
comparison
equal
deleted
inserted
replaced
59:6995393bda9f | 60:f7a999b3b19c |
---|---|
52 | 52 |
53 def stop_err(msg): | 53 def stop_err(msg): |
54 sys.exit(msg) | 54 sys.exit(msg) |
55 | 55 |
56 | 56 |
57 def write_dir_contents_as_html(fh, dir): | |
58 for index, dir_entry in enumerate(sorted(os.listdir(dir))): | |
59 if index % 2 == 0: | |
60 bgcolor = '#D8D8D8' | |
61 else: | |
62 bgcolor = '#FFFFFF' | |
63 link = '<a href="%s" type="text/plain">%s</a>\n' % (dir_entry, dir_entry) | |
64 fh.write('<tr bgcolor="%s"><td>%s</td></tr>\n' % (bgcolor, link)) | |
65 | |
66 | |
67 | |
68 def write_html_output(output, title, dir): | 57 def write_html_output(output, title, dir): |
69 with open(output, 'w') as fh: | 58 with open(output, 'w') as fh: |
59 dir_items = sorted(os.listdir(dir)) | |
60 # Directories can only contain either files or directories, but not both. | |
61 if os.path.isdir(dir_items[0]): | |
62 header = 'Directories' | |
63 else: | |
64 header = 'Datasets' | |
70 fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(os.listdir(dir)))) | 65 fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(os.listdir(dir)))) |
71 fh.write('<body><p/><table cellpadding="2">\n') | 66 fh.write('<body><p/><table cellpadding="2">\n') |
72 fh.write('<tr><th>Size</th><th>Name</th></tr>\n') | 67 fh.write('<tr><th>%s</th></tr>\n' % header) |
73 for index, fname in enumerate(sorted(os.listdir(dir))): | 68 for index, fname in enumerate(sorted(os.listdir(dir))): |
74 if index % 2 == 0: | 69 if index % 2 == 0: |
75 bgcolor = '#D8D8D8' | 70 bgcolor = '#D8D8D8' |
76 else: | 71 else: |
77 bgcolor = '#FFFFFF' | 72 bgcolor = '#FFFFFF' |