How to use the pypandoc.ensure_pandoc_installed function in pypandoc

To help you get started, we’ve selected a few pypandoc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github burgerbecky / makeprojects / docs / build_rules.py View on Github external
# Doxygen may not create the output folder, ensure it exists.

    temp_dir = os.path.join(working_directory, 'temp')
    burger.create_folder_if_needed(temp_dir)

    # Get the input and output file names
    source = os.path.join(os.path.dirname(working_directory), 'README.rst')
    dest = os.path.join(temp_dir, 'README.html')

    # Was the file already created and newer than the source?
    if burger.is_source_newer(source, dest):

        # Load pandoc if needed to do the conversion
        if hasattr(pypandoc, 'ensure_pandoc_installed'):
            # pylint: disable=E1101
            pypandoc.ensure_pandoc_installed(quiet=True, delete_installer=True)
        else:
            try:
                pypandoc.get_pandoc_path()
            except OSError:
                pypandoc.download_pandoc()
        pypandoc.convert_file(source, to='html', outputfile=dest)
    return 0