How to use the graphviz.tools.mkdirs function in graphviz

To help you get started, we’ve selected a few graphviz 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 xflr6 / graphviz / tests / test_tools.py View on Github external
def test_mkdirs(tmpdir):
    with tmpdir.as_cwd():
        mkdirs('spam.eggs')
        assert list(itertree(str(tmpdir))) == []
        for _ in range(2):
            mkdirs('spam/eggs/spam.eggs')
            assert list(itertree(str(tmpdir))) == [(False, 'spam'),
                                                   (False, 'spam/eggs')]
github xflr6 / graphviz / tests / test_tools.py View on Github external
def test_mkdirs(tmpdir):
    with tmpdir.as_cwd():
        mkdirs('spam.eggs')
        assert list(itertree(str(tmpdir))) == []
        for _ in range(2):
            mkdirs('spam/eggs/spam.eggs')
            assert list(itertree(str(tmpdir))) == [(False, 'spam'),
                                                   (False, 'spam/eggs')]
github xflr6 / graphviz / tests / test_tools.py View on Github external
def test_mkdirs_invalid(tmpdir):
    with tmpdir.as_cwd():
        (tmpdir / 'spam.eggs').write_binary(b'')
        with pytest.raises(OSError):
            mkdirs('spam.eggs/spam')
github xflr6 / graphviz / graphviz / files.py View on Github external
def save(self, filename=None, directory=None):
        """Save the DOT source to file. Ensure the file ends with a newline.

        Args:
            filename: Filename for saving the source (defaults to ``name`` + ``'.gv'``)
            directory: (Sub)directory for source saving and rendering.
        Returns:
            The (possibly relative) path of the saved source file.
        """
        if filename is not None:
            self.filename = filename
        if directory is not None:
            self.directory = directory

        filepath = self.filepath
        tools.mkdirs(filepath)

        data = text_type(self.source)

        log.debug('write %d bytes to %r', len(data), filepath)
        with io.open(filepath, 'w', encoding=self.encoding) as fd:
            fd.write(data)
            if not data.endswith(u'\n'):
                fd.write(u'\n')

        return filepath