comparison html_export.py @ 0:6423c038695d

First commit
author Vimalkumar Velayudhan <vimal@biotechcoder.com>
date Fri, 03 Jul 2015 11:59:29 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:6423c038695d
1 # -*- coding: utf-8 -*-
2 import os
3 import argparse
4
5 parser = argparse.ArgumentParser(
6 description='Create a HTML output file with link to a sample text file')
7 parser.add_argument('--html_file', default='html_export.html')
8 parser.add_argument('--output_path', default=os.getcwd())
9 args = parser.parse_args()
10
11 html = """\
12 <!DOCTYPE html>
13 <html lang="en">
14 <head>
15 <meta charset="utf-8">
16 <title>HTML export</title>
17 </head>
18 <body>
19 <h3>HTML output file with link to sample text file</h3>
20 <p>Download: {content}</p>
21 </body>
22 </html>
23
24 """
25
26 # create output directory
27 os.mkdir(args.output_path)
28
29 # create the text file with content
30 with open(os.path.join(args.output_path, 'paths.txt'), 'w') as f:
31 paths = os.environ['PATH'].split(':')
32 f.write('\n'.join(paths))
33
34 # write html file
35 with open(args.html_file, 'w') as g:
36 g.write(html.format(content='<a href="paths.txt">paths.txt</a>'))