# HG changeset patch # User greg # Date 1495551212 14400 # Node ID 1a2a918563d43cae5fa07aa01b5f4d32ecea779a # Parent 048fcfb76dfabe929d7e83e4e7f591b62034f0f8 Uploaded diff -r 048fcfb76dfa -r 1a2a918563d4 utils.py --- a/utils.py Mon May 22 15:20:58 2017 -0400 +++ b/utils.py Tue May 23 10:53:32 2017 -0400 @@ -57,15 +57,19 @@ 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' + header = '' fh.write('

%s: %d items

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

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