Mercurial > repos > greg > gene_family_phylogeny_builder
comparison utils.py @ 55:8013d394c525 draft
Uploaded
author | greg |
---|---|
date | Mon, 30 Oct 2017 09:05:37 -0400 |
parents | 9962341547d3 |
children |
comparison
equal
deleted
inserted
replaced
54:eef0f4704dca | 55:8013d394c525 |
---|---|
52 check_execution_errors(rc, fstderr, fstdout) | 52 check_execution_errors(rc, fstderr, fstdout) |
53 | 53 |
54 | 54 |
55 def stop_err(msg): | 55 def stop_err(msg): |
56 sys.exit(msg) | 56 sys.exit(msg) |
57 | |
58 | |
59 def write_html_output(output, title, dir): | |
60 with open(output, 'w') as fh: | |
61 dir_items = sorted(os.listdir(dir)) | |
62 # Directories can only contain either files or directories, | |
63 # but not both. | |
64 if len(dir_items) > 0: | |
65 item_path = os.path.join(dir, dir_items[0]) | |
66 if os.path.isdir(item_path): | |
67 header = 'Directories' | |
68 else: | |
69 header = 'Datasets' | |
70 else: | |
71 header = '' | |
72 fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(dir_items))) | |
73 fh.write('<body><p/><table cellpadding="2">\n') | |
74 fh.write('<tr><b>%s</th></b>\n' % header) | |
75 for index, fname in enumerate(dir_items): | |
76 if index % 2 == 0: | |
77 bgcolor = '#D8D8D8' | |
78 else: | |
79 bgcolor = '#FFFFFF' | |
80 link = '<a href="%s" type="text/plain">%s</a>\n' % (fname, fname) | |
81 fh.write('<tr bgcolor="%s"><td>%s</td></tr>\n' % (bgcolor, link)) | |
82 fh.write('</table></body></html>\n') |