view python/s5ify.py @ 783:d564f7ad8294

this now works again, and without docker-machine; ephermal testing for now, ephemeral testing forever
author Jeff Hammel <k0scist@gmail.com>
date Wed, 24 Aug 2016 14:39:51 -0700
parents e047129c84bc
children
line wrap: on
line source

#!/usr/bin/env python

"""
my front end to rst2st.py
"""

# imports
import argparse
import os
import subprocess
import sys

def normalize_filename(filename):
    return None  # TODO

def main(args=sys.argv[1:]):
    """CLI"""

    # parse command line
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('input')
    options = parser.parse_args(args)

    # sanity
    input = options.input
    if not os.path.isfile(input):
        parser.error("Not a file: '{}'".format(input))
    input = os.path.abspath(options.input)

    # get output name from input
    output_filename = os.path.splitext(os.path.basename(input))[0] + '.html'
    output = os.path.join(os.path.dirname(input), output_filename)

    # build command line
    options = []
    command = ['rst2s5.py']
    command.extend(options)
    command.extend([input, output])
    print subprocess.list2cmdline(command)

    # call it
    subprocess.call(command)

if __name__ == '__main__':
    main()