# HG changeset patch # User greg # Date 1495480839 14400 # Node ID 93a69f4573a600dfe386caa052036b714135a791 # Parent 238b555c57b5dc0f0cad918eb72c648bf9a90a71 Uploaded diff -r 238b555c57b5 -r 93a69f4573a6 utils.py --- a/utils.py Mon May 15 08:26:43 2017 -0400 +++ b/utils.py Mon May 22 15:20:39 2017 -0400 @@ -56,18 +56,21 @@ def write_html_output(output, title, dir): with open(output, 'w') as fh: - fh.write('

%s: %d files

\n' % (title, len(os.listdir(dir)))) + 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' + else: + header = 'Datasets' + fh.write('

%s: %d items

\n' % (title, len(dir_items))) fh.write('

\n') - fh.write('\n') - for index, fname in enumerate(sorted(os.listdir(dir))): + fh.write('\n' % header) + for index, fname in enumerate(dir_items): if index % 2 == 0: bgcolor = '#D8D8D8' else: bgcolor = '#FFFFFF' - try: - size = str(os.path.getsize(os.path.join(dir, fname))) - except: - size = 'unknown' link = '%s\n' % (fname, fname) - fh.write('\n' % (bgcolor, size, link)) + fh.write('\n' % (bgcolor, link)) fh.write('
SizeName
%s
%s%s
%s
\n')