Mercurial > repos > greg > gene_family_classifier
comparison utils.py @ 148:1a2a918563d4 draft
Uploaded
| author | greg |
|---|---|
| date | Tue, 23 May 2017 10:53:32 -0400 |
| parents | 93a69f4573a6 |
| children | 36ed0037292a |
comparison
equal
deleted
inserted
replaced
| 147:048fcfb76dfa | 148:1a2a918563d4 |
|---|---|
| 55 | 55 |
| 56 | 56 |
| 57 def write_html_output(output, title, dir): | 57 def write_html_output(output, title, dir): |
| 58 with open(output, 'w') as fh: | 58 with open(output, 'w') as fh: |
| 59 dir_items = sorted(os.listdir(dir)) | 59 dir_items = sorted(os.listdir(dir)) |
| 60 # Directories can only contain either files or directories, but not both. | 60 # Directories can only contain either files or directories, |
| 61 item_path = os.path.join(dir, dir_items[0]) | 61 # but not both. |
| 62 if os.path.isdir(item_path): | 62 if len(dir_items) > 0: |
| 63 header = 'Directories' | 63 item_path = os.path.join(dir, dir_items[0]) |
| 64 if os.path.isdir(item_path): | |
| 65 header = 'Directories' | |
| 66 else: | |
| 67 header = 'Datasets' | |
| 64 else: | 68 else: |
| 65 header = 'Datasets' | 69 header = '' |
| 66 fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(dir_items))) | 70 fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(dir_items))) |
| 67 fh.write('<body><p/><table cellpadding="2">\n') | 71 fh.write('<body><p/><table cellpadding="2">\n') |
| 68 fh.write('<tr><th>%s</th></tr>\n' % header) | 72 fh.write('<tr><b>%s</th></b>\n' % header) |
| 69 for index, fname in enumerate(dir_items): | 73 for index, fname in enumerate(dir_items): |
| 70 if index % 2 == 0: | 74 if index % 2 == 0: |
| 71 bgcolor = '#D8D8D8' | 75 bgcolor = '#D8D8D8' |
| 72 else: | 76 else: |
| 73 bgcolor = '#FFFFFF' | 77 bgcolor = '#FFFFFF' |
