# HG changeset patch
# User greg
# Date 1495480962 14400
# Node ID ea2be77b575c8db46aaf47cf930e0b92d47c5cef
# Parent ae78488e9793ddf255a631de63e995b33ec03a4b
Uploaded
diff -r ae78488e9793 -r ea2be77b575c utils.py
--- a/utils.py Mon May 15 08:28:22 2017 -0400
+++ b/utils.py Mon May 22 15:22:42 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('Size | Name |
\n')
- for index, fname in enumerate(sorted(os.listdir(dir))):
+ fh.write('%s |
\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('%s | %s |
\n' % (bgcolor, size, link))
+ fh.write('%s |
\n' % (bgcolor, link))
fh.write('
\n')