Mercurial > repos > iuc > macs2
comparison dir2html.py @ 4:56e104999978 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/macs2 commit 9df9b52baf62b70fbcfc3fbe965d7197d4e8738e
author | iuc |
---|---|
date | Mon, 06 Feb 2017 02:30:37 -0500 |
parents | fe62ba547975 |
children |
comparison
equal
deleted
inserted
replaced
3:6d4babad010f | 4:56e104999978 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | |
3 from __future__ import print_function | |
4 | |
2 import os | 5 import os |
3 import sys | 6 import sys |
4 from xml.sax.saxutils import escape | 7 from xml.sax.saxutils import escape |
5 | 8 |
6 def make_table( directory ): | 9 |
10 def make_table(directory): | |
7 ret = ['<table class="fileList">\n'] | 11 ret = ['<table class="fileList">\n'] |
8 for file in os.listdir( directory ): | 12 for filename in os.listdir(directory): |
9 ret.append('<tr><td class="file"><a href="%s">%s</a></td></tr>\n' % ( file, escape(file).replace( 'MACS2_', '' ) )) | 13 ret.append('<tr><td class="file"><a href="%s">%s</a></td></tr>\n' % (filename, escape(filename).replace('MACS2_', ''))) |
10 ret.append('</table>') | 14 ret.append('</table>') |
11 return ''.join(ret) | 15 return ''.join(ret) |
12 | 16 |
13 def make_html( directory, stderr ): | 17 |
18 def make_html(directory, stderr): | |
14 return '\n'.join(['<html>' | 19 return '\n'.join(['<html>' |
15 '<head>', | 20 '<head>', |
16 ' <title>Additional output created by MACS2</title>', | 21 ' <title>Additional output created by MACS2</title>', |
17 ' <style type="text/css">', | 22 ' <style type="text/css">', |
18 ' table.fileList { text-align: left; }', | 23 ' table.fileList { text-align: left; }', |
20 ' td.file { padding-left: 4em; }', | 25 ' td.file { padding-left: 4em; }', |
21 ' </style>', | 26 ' </style>', |
22 '</head>', | 27 '</head>', |
23 '<body>', | 28 '<body>', |
24 '<h1>Additional Files:</h1>', | 29 '<h1>Additional Files:</h1>', |
25 make_table( directory ), | 30 make_table(directory), |
26 '<h3>Messages from MACS2:</h3>', | 31 '<h3>Messages from MACS2:</h3>', |
27 stderr.read().replace('\n', '<br>'), | 32 stderr.read().replace('\n', '<br>'), |
28 '</body>', | 33 '</body>', |
29 '</html>']) | 34 '</html>']) |
30 | 35 |
36 | |
31 if __name__ == '__main__': | 37 if __name__ == '__main__': |
32 if len(sys.argv) == 3: | 38 if len(sys.argv) == 3: |
33 directory_path = sys.argv[1] | 39 directory_path = sys.argv[1] |
34 stderr = open( sys.argv[2] ) | 40 stderr = open(sys.argv[2]) |
35 print make_html( directory_path, stderr ) | 41 print(make_html(directory_path, stderr)) |
36 else: | 42 else: |
37 sys.exit( 'Two parameter expected: directory path and stderr path' ) | 43 sys.exit('Two parameter expected: directory path and stderr path') |
38 |