Mercurial > repos > greg > assembly_post_processor
changeset 60:f7a999b3b19c draft
Uploaded
author | greg |
---|---|
date | Mon, 22 May 2017 11:38:22 -0400 |
parents | 6995393bda9f |
children | 5fb9c4fc7c00 |
files | utils.py |
diffstat | 1 files changed, 7 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/utils.py Mon May 22 11:31:50 2017 -0400 +++ b/utils.py Mon May 22 11:38:22 2017 -0400 @@ -54,22 +54,17 @@ sys.exit(msg) -def write_dir_contents_as_html(fh, dir): - for index, dir_entry in enumerate(sorted(os.listdir(dir))): - if index % 2 == 0: - bgcolor = '#D8D8D8' - else: - bgcolor = '#FFFFFF' - link = '<a href="%s" type="text/plain">%s</a>\n' % (dir_entry, dir_entry) - fh.write('<tr bgcolor="%s"><td>%s</td></tr>\n' % (bgcolor, link)) - - - 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. + if os.path.isdir(dir_items[0]): + header = 'Directories' + else: + header = 'Datasets' fh.write('<html><head><h3>%s: %d items</h3></head>\n' % (title, len(os.listdir(dir)))) fh.write('<body><p/><table cellpadding="2">\n') - fh.write('<tr><th>Size</th><th>Name</th></tr>\n') + fh.write('<tr><th>%s</th></tr>\n' % header) for index, fname in enumerate(sorted(os.listdir(dir))): if index % 2 == 0: bgcolor = '#D8D8D8'