コード例 #1
0
ファイル: build_rules.py プロジェクト: burgerbecky/wslwinreg
def build(working_directory, configuration):
    """
    Preprocess READEME.rst

    Doxygen doesn't support the importation of .rst files, and the
    support for .md files doesn't support images that
    also have links. To get around this limitation, this preprocessor
    will use docutils to convert the README.rst into an html file
    which will be directly imported into the Doxygen documentation
    so only one copy of the README is needed.

    On exit, return 0 for no error, or a non zero error code if there was an
    error to report.

    Args:
        working_directory
            Directory this script resides in.

        configuration
            Configuration to build, ``all`` if no configuration was requested.

    Returns:
        None if not implemented, otherwise an integer error code.
    """

    # Copy README.rst to docs/temp/README.html
    # Doxygen may not create the output folder, ensure it exists.

    temp_dir = os.path.join(working_directory, 'temp')
    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 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
コード例 #2
0
def main():
    home_link = "https://raw.githubusercontent.com/mbadry1/DeepLearning.ai-Summary/master/"
    marks_down_links = {
        "Deeplearning.ai summary Homepage":
        home_link + "Readme.md",
        "01- Neural Networks and Deep Learning":
        home_link + "1-%20Neural%20Networks%20and%20Deep%20Learning/Readme.md",
        "02- Improving Deep Neural Networks Hyperparameter tuning, Regularization and Optimization":
        home_link + "2-%20Improving%20Deep%20Neural%20Networks/Readme.md",
        "03- Structuring Machine Learning Projects":
        home_link +
        "3-%20Structuring%20Machine%20Learning%20Projects/Readme.md",
        "04- Convolutional Neural Networks":
        home_link + "4-%20Convolutional%20Neural%20Networks/Readme.md",
        "05- Sequence Models":
        home_link + "5-%20Sequence%20Models/Readme.md",
    }

    # Extracting pandoc version
    print("pandoc_version:", pypandoc.get_pandoc_version())
    print("pandoc_path:", pypandoc.get_pandoc_path())
    print("\n")

    # Starting downloading and converting
    for key, value in marks_down_links.items():
        print("Converting", key)
        pypandoc.convert_file(value,
                              'pdf',
                              extra_args=[
                                  '--latex-engine=xelatex', '-V',
                                  'geometry:margin=1.5cm'
                              ],
                              outputfile=(key + ".pdf"))
        print("Converting", key, "completed")
コード例 #3
0
def main():
    home_link = "https://raw.githubusercontent.com/mbadry1/DeepLearning.ai-Summary/master/"
    marks_down_links = {
        "Deeplearning.ai summary Homepage":
            home_link + "Readme.md",
        "01- Neural Networks and Deep Learning":
            home_link + "1-%20Neural%20Networks%20and%20Deep%20Learning/Readme.md",
        "02- Improving Deep Neural Networks Hyperparameter tuning, Regularization and Optimization":
            home_link + "2-%20Improving%20Deep%20Neural%20Networks/Readme.md",
        "03- Structuring Machine Learning Projects":
            home_link + "3-%20Structuring%20Machine%20Learning%20Projects/Readme.md",
        "04- Convolutional Neural Networks":
            home_link + "4-%20Convolutional%20Neural%20Networks/Readme.md",
        "05- Sequence Models":
            home_link + "5-%20Sequence%20Models/Readme.md",
    }

    # Extracting pandoc version
    print("pandoc_version:", pypandoc.get_pandoc_version())
    print("pandoc_path:", pypandoc.get_pandoc_path())
    print("\n")

    # Starting downloading and converting
    for key, value in marks_down_links.items():
        print("Converting", key)
        pypandoc.convert_file(
            value,
            'pdf',
            extra_args=['--latex-engine=xelatex', '-V', 'geometry:margin=1.5cm'],
            outputfile=(key + ".pdf")
        )
        print("Converting", key, "completed")
コード例 #4
0
 def create_sample_lua(self):
     args = [
         pypandoc.get_pandoc_path(), '--print-default-data-file',
         'sample.lua'
     ]
     p = subprocess.Popen(args, stdout=subprocess.PIPE)
     out, err = p.communicate()
     return out.decode('utf-8')
コード例 #5
0
def build_readme(working_directory):
    """
    Preprocess READEME.rst

    Doxygen doesn't support the importation of .rst files, and the
    support for .md files doesn't support images that
    also have links. To get around this limitation, this preprocessor
    will use docutils to convert the README.rst into an html file
    which will be directly imported into the Doxygen documentation
    so only one copy of the README is needed.

    Arg:
        working_directory: Directory for this function to build.
    Returns:
        Zero on no error, non-zero on error.
    """

    # Copy README.rst to docs/temp/README.html
    # 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
コード例 #6
0
def main():
    marks_down_links = {
        "Standford CS231n 2017 Summary":
        "https://raw.githubusercontent.com/mbadry1/CS231n-2017-Summary/master/README.md",
    }

    # Extracting pandoc version
    print("pandoc_version:", pypandoc.get_pandoc_version())
    print("pandoc_path:", pypandoc.get_pandoc_path())
    print("\n")

    # Starting downloading and converting
    for key, value in marks_down_links.items():
        print("Converting", key)
        pypandoc.convert_file(
            value,
            'pdf',
            extra_args=['--pdf-engine=xelatex', '-V', 'geometry:margin=1.5cm'],
            outputfile=(key + ".pdf"))
        print("Converting", key, "completed")
コード例 #7
0
    'packaging', 'psutil>=3.3.0'
]

# Check that the user has installed the Python development headers
PythonH = os.path.join(get_python_inc(), 'Python.h')
if not os.path.exists(PythonH):
    print >> sys.stderr, "You must install the Python development headers!"
    print >> sys.stderr, "$ apt-get install python-dev"
    sys.exit(-1)

# Convert README.md to reStructuredText for PyPI
long_description = ''
try:
    import pypandoc
    try:
        pypandoc.get_pandoc_path()
    except OSError:
        pypandoc.download_pandoc()
    long_description = pypandoc.convert_file('README.md', 'rst')
except ImportError:
    pass
except Exception as e:
    print >> sys.stderr, "Failed to convert README.md through pandoc, proceeding anyway"
    traceback.print_exc()

setup(
    name='pwntools',
    packages=find_packages(),
    version='3.5.0dev',
    data_files=[
        ('', glob.glob('*.md') + glob.glob('*.txt')),
コード例 #8
0
 def test_get_pandoc_path(self):
     result = pypandoc.get_pandoc_path()
     assert "pandoc" in result
コード例 #9
0
 def create_sample_lua(self):
     args = [pypandoc.get_pandoc_path(), '--print-default-data-file', 'sample.lua']
     p = subprocess.Popen(args, stdout=subprocess.PIPE)
     out, err = p.communicate()
     return out.decode('utf-8')
コード例 #10
0
 def test_get_pandoc_path(self):
     result = pypandoc.get_pandoc_path()
     assert "pandoc" in result
コード例 #11
0
ファイル: __init__.py プロジェクト: meikuam/siraj-toolkit
from pypandoc import get_pandoc_path
try:
    print('check if pandoc is installed')
    pandoc_path = get_pandoc_path()
    print("pandoc_path: ", pandoc_path)
except OSError:
    print('pandoc is not installed, so try to download it.')
    from pypandoc.pandoc_download import download_pandoc

    # see the documentation how to customize the installation path
    # but be aware that you then need to include it in the `PATH`
    download_pandoc()

from src.pandoc_cli.pandoc_cli import Converter
コード例 #12
0
ファイル: setup.py プロジェクト: RobertLarsen/pwntools
if platform.system() != 'OpenBSD':
    install_requires.append('psutil>=2.1.3')

# Check that the user has installed the Python development headers
PythonH = os.path.join(get_python_inc(), 'Python.h')
if not os.path.exists(PythonH):
    print >> sys.stderr, "You must install the Python development headers!"
    print >> sys.stderr, "$ apt-get install python-dev"
    sys.exit(-1)

# Convert README.md to reStructuredText for PyPI
long_description = ''
try:
    import pypandoc
    try:
        pypandoc.get_pandoc_path()
    except OSError:
        pypandoc.download_pandoc()
    long_description = pypandoc.convert_file('README.md', 'rst')
except ImportError:
    pass


setup(
    name                 = 'pwntools',
    packages             = find_packages(),
    version              = '3.3.0dev',
    data_files           = [('',
                             glob.glob('*.md') + glob.glob('*.txt')),
                            ],
    package_data         = {
コード例 #13
0
def _pandoc_installed():
    try:
        pypandoc.get_pandoc_path()
    except OSError:
        return False
    return True