Mercurial > repos > greg > assembly_post_processor
changeset 64:45aa928ed5df draft
Uploaded
author | greg |
---|---|
date | Tue, 23 May 2017 10:52:39 -0400 |
parents | dff964aa0dd5 |
children | baf10f7f3d4a |
files | utils.py |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/utils.py Mon May 22 11:57:35 2017 -0400 +++ b/utils.py Tue May 23 10:52:39 2017 -0400 @@ -57,16 +57,20 @@ def write_html_output(output, title, dir): with open(output, 'w') as fh: dir_items = sorted(os.listdir(dir)) - # Directories can only contain either files or directories, but not both. - item_path = os.path.join(dir, dir_items[0]) - if os.path.isdir(item_path): - header = 'Directories' + # Directories can only contain either files or directories, + # but not both. + if len(dir_items) > 0: + item_path = os.path.join(dir, dir_items[0]) + if os.path.isdir(item_path): + header = 'Directories' + else: + header = 'Datasets' else: - header = 'Datasets' - fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(os.listdir(dir)))) + header = '' + fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(dir_items))) fh.write('<body><p/><table cellpadding="2">\n') - fh.write('<tr><th>%s</th></tr>\n' % header) - for index, fname in enumerate(sorted(os.listdir(dir))): + fh.write('<tr><b>%s</th></b>\n' % header) + for index, fname in enumerate(dir_items): if index % 2 == 0: bgcolor = '#D8D8D8' else: