# HG changeset patch # User greg # Date 1495467502 14400 # Node ID f7a999b3b19c8bce692c9d08927ee0d5abf78309 # Parent 6995393bda9f8a6afcb55622714ac54ced82117b Uploaded diff -r 6995393bda9f -r f7a999b3b19c utils.py --- 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 = '%s\n' % (dir_entry, dir_entry) - fh.write('%s\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('

%s: %d items

\n' % (title, len(os.listdir(dir)))) fh.write('

\n') - fh.write('\n') + fh.write('\n' % header) for index, fname in enumerate(sorted(os.listdir(dir))): if index % 2 == 0: bgcolor = '#D8D8D8'
SizeName
%s