def test_skip_notes(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'maximal'),
                '-n',
                os.path.join(TEST_DATA, 'presenter-notes.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                # We have verified the contents in test_generator.py, let's
                # just check that it writes the right thing:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['skip-presenter-notes'])

            out_files = os.listdir(tmpdir)
            self.assertEqual(set(out_files), {'index.html', 'js', 'css', 'images', 'fonts'})
            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(set(js_files),
                             {'impress.js', 'hovercraft.js', 'impressConsole.js', 'dummy.js'})
            css_files = os.listdir(os.path.join(tmpdir, 'css'))
            self.assertEqual(set(css_files), {'print.css', 'style.css', 'impressConsole.css'})
            image_files = os.listdir(os.path.join(tmpdir, 'images'))
            self.assertEqual(set(image_files), {'python-logo-master-v3-TM.png'})
            font_files = os.listdir(os.path.join(tmpdir, 'fonts'))
            self.assertEqual(set(font_files), {
                'texgyreschola-regular-webfont.ttf',
                'texgyreschola-regular-webfont.eot',
                'texgyreschola-regular-webfont.woff',
                'texgyreschola-regular-webfont.svg',
            })
Exemple #2
0
    def test_default_template(self):
        with TemporaryDirectory() as tmpdir:
            # Adding a non-existant subdir, to test that it gets created.
            tmpdir = os.path.join(tmpdir, 'foo')

            sys.argv = [
                'bin/hovercraft',
                os.path.join(TEST_DATA, 'advanced.rst'),
                tmpdir,
            ]
            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                self.assertEqual(outfile.read(),
                                 HTML_OUTPUTS['default-template'])

            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(
                set(js_files),
                {'impress.js', 'hovercraft.js', 'impressConsole.js'})
            css_files = os.listdir(os.path.join(tmpdir, 'css'))
            self.assertEqual(
                set(css_files),
                {'hovercraft.css', 'impressConsole.css', 'highlight.css'})
            image_files = os.listdir(os.path.join(tmpdir, 'images'))
            self.assertEqual(set(image_files), {'hovercraft_logo.png'})
Exemple #3
0
 def test_skip_notes(self):
     with TemporaryDirectory() as tmpdir:
         sys.argv = [
             'bin/hovercraft',
             '-t' + os.path.join(TEST_DATA, 'maximal'),
             '-c' + os.path.join(TEST_DATA, 'extra.css'),
             '-n', 
             os.path.join(TEST_DATA, 'presenter-notes.rst'),
             tmpdir,
         ]
         
         main()
         
         with open(os.path.join(tmpdir, 'index.html')) as outfile:
             # We have verified the contents in test_generator.py, let's
             # just check that it writes the right thing:
             self.assertEqual(len(outfile.read()), 1368)
             
         out_files = os.listdir(tmpdir)
         self.assertEqual(set(out_files), {'extra.css', 'index.html', 'js', 'css', 'images', 'fonts'})
         js_files = os.listdir(os.path.join(tmpdir, 'js'))
         self.assertEqual(set(js_files), {'impress.js', 'hovercraft.js', 'impressConsole.js', 'dummy.js'})
         css_files = os.listdir(os.path.join(tmpdir, 'css'))
         self.assertEqual(set(css_files), {'print.css', 'style.css', 'impressConsole.css'})
         image_files = os.listdir(os.path.join(tmpdir, 'images'))
         self.assertEqual(set(image_files), {'python-logo-master-v3-TM.png'})
         font_files = os.listdir(os.path.join(tmpdir, 'fonts'))
         self.assertEqual(set(font_files), {
             'texgyreschola-regular-webfont.ttf',
             'texgyreschola-regular-webfont.eot',
             'texgyreschola-regular-webfont.woff',
             'texgyreschola-regular-webfont.svg',
         })
Exemple #4
0
    def test_extra_css(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                "bin/hovercraft",
                "-t" + os.path.join(TEST_DATA, "maximal"),
                "-c" + os.path.join(TEST_DATA, "extra.css"),
                "-n",
                os.path.join(TEST_DATA, "simple.rst"),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, "index.html"), "rb") as outfile:
                self.assertEqual(outfile.read(), HTML_OUTPUTS["extra_css"])

            out_files = os.listdir(tmpdir)
            self.assertEqual(
                set(out_files),
                {
                    "extra.css",
                    "index.html",
                    "js",
                    "css",
                    "images",
                    "fonts",
                    "directory",
                },
            )
    def test_big(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'maximal', 'template.cfg'),
                os.path.join(TEST_DATA, 'advanced.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                # We have verified the contents in test_generator.py, let's
                # just check that it writes the right thing:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['advanced'])

            out_files = os.listdir(tmpdir)
            self.assertEqual(set(out_files),
                             {'extra.css', 'extra.js', 'index.html', 'js', 'css', 'images', 'fonts'})
            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(set(js_files),
                             {'impress.js', 'hovercraft.js', 'impressConsole.js', 'dummy.js'})
            css_files = os.listdir(os.path.join(tmpdir, 'css'))
            self.assertEqual(set(css_files), {'print.css', 'style.css', 'impressConsole.css'})
            image_files = os.listdir(os.path.join(tmpdir, 'images'))
            self.assertEqual(set(image_files), {'hovercraft_logo.png'})
            font_files = os.listdir(os.path.join(tmpdir, 'fonts'))
            self.assertEqual(set(font_files), {
                'texgyreschola-regular-webfont.ttf',
                'texgyreschola-regular-webfont.eot',
                'texgyreschola-regular-webfont.woff',
                'texgyreschola-regular-webfont.svg',
            })
Exemple #6
0
def run(filename, dictionary, build_dir, image_paths):
    settings.logger.info("Bootstrap added successfully.")

    """
    Runs hovercraft command. Creates presentation in presentation folder.
    """

    try:
        settings.logger.info("registering directives...")
        directives.register_directive('row', Row)
        directives.register_directive('column', Column)
        settings.logger.info("Done")

        pm.print_spacer()
        settings.logger.info("Running hovercraft to create presentation...\n")
        hovercraft_target_dir = get_folder_name(dictionary)
        hovercraft_target_dir = str(Path(build_dir) / hovercraft_target_dir)

        command = ["--skip-help", filename, hovercraft_target_dir]

        handle_images(hovercraft_target_dir, filename, image_paths)
        hovercraft.main(command)
        html_file = Path(hovercraft_target_dir) / "index.html"
        if settings.columns:
            make_columns(str(html_file))
        soup = make_soup(html_file)
        add_bootstrap(soup, html_file)
        if settings.bg_img:
            add_background_images(soup, html_file)
        if not settings.header_visible:
            hide_header(soup, html_file)
        if not settings.footer_visible:
            hide_footer(soup, html_file)
        links_to_new_tabs(soup, html_file)
        settings.logger.info("Hovercraft presentation created.")
        return hovercraft_target_dir
    except FileNotFoundError as fnf_error:
        settings.logger.critical("\nCritical error occurred while running hovercraft."
                                 "\nFile not found.\nError message: {}".format(fnf_error))
        tb = traceback.format_exc()
        settings.logger.warning(tb)
        pm.exiting()

    except OSError as error:
        settings.logger.critical("\nError occurred while running hovercraft.\nError message: {}".format(error))
        tb = traceback.format_exc()
        settings.logger.warning(tb)
        pm.exiting()
    except subprocess.CalledProcessError as e:
        settings.logger.critical("\nError occurred while running hovercraft.\nError: {}, \noutput: {} "
                                 "\nPossible cause: Header and/or footer images do not exist or image paths are not "
                                 "correct in presentation_config.yaml".format(e, e.output))
        tb = traceback.format_exc()
        settings.logger.warning(tb)
        pm.exiting()
    finally:
        pm.print_spacer()
Exemple #7
0
    def test_mathjax(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                os.path.join(TEST_DATA, 'math.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                result = outfile.read()
                self.assertIn(b'<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">', result)
                self.assertIn(br'<div class="math-block ">$$\begin{align}dS = \frac{dQ}{T}\end{align}$$</div>', result)
                self.assertIn(br'<span class="math ">\(S = k \log W\)</span>', result)
    def test_mathjax(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                os.path.join(TEST_DATA, 'math.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                result = outfile.read()
                self.assertIn(b'<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">', result)
                self.assertIn(br'<div class="math-block ">$$\begin{align}dS = \frac{dQ}{T}\end{align}$$</div>', result)
                self.assertIn(br'<span class="math ">\(S = k \log W\)</span>', result)
    def test_big(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'maximal', 'template.cfg'),
                os.path.join(TEST_DATA, 'advanced.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                # We have verified the contents in test_generator.py, let's
                # just check that it writes the right thing:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['advanced'])

            out_files = os.listdir(tmpdir)
            self.assertEqual(
                set(out_files), {
                    'extra.css', 'extra.js', 'index.html', 'js', 'css',
                    'images', 'fonts', 'directory'
                })

            # Make sure the whole tree of the directory resource was copies,
            # except .dont-include, which should not be included.
            out_files = os.listdir(os.path.join(tmpdir, 'directory'))
            self.assertEqual(set(out_files),
                             {'subdir', 'hovercraft_logo.png', 'print.css'})
            out_files = os.listdir(os.path.join(tmpdir, 'directory', 'subdir'))
            self.assertEqual(set(out_files), {'afile'})

            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(set(js_files), {
                'impress.js', 'hovercraft.js', 'impressConsole.js', 'dummy.js'
            })
            css_files = os.listdir(os.path.join(tmpdir, 'css'))
            self.assertEqual(set(css_files),
                             {'print.css', 'style.css', 'impressConsole.css'})
            image_files = os.listdir(os.path.join(tmpdir, 'images'))
            self.assertEqual(set(image_files), {'hovercraft_logo.png'})
            font_files = os.listdir(os.path.join(tmpdir, 'fonts'))
            self.assertEqual(
                set(font_files), {
                    'texgyreschola-regular-webfont.ttf',
                    'texgyreschola-regular-webfont.eot',
                    'texgyreschola-regular-webfont.woff',
                    'texgyreschola-regular-webfont.svg',
                })
Exemple #10
0
    def test_auto_console(self):
        with TemporaryDirectory() as tmpdir:
            # Adding a non-existant subdir, to test that it gets created.
            tmpdir = os.path.join(tmpdir, 'foo')

            sys.argv = [
                'bin/hovercraft',
                '-a',
                os.path.join(TEST_DATA, 'simple.rst'),
                tmpdir,
            ]
            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                result = outfile.read()
                self.assertIn(b'auto-console="True"', result)
Exemple #11
0
    def test_auto_console(self):
        with TemporaryDirectory() as tmpdir:
            # Adding a non-existant subdir, to test that it gets created.
            tmpdir = os.path.join(tmpdir, "foo")

            sys.argv = [
                "bin/hovercraft",
                "-a",
                os.path.join(TEST_DATA, "simple.rst"),
                tmpdir,
            ]
            main()

            with open(os.path.join(tmpdir, "index.html"), "rb") as outfile:
                result = outfile.read()
                self.assertIn(b'auto-console="True"', result)
    def test_small(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'minimal'),
                os.path.join(TEST_DATA, 'simple.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['simple'])

            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(set(js_files), {'impress.js', 'hovercraft-minimal.js'})
    def test_small(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'minimal'),
                os.path.join(TEST_DATA, 'simple.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['simple'])

            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(set(js_files), {'impress.js', 'hovercraft-minimal.js'})
    def test_subdirectory_css(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                os.path.join(TEST_DATA, 'subdir-css.rst'),
                tmpdir,
            ]

            main()

            out_files = os.listdir(tmpdir)
            self.assertEqual(set(out_files), {'index.html', 'js', 'css', 'images'})
            css_files = os.listdir(os.path.join(tmpdir, 'css'))
            self.assertEqual(set(css_files), {'hovercraft.css', 'highlight.css', 'sub.css', 'impressConsole.css'})
            image_files = os.listdir(os.path.join(tmpdir, 'images'))
            self.assertEqual(set(image_files), {'python-logo-master-v3-TM.png'})
    def test_auto_console(self):
        with TemporaryDirectory() as tmpdir:
            # Adding a non-existant subdir, to test that it gets created.
            tmpdir = os.path.join(tmpdir, 'foo')

            sys.argv = [
                'bin/hovercraft',
                '-a',
                os.path.join(TEST_DATA, 'simple.rst'),
                tmpdir,
            ]
            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                result = outfile.read()
                self.assertIn(b'auto-console="True"', result)
Exemple #16
0
    def test_small(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                "bin/hovercraft",
                "-t" + os.path.join(TEST_DATA, "minimal"),
                os.path.join(TEST_DATA, "simple.rst"),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, "index.html"), "rb") as outfile:
                self.assertEqual(outfile.read(), HTML_OUTPUTS["simple"])

            js_files = os.listdir(os.path.join(tmpdir, "js"))
            self.assertEqual(set(js_files),
                             {"impress.js", "hovercraft-minimal.js"})
    def test_subdirectory_css(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                os.path.join(TEST_DATA, 'subdir-css.rst'),
                tmpdir,
            ]

            main()

            out_files = os.listdir(tmpdir)
            self.assertEqual(set(out_files), {'index.html', 'js', 'css', 'images'})
            css_files = os.listdir(os.path.join(tmpdir, 'css'))
            self.assertEqual(set(css_files),
                             {'hovercraft.css', 'highlight.css', 'sub.css', 'sub2.css', 'impressConsole.css'})
            image_files = os.listdir(os.path.join(tmpdir, 'images'))
            self.assertEqual(set(image_files), {'python-logo-master-v3-TM.png'})
Exemple #18
0
    def test_skip_notes(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                "bin/hovercraft",
                "-t" + os.path.join(TEST_DATA, "maximal"),
                "-n",
                os.path.join(TEST_DATA, "presenter-notes.rst"),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, "index.html"), "rb") as outfile:
                # We have verified the contents in test_generator.py, let's
                # just check that it writes the right thing:
                self.assertEqual(outfile.read(),
                                 HTML_OUTPUTS["skip-presenter-notes"])

            out_files = os.listdir(tmpdir)
            self.assertEqual(
                set(out_files),
                {"index.html", "js", "css", "images", "fonts", "directory"},
            )
            js_files = os.listdir(os.path.join(tmpdir, "js"))
            self.assertEqual(
                set(js_files),
                {
                    "impress.js", "hovercraft.js", "impressConsole.js",
                    "dummy.js"
                },
            )
            css_files = os.listdir(os.path.join(tmpdir, "css"))
            self.assertEqual(set(css_files),
                             {"print.css", "style.css", "impressConsole.css"})
            image_files = os.listdir(os.path.join(tmpdir, "images"))
            self.assertEqual(set(image_files), {"hovercraft_logo.png"})
            font_files = os.listdir(os.path.join(tmpdir, "fonts"))
            self.assertEqual(
                set(font_files),
                {
                    "texgyreschola-regular-webfont.ttf",
                    "texgyreschola-regular-webfont.eot",
                    "texgyreschola-regular-webfont.woff",
                    "texgyreschola-regular-webfont.svg",
                },
            )
Exemple #19
0
 def test_small(self):
     with TemporaryDirectory() as tmpdir:
         sys.argv = [
             'bin/hovercraft',
             '-t' + os.path.join(TEST_DATA, 'minimal'),
             os.path.join(TEST_DATA, 'simple.rst'),
             tmpdir, 
         ]
         
         main()
         
         with open(os.path.join(tmpdir, 'index.html')) as outfile:
             # We have verified the contents in test_geerator.py, let's
             # just check that it writes the right thing:
             self.assertEqual(len(outfile.read()), 561)
             
         js_files = os.listdir(os.path.join(tmpdir, 'js'))
         self.assertEqual(set(js_files), {'impress.js', 'hovercraft-minimal.js'})
    def test_extra_css(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'maximal'),
                '-c' + os.path.join(TEST_DATA, 'extra.css'),
                '-n',
                os.path.join(TEST_DATA, 'simple.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['extra_css'])

            out_files = os.listdir(tmpdir)
            self.assertEqual(set(out_files), {'extra.css', 'index.html', 'js', 'css', 'images', 'fonts'})
    def test_small(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'minimal'),
                os.path.join(TEST_DATA, 'simple.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html')) as outfile:
                # We have verified the contents in test_geerator.py, let's
                # just check that it writes the right thing:
                self.assertEqual(len(outfile.read()), 561)

            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(set(js_files),
                             {'impress.js', 'hovercraft-minimal.js'})
    def test_extra_css(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                'bin/hovercraft',
                '-t' + os.path.join(TEST_DATA, 'maximal'),
                '-c' + os.path.join(TEST_DATA, 'extra.css'),
                '-n',
                os.path.join(TEST_DATA, 'simple.rst'),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['extra_css'])

            out_files = os.listdir(tmpdir)
            self.assertEqual(set(out_files),
                             {'extra.css', 'index.html', 'js', 'css', 'images', 'fonts'})
Exemple #23
0
    def test_subdirectory_css(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                "bin/hovercraft",
                os.path.join(TEST_DATA, "subdir-css.rst"),
                tmpdir,
            ]

            main()

            out_files = os.listdir(tmpdir)
            self.assertEqual(set(out_files),
                             {"index.html", "js", "css", "images"})
            css_files = os.listdir(os.path.join(tmpdir, "css"))
            self.assertEqual(
                set(css_files),
                {"hovercraft.css", "highlight.css", "sub.css", "sub2.css"},
            )
            image_files = os.listdir(os.path.join(tmpdir, "images"))
            self.assertEqual(set(image_files), {"hovercraft_logo.png"})
    def test_default_template(self):
        with TemporaryDirectory() as tmpdir:
            # Adding a non-existant subdir, to test that it gets created.
            tmpdir = os.path.join(tmpdir, 'foo')

            sys.argv = [
                'bin/hovercraft',
                os.path.join(TEST_DATA, 'advanced.rst'),
                tmpdir,
            ]
            main()

            with open(os.path.join(tmpdir, 'index.html'), 'rb') as outfile:
                self.assertEqual(outfile.read(), HTML_OUTPUTS['default-template'])

            js_files = os.listdir(os.path.join(tmpdir, 'js'))
            self.assertEqual(set(js_files), {'impress.js', 'hovercraft.js',
                                             'impressConsole.js'})
            css_files = os.listdir(os.path.join(tmpdir, 'css'))
            self.assertEqual(set(css_files), {'hovercraft.css',
                                              'impressConsole.css', 'highlight.css'})
            image_files = os.listdir(os.path.join(tmpdir, 'images'))
            self.assertEqual(set(image_files), {'hovercraft_logo.png'})
Exemple #25
0
    def test_default_template(self):
        with TemporaryDirectory() as tmpdir:
            # Adding a non-existant subdir, to test that it gets created.
            tmpdir = os.path.join(tmpdir, "foo")

            sys.argv = [
                "bin/hovercraft",
                os.path.join(TEST_DATA, "advanced.rst"),
                tmpdir,
            ]
            main()

            with open(os.path.join(tmpdir, "index.html"), "rb") as outfile:
                self.assertEqual(outfile.read(),
                                 HTML_OUTPUTS["default-template"])

            js_files = os.listdir(os.path.join(tmpdir, "js"))
            self.assertEqual(set(js_files),
                             {"impress.js", "hovercraft.js", "gotoSlide.js"})
            css_files = os.listdir(os.path.join(tmpdir, "css"))
            self.assertEqual(set(css_files),
                             {"hovercraft.css", "highlight.css"})
            image_files = os.listdir(os.path.join(tmpdir, "images"))
            self.assertEqual(set(image_files), {"hovercraft_logo.png"})
Exemple #26
0
    def test_big(self):
        with TemporaryDirectory() as tmpdir:
            sys.argv = [
                "bin/hovercraft",
                "-t" + os.path.join(TEST_DATA, "maximal", "template.cfg"),
                os.path.join(TEST_DATA, "advanced.rst"),
                tmpdir,
            ]

            main()

            with open(os.path.join(tmpdir, "index.html"), "rb") as outfile:
                # We have verified the contents in test_generator.py, let's
                # just check that it writes the right thing:
                self.assertEqual(outfile.read(), HTML_OUTPUTS["advanced"])

            out_files = os.listdir(tmpdir)
            self.assertEqual(
                set(out_files),
                {
                    "extra.css",
                    "extra.js",
                    "index.html",
                    "js",
                    "css",
                    "images",
                    "fonts",
                    "directory",
                },
            )

            # Make sure the whole tree of the directory resource was copies,
            # except .dont-include, which should not be included.
            out_files = os.listdir(os.path.join(tmpdir, "directory"))
            self.assertEqual(set(out_files),
                             {"subdir", "hovercraft_logo.png", "print.css"})
            out_files = os.listdir(os.path.join(tmpdir, "directory", "subdir"))
            self.assertEqual(set(out_files), {"afile"})

            js_files = os.listdir(os.path.join(tmpdir, "js"))
            self.assertEqual(
                set(js_files),
                {
                    "impress.js", "hovercraft.js", "impressConsole.js",
                    "dummy.js"
                },
            )
            css_files = os.listdir(os.path.join(tmpdir, "css"))
            self.assertEqual(set(css_files),
                             {"print.css", "style.css", "impressConsole.css"})
            image_files = os.listdir(os.path.join(tmpdir, "images"))
            self.assertEqual(set(image_files), {"hovercraft_logo.png"})
            font_files = os.listdir(os.path.join(tmpdir, "fonts"))
            self.assertEqual(
                set(font_files),
                {
                    "texgyreschola-regular-webfont.ttf",
                    "texgyreschola-regular-webfont.eot",
                    "texgyreschola-regular-webfont.woff",
                    "texgyreschola-regular-webfont.svg",
                },
            )
Exemple #27
0
#!/usr/bin/env python3

from os.path import realpath
import sys

import hovercraft
import alectryon.docutils
alectryon.docutils.setup()

from alectryon.serapi import SerAPI
SerAPI.DEFAULT_PP_ARGS["pp_margin"] = 70

from hovercraft.parse import SlideMaker

# Hovercraft's MathJax is outdated and competes with ours
SlideMaker.start_math = SlideMaker.default_start
SlideMaker.start_math_block = SlideMaker.default_start

from hovercraft import position
position.DEFAULT_MOVEMENT = 2600 # Must be > 1920

if __name__ == "__main__":
    hovercraft.main(sys.argv[1:])
Exemple #28
0
import hovercraft

hovercraft.main()
Exemple #29
0
# Need to make sure all graph images files are existing
try:
    presentation = sys.argv[1:][0]
except IndexError:
    presentation = 'index.rst'

# Relpath
rel_path = os.path.abspath(os.path.dirname(presentation))
# Make dir
graphs = []
with open(presentation, 'r') as f:
    for l in f.readlines():
        try:
            img = re.findall(r'.. graph::\s?(.*)$', l)[0]
            img_path = os.path.join(rel_path, img)
            img_dir = os.path.dirname(img_path)
            if not os.path.exists(img_dir):
                os.mkdir(img_dir)
            if not os.path.exists(img_path):
                with open(img_path, 'w+') as f:
                    pass
        except IndexError:
            pass

if __name__ == "__main__":
    cmd = [presentation]
    if len(sys.argv) > 2:
        cmd.extend(sys.argv[2:])
    hovercraft.main(cmd)
from hovercraft import main

if __name__ == '__main__':
    main(
        [
            # '-N',
            'README.rst',
            # targetdir - generated presentation static html
            'www'
        ]
    )