Mercurial > repos > greg > assembly_post_processor
changeset 59:6995393bda9f draft
Uploaded
author | greg |
---|---|
date | Mon, 22 May 2017 11:31:50 -0400 |
parents | e7f264e21d9a |
children | f7a999b3b19c |
files | utils.py |
diffstat | 1 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/utils.py Mon May 22 10:37:52 2017 -0400 +++ b/utils.py Mon May 22 11:31:50 2017 -0400 @@ -54,9 +54,20 @@ 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: - fh.write('<html><head><h3>%s: %d files</h3></head>\n' % (title, len(os.listdir(dir)))) + 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') for index, fname in enumerate(sorted(os.listdir(dir))): @@ -64,10 +75,6 @@ bgcolor = '#D8D8D8' else: bgcolor = '#FFFFFF' - try: - size = str(os.path.getsize(os.path.join(dir, fname))) - except: - size = 'unknown' link = '<a href="%s" type="text/plain">%s</a>\n' % (fname, fname) - fh.write('<tr bgcolor="%s"><td>%s</td><td>%s</td></tr>\n' % (bgcolor, size, link)) + fh.write('<tr bgcolor="%s"><td>%s</td></tr>\n' % (bgcolor, link)) fh.write('</table></body></html>\n')