view html_export.py @ 1:da900b5a0bda

Add input, test, citations parameters and test-data
author Vimalkumar Velayudhan <vimal@biotechcoder.com>
date Fri, 03 Jul 2015 12:24:49 +0100
parents 6423c038695d
children
line wrap: on
line source

# -*- coding: utf-8 -*-
import os
import argparse

parser = argparse.ArgumentParser(
    description='Create a HTML output file with link to a sample text file')
parser.add_argument('--html_file', default='html_export.html')
parser.add_argument('--output_path', default=os.getcwd())
args = parser.parse_args()

html = """\
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>HTML export</title>
 </head>
<body>
<h3>HTML output file with link to sample text file</h3>
<p>Download: {content}</p>
</body>
</html>

"""

# create output directory
os.mkdir(args.output_path)

# create the text file with content
with open(os.path.join(args.output_path, 'paths.txt'), 'w') as f:
    paths = os.environ['PATH'].split(':')
    f.write('\n'.join(paths))

# write html file
with open(args.html_file, 'w') as g:
    g.write(html.format(content='<a href="paths.txt">paths.txt</a>'))