From 85b1cdc94d1d78723d7ded8c128b4b521e56df90 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sat, 22 Sep 2012 20:08:17 -0700 Subject: Move convert_md_to_rst() function. --- setup.py | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 538291f..330de7e 100644 --- a/setup.py +++ b/setup.py @@ -184,6 +184,32 @@ def make_temp_path(path): return temp_path +def convert_md_to_rst(path): + """ + Convert the given file from markdown to reStructuredText. + + Returns the new path. + + """ + # We write the converted files to temp files to simplify debugging. + temp_path = make_temp_path(path) + print("Converting: %s to %s" % (path, temp_path)) + + if os.path.exists(temp_path): + os.remove(temp_path) + + # Pandoc uses the UTF-8 character encoding for both input and output. + command = "pandoc --write=rst --output=%s %s" % (temp_path, path) + os.system(command) + + if not os.path.exists(temp_path): + s = ("Error running: %s\n" + " Did you install pandoc per the %s docstring?" % (command, __file__)) + sys.exit(s) + + return temp_path + + def write_long_description(target_path): """ Generate the long_description for setup(). @@ -240,32 +266,6 @@ Run the following command and commit the changes-- os.system('python setup.py sdist upload') -def convert_md_to_rst(path): - """ - Convert the given file from markdown to reStructuredText. - - Returns the new path. - - """ - # We write the converted files to temp files to simplify debugging. - temp_path = make_temp_path(path) - print("Converting: %s to %s" % (path, temp_path)) - - if os.path.exists(temp_path): - os.remove(temp_path) - - # Pandoc uses the UTF-8 character encoding for both input and output. - command = "pandoc --write=rst --output=%s %s" % (temp_path, path) - os.system(command) - - if not os.path.exists(temp_path): - s = ("Error running: %s\n" - " Did you install pandoc per the %s docstring?" % (command, __file__)) - sys.exit(s) - - return temp_path - - # We use the package simplejson for older Python versions since Python # does not contain the module json before 2.6: # -- cgit v1.2.1