def convert_md_to_rst(source, destination=None, backup_dir=None):
<EOL>try:<EOL><INDENT>import pypandoc<EOL><DEDENT>except ImportError:<EOL><INDENT>os.system("<STR_LIT>")<EOL>import pypandoc<EOL><DEDENT>destination = destination or (os.path.splitext(source)[<NUM_LIT:0>] + '<STR_LIT>')<EOL>backup_dir = backup_dir or os.path.join(os.path.dirname(destination),<EOL>'<STR_LIT>')<EOL>bak_name = (os.path.basename(destination) +<EOL>time.strftime('<STR_LIT>'))<EOL>bak_path = os.path.join(backup_dir, bak_name)<EOL>if os.path.isfile(destination):<EOL><INDENT>if not os.path.isdir(os.path.dirname(bak_path)):<EOL><INDENT>os.mkdir(os.path.dirname(bak_path))<EOL><DEDENT>os.rename(destination, bak_path)<EOL><DEDENT>try:<EOL><INDENT>pypandoc.convert(<EOL>source,<EOL>'<STR_LIT>',<EOL>format='<STR_LIT>',<EOL>outputfile=destination<EOL>)<EOL><DEDENT>except:<EOL><INDENT>if os.path.isfile(destination):<EOL><INDENT>os.remove(destination)<EOL><DEDENT>if os.path.isfile(bak_path):<EOL><INDENT>os.rename(bak_path, destination)<EOL><DEDENT>raise<EOL><DEDENT>
Try to convert the source, an .md (markdown) file, to an .rst
    (reStructuredText) file at the destination. If the destination isn't
    provided, it defaults to be the same as the source path except for the
    filename extension. If the destination file already exists, it will be
    overwritten. In the event of an error, the destination file will be
    left untouched.