Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions bin/rst2ansi

This file was deleted.

34 changes: 34 additions & 0 deletions rst2ansi/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python

from __future__ import print_function

import sys
from rst2ansi import rst2ansi
import argparse
import io

def main(argv=None):
if argv is None:
argv = sys.argv[1:]

parser = argparse.ArgumentParser(description='Prints a reStructuredText input in an ansi-decorated format suitable for console output.')
parser.add_argument('file', type=str, nargs='?', help='A path to the file to open')

args = parser.parse_args(argv)

def process_file(f):
out = rst2ansi(f.read())
if out:
try:
print(out)
except UnicodeEncodeError:
print(out.encode('ascii', errors='backslashreplace').decode('ascii'))

if args.file:
with io.open(args.file, 'rb') as f:
process_file(f)
else:
process_file(sys.stdin)

if __name__ == '__main__':
main()
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import os
import sys
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from setuptools import setup

def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
Expand All @@ -21,8 +18,10 @@ def read(fname):
keywords="rst restructuredtext ansi console code converter",
url="https://github.com/Snaipe/python-rst-to-ansi",
packages=['rst2ansi'],
requires=['docutils'],
scripts=['bin/rst2ansi'],
install_requires=['docutils'],
entry_points = {
'console_scripts': ['rst2ansi=rst2ansi.__main__:main'],
},
data_files=[],
classifiers=[
"Development Status :: 4 - Beta",
Expand Down