def __init__(self, configs,*args, **kwargs):
        Renderer.__init__(self, *args, **kwargs)
        #document title
        self.configs = configs
        self.doc_title = configs['title']
        self.image_extension = configs['images_ext']
        # Load dictionary with methods
        for key in dir(self):
            if key.startswith('do__'):
                self[self.aliases[key[4:]]] = getattr(self, key)
            elif key.startswith('do_'):
                self[key[3:]] = getattr(self, key)

        self['default-layout'] = self['document-layout'] = self.default
        self.footnotes = []
        self.blocks = []
        #tree object
        self.tree = PageTree(self.doc_title,
                configs['output_path'],configs)
        #parameter for list formatting
        self.list_level=u''
        #parameter for theorem handling
        self.in_theorem=False

        ####### TAGS ANALYSY
        #dictionary for tag usage
        self.used_tags = {}
Exemplo n.º 2
0
def test_imager(imager_tuple, tmpdir):
    imager, ext, compiler = imager_tuple
    if ext == ".svg":
        kind = "vector-imager"
    else:
        kind = "imager"

    tmpdir = Path(str(tmpdir)) # for old pythons

    tex = TeX()
    tex.ownerDocument.config['images'][kind] = imager
    if compiler is not None:
        tex.ownerDocument.config['images'][kind.replace("imager", "compiler")] = compiler

    tex.input(r'''
    \documentclass{article}
    \AtBeginDocument{You should not be seeing this in the imager output. This
    is injected into the document with \textbackslash AtBeginDocument. The actual
    image is on the second page and the imager should get the images from
    there.}
    \begin{document}
    $a + b = x$
    \end{document}
    ''')

    renderer = Renderer()
    if kind == "imager":
        renderer['math'] = lambda node: node.image.url
    else:
        renderer['math'] = lambda node: node.vectorImage.url

    directory = os.getcwd()
    os.chdir(str(tmpdir))
    renderer.render(tex.parse())
    os.chdir(directory)

    outfile = tmpdir/'images'/('img-0001' + ext)
    root = Path(__file__).parent

    benchfile = root/'benchmarks'/"{}-{}{}".format(imager, compiler, ext)
    if not benchfile.exists():
        (root/'new').mkdir(parents=True, exist_ok=True)
        shutil.copyfile(str(outfile), str(root/'new'/benchfile.name))
        raise OSError('No benchmark file: %s' % benchfile)

    diff = cmp_img(str(benchfile.absolute()), str(outfile.absolute()))

    if (ext == '.svg' and diff > 0.0001) or diff > 0.01:
        (root/'new').mkdir(parents=True, exist_ok=True)
        shutil.copyfile(str(outfile), str(root/'new'/benchfile.name))

        if ext == '.svg':
            bench = benchfile.read_text().split('\n')
            output = outfile.read_text()
            print('SVG differences:\n','\n'.join(difflib.unified_diff(
                bench, output.split('\n'), fromfile='benchmark', tofile='output')).strip())
            print('Full svg:\n\n', output)
        assert False, 'Differences were found:\n' + str(diff)
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     Renderer.__init__(self, *args, **kwargs)
     # Load dictionary with methods
     for key in dir(self):
         if key.startswith('do_'):
             self[key[3:]] = getattr(self, key)
     self['default-layout'] = self['document-layout'] = self.default
     self.footnotes = []
     self.blocks = []
Exemplo n.º 4
0
    def render(self, document):
        """ Load and compile page templates """
        themename = document.config['general']['theme']

        # Load templates from renderer directory and parent
        # renderer directories
        sup = list(type(self).__mro__)
        sup.reverse()
        themes = []
        for cls in sup:
            if cls is BaseRenderer or cls is object or cls is dict:
                continue
            cwd = os.path.dirname(sys.modules[cls.__module__].__file__)
            log.info('Importing templates from %s' % cwd)
            self.importDirectory(cwd)

            # Store theme location
            themes.append(os.path.join(cwd, 'Themes', themename))

            # Load templates configured by the environment variable
            templates = os.environ.get('%sTEMPLATES' % cls.__name__, '')
            for path in [
                    x.strip() for x in templates.split(os.pathsep)
                    if x.strip()
            ]:
                log.info('Importing templates from %s' % path)
                self.importDirectory(path)
                themes.append(os.path.join(path, 'Themes', themename))

        # Load only one theme
        for theme in reversed(themes):
            if os.path.isdir(theme):
                log.info('Importing templates from %s' % theme)
                self.importDirectory(theme)

                extensions = ['.zpts', '.pts']
                for e in self.engines.values():
                    extensions += e.ext

                if document.config['general']['copy-theme-extras']:
                    # Copy all theme extras
                    cwd = os.getcwd()
                    os.chdir(theme)
                    for item in os.listdir('.'):
                        if os.path.isdir(item):
                            if not os.path.isdir(os.path.join(cwd, item)):
                                os.makedirs(os.path.join(cwd, item))
                            copytree(item, cwd, True)
                        elif os.path.splitext(
                                item)[-1].lower() not in extensions:
                            shutil.copy(item, os.path.join(cwd, item))
                    os.chdir(cwd)

                break

        BaseRenderer.render(self, document)
Exemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     """Initialize the Renderer
     """
     Renderer.__init__(self, *args, **kwargs)
     
     # Load dictionary with methods
     for key in vars(type(self)):
         if key.startswith('do__'):
             self[self.aliases[key[4:]]] = getattr(self, key)
         elif key.startswith('do_'):
             self[key[3:]] = getattr(self, key)
Exemplo n.º 6
0
    def render(self, document):
        """ Load and compile page templates """
        themename = document.config['general']['theme']

        # Load templates from renderer directory and parent 
        # renderer directories
        sup = list(type(self).__mro__)
        sup.reverse()
        themes = []
        for cls in sup:
            if cls is BaseRenderer or cls is object or cls is dict:
                continue
            cwd = os.path.dirname(sys.modules[cls.__module__].__file__)
            log.info('Importing templates from %s' % cwd)
            self.importDirectory(cwd)

            # Store theme location
            themes.append(os.path.join(cwd, 'Themes', themename))

            # Load templates configured by the environment variable
            templates = os.environ.get('%sTEMPLATES' % cls.__name__,'')
            for path in [x.strip() for x in templates.split(os.pathsep) if x.strip()]:
                log.info('Importing templates from %s' % path)
                self.importDirectory(path)
                themes.append(os.path.join(path, 'Themes', themename))

        # Load only one theme
        for theme in reversed(themes):
            if os.path.isdir(theme):
                log.info('Importing templates from %s' % theme)
                self.importDirectory(theme)

                extensions = ['.zpts','.pts']
                for e in self.engines.values():
                    extensions += e.ext

                if document.config['general']['copy-theme-extras']:
                    # Copy all theme extras
                    cwd = os.getcwd()
                    os.chdir(theme)
                    for item in os.listdir('.'):
                        if os.path.isdir(item):
                            if not os.path.isdir(os.path.join(cwd,item)):
                                os.makedirs(os.path.join(cwd,item))
                            copytree(item, cwd, True)
                        elif os.path.splitext(item)[-1].lower() not in extensions:
                            shutil.copy(item, os.path.join(cwd,item))
                    os.chdir(cwd)

                break

        BaseRenderer.render(self, document)
Exemplo n.º 7
0
    def render(self, document):
        """ Load templates and render the document """
        self.loadTemplates(document)

        # Better support oversized images, if sidewaysfigure is used
        for item in document:
            if isinstance(item, documentclass):
                if item.argSource[0] == '[':
                    item.argSource = '[fullpage,' + item.argSource[1:]
                else:
                    item.argSource = '[fullpage]' + item.argSource

        BaseRenderer.render(self, document)
Exemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        BaseRenderer.__init__(self, *args, **kwargs)
        
        # Load dictionary with methods
        for key in vars(type(self)):
            if key.startswith('do__'):
                self[self.aliases[key[4:]]] = getattr(self, key)
            elif key.startswith('do_'):
                self[key[3:]] = getattr(self, key)

        self['default-layout'] = self['document-layout'] = self.default
        
        self.footnotes = []
        self.blocks = []
Exemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        BaseRenderer.__init__(self, *args, **kwargs)

        # Load dictionary with methods
        for key in dir(self):
            if key.startswith('do__'):
                self[self.aliases[key[4:]]] = getattr(self, key)
            elif key.startswith('do_'):
                self[key[3:]] = getattr(self, key)

        self['default-layout'] = self['document-layout'] = self.default

        self.footnotes = []
        self.blocks = []
Exemplo n.º 10
0
    def __init__(self, *args, **kwargs):
        BaseRenderer.__init__(self, *args, **kwargs)

        # Load dictionary with methods
        for key in vars(type(self)):
            if key.startswith('do__'):
                self[self.aliases[key[4:]]] = getattr(self, key)
            elif key.startswith('do_'):
                self[key[3:]] = getattr(self, key)

        self.indent = 0
        self.in_func = False
        self.in_cvarg = False
        self.descriptions = 0
        self.after_parameters = False
        self.func_short_desc = ''
Exemplo n.º 11
0
    def processFileContent(self, document, s):
        s = BaseRenderer.processFileContent(self, document, s)

        # Put block level elements back in
        block_re = re.compile('(\\s*)\001\\[(\\d+)@+\\]')
        while 1:
            m = block_re.search(s)
            if not m:
                break

            space = ''
            before = m.group(1)
            if before is None:
                before = ''
            if '\n' in before:
                spaces = before.split('\n')
                space = spaces.pop()
                before = '\n'.join(spaces) + '\n'

            block = self.blocks[int(m.group(2))]
            block = space + block.replace('\n', u'\n%s' % space)

            s = block_re.sub('%s%s' % (before, block), s, 1)

        # Clean up newlines
        return re.sub(r'\s*\n\s*\n(\s*\n)+', r'\n\n\n', s)
Exemplo n.º 12
0
    def processFileContent(self, document, s):
        s = BaseRenderer.processFileContent(self, document, s)

        # Put block level elements back in
        block_re = re.compile('(\\s*)\001\\[(\\d+)@+\\]')
        while 1:
            m = block_re.search(s)
            if not m:
                break

            space = ''
            before = m.group(1)
            if before is None:
                before = ''
            if '\n' in before:
                spaces = before.split('\n')
                space = spaces.pop()
                before = '\n'.join(spaces) + '\n'

            block = self.blocks[int(m.group(2))]
            block = space + block.replace('\n', u'\n%s' % space) 

            s = block_re.sub('%s%s' % (before, block), s, 1)

        # Clean up newlines
        return re.sub(r'\s*\n\s*\n(\s*\n)+', r'\n\n\n', s)
Exemplo n.º 13
0
    def __init__(self, *args, **kwargs):
        BaseRenderer.__init__(self, *args, **kwargs)

        # Load dictionary with methods
        for key in vars(type(self)):
            if key.startswith("do__"):
                self[self.aliases[key[4:]]] = getattr(self, key)
            elif key.startswith("do_"):
                self[key[3:]] = getattr(self, key)

        self.indent = 0
        self.in_func = False
        self.in_cvarg = False
        self.descriptions = 0
        self.after_parameters = False
        self.func_short_desc = ""
    def processFileContent(self, document, s):
        # process the bibliography information

        s = BaseRenderer.processFileContent(self, document, s)

        # Put block level elements back in
        block_re = re.compile('(\\s*)\001\\[(\\d+)@+\\]')
        while 1:
            m = block_re.search(s)
            if not m:
                break

            space = ''
            before = m.group(1)
            if before is None:
                before = ''
            if '\n' in before:
                spaces = before.split('\n')
                space = spaces.pop()
                before = '\n'.join(spaces) + '\n'

            block = self.blocks[int(m.group(2))]
            block = space + block.replace('\n', u'\n%s' % space)

            s = block_re.sub('%s%s' % (before, block), s, 1)

        # Hack to allow eqref to work
        s = re.sub(r'(\\eqref) ([^\s,.]+)', r'\1{\2}', s)

        # Remove single spaces at beginning of lines
        # Some in-line equations are not handled correctly
        s1 = re.sub(r'^\s(\S)', r'\1', s, flags=re.MULTILINE)

        # Clean up newlines
        return re.sub(r'\s*\n\s*\n(\s*\n)+', r'\n\n\n', s1)
Exemplo n.º 15
0
 def __init__(self, *args, **kwargs):
     BaseRenderer.__init__(self, *args, **kwargs)
     self.engines = {}
     htmlexts = ['.html','.htm','.xhtml','.xhtm','.zpt']
     self.registerEngine('zpt', None, htmlexts, htmltemplate)
     self.registerEngine('zpt', 'xml', '.xml', xmltemplate)
     self.registerEngine('tal', None, htmlexts, htmltemplate)
     self.registerEngine('tal', 'xml', '.xml', xmltemplate)
     self.registerEngine('html', None, htmlexts, htmltemplate)
     self.registerEngine('xml', 'xml', '.xml', xmltemplate)
     self.registerEngine('python', None, '.pyt', pythontemplate)
     self.registerEngine('string', None, '.st', stringtemplate)
     self.registerEngine('kid', None, '.kid', kidtemplate)
     self.registerEngine('cheetah', None, '.che', cheetahtemplate)
     self.registerEngine('genshi', None, '.gen', genshihtmltemplate)
     self.registerEngine('genshi', 'xml', '.genx', genshixmltemplate)
     self.registerEngine('genshi', 'text', '.gent', genshitexttemplate)
Exemplo n.º 16
0
 def __init__(self, *args, **kwargs):
     BaseRenderer.__init__(self, *args, **kwargs)
     self.engines = {}
     htmlexts = [".html", ".htm", ".xhtml", ".xhtm", ".zpt", ".pt"]
     self.registerEngine("pt", None, htmlexts, htmltemplate)
     self.registerEngine("zpt", None, htmlexts, htmltemplate)
     self.registerEngine("zpt", "xml", ".xml", xmltemplate)
     self.registerEngine("tal", None, htmlexts, htmltemplate)
     self.registerEngine("tal", "xml", ".xml", xmltemplate)
     self.registerEngine("html", None, htmlexts, htmltemplate)
     self.registerEngine("xml", "xml", ".xml", xmltemplate)
     self.registerEngine("python", None, ".pyt", pythontemplate)
     self.registerEngine("string", None, ".st", stringtemplate)
     self.registerEngine("kid", None, ".kid", kidtemplate)
     self.registerEngine("cheetah", None, ".che", cheetahtemplate)
     self.registerEngine("genshi", None, ".gen", genshihtmltemplate)
     self.registerEngine("genshi", "xml", ".genx", genshixmltemplate)
     self.registerEngine("genshi", "text", ".gent", genshitexttemplate)
Exemplo n.º 17
0
    def processFileContent(self, document, s):
        s = BaseRenderer.processFileContent(self, document, s)

        # Clean up newlines
        s = re.sub(r'\s*\n(\s*\n)+', r'\n\n', s)
        s = re.sub(r'(\s*\n)+(\.B[ld])', r'\n\2', s)
        s = re.sub(r'(\.E[ld])\s*(\.B[ld])', r'\1\n\n\2', s)
        s = re.sub(r'\.Ed\s*\.Bd', r'.Ed\n.Bd', s)
        s = s.lstrip()

        return s
Exemplo n.º 18
0
    def processFileContent(self, document, s):
        s = BaseRenderer.processFileContent(self, document, s)

        # Clean up newlines
        s = re.sub(r'\s*\n(\s*\n)+', r'\n\n', s)
        s = re.sub(r'(\s*\n)+(\.B[ld])', r'\n\2', s)
        s = re.sub(r'(\.E[ld])\s*(\.B[ld])', r'\1\n\n\2', s)
        s = re.sub(r'\.Ed\s*\.Bd', r'.Ed\n.Bd', s)
        s = s.lstrip()
        
        return s
Exemplo n.º 19
0
def test_todo_disable(tmpdir):
    renderer = Renderer()

    def render_todo(obj):
        if obj.ownerDocument.todoNotesDisable:
            return "disabled"
        else:
            return str(obj.attributes["todo"])

    renderer["todo"] = render_todo

    enabled = r'''
\documentclass{article}
\usepackage{todonotes}
\begin{document}
  \todo{foo}
\end{document}
'''

    disabled = r'''
\documentclass{article}
\usepackage[disable]{todonotes}
\begin{document}
  \todo{foo}
\end{document}
'''

    with tmpdir.as_cwd():
        renderer.render(TeX().input(enabled).parse())
        assert Path("index").read_text().strip() == "foo"

        renderer.render(TeX().input(disabled).parse())
        assert Path("index").read_text().strip() == "disabled"
Exemplo n.º 20
0
    def processFileContent(self, document, s):
        # Add width, height, and depth to images
        s = re.sub(r"&(\S+)-(width|height|depth);(?:&([a-z]+);)?", self.setImageData, s)

        # Convert characters >127 to entities
        if document.config["files"]["escape-high-chars"]:
            s = list(s)
            for i, item in enumerate(s):
                if ord(item) > 127:
                    s[i] = "&#%.3d;" % ord(item)
            s = u"".join(s)

        return BaseRenderer.processFileContent(self, document, s)
Exemplo n.º 21
0
    def processFileContent(self, document, s):
        # Add width, height, and depth to images
        s = re.sub(r'&(\S+)-(width|height|depth);(?:&([a-z]+);)?',
                   self.setImageData, s)

        # Convert characters >127 to entities
        if document.config['files']['escape-high-chars']:
            s = list(s)
            for i, item in enumerate(s):
                if ord(item) > 127:
                    s[i] = '&#%.3d;' % ord(item)
            s = ''.join(s)
        
        return BaseRenderer.processFileContent(self, document, s)
Exemplo n.º 22
0
    def processFileContent(self, document, s):
        # Convert characters >127 to entities
        if document.config['files']['escape-high-chars']:
            s = list(s)
            for i, item in enumerate(s):
                if ord(item) > 127:
                    s[i] = '&#%.3d;' % ord(item)
            s = ''.join(s)

        # Remove empty paragraphs
        s = EMPTY_PARAGRAPH.sub(r'', s)

        # Add a non-breaking space to empty table cells
        s = TABLE_NBSP.sub(r'\1 \3', s)

        return BaseRenderer.processFileContent(self, document, s)
Exemplo n.º 23
0
    def processFileContent(self, document, s):
        # Add width, height, and depth to images
        s = re.sub(r'&(\S+)-(width|height|depth);(?:&([a-z]+);)?',
                   self.setImageData, s)

        # Convert characters >127 to entities
        if document.config['files']['escape-high-chars']:
            s = list(s)
            for i, item in enumerate(s):
                if ord(item) > 127:
                    s[i] = '&#%.3d;' % ord(item)
            s = ''.join(s)

        # Remove empty paragraphs
        s = re.compile(r'<p>\s*</p>', re.I).sub(r'', s)

        # Add a non-breaking space to empty table cells
        s = re.compile(r'(<(td|th)\b[^>]*>)\s*(</\2>)', re.I).sub(r'\1&nbsp;\3', s)

        return BaseRenderer.processFileContent(self, document, s)
Exemplo n.º 24
0
def test_imager(enable_bitmap, tmpdir):
    with tmpdir.as_cwd():
        tex = TeX()
        tex.ownerDocument.config['images']["imager"] = "none"
        tex.ownerDocument.config['images']["vector-imager"] = "pdf2svg"

        tex.input(r'''
        \documentclass{article}
        \begin{document}
        $a + b = x$
        \end{document}
        ''')

        doc = tex.parse()
        renderer = Renderer()
        renderer.imager = NullImager(doc)
        renderer.vectorBitmap = enable_bitmap
        renderer['math'] = lambda node: node.vectorImage.url

        if enable_bitmap:
            with pytest.raises(ValueError):
                renderer.render(doc)
        else:
            renderer.render(doc)
Exemplo n.º 25
0
    latexcontent = r'''\documentclass{book}
    
    \usepackage{latex2cnxmlmod}
    \usepackage{longtable}
    \begin{document}
    %s
    \end{document}''' % latexcontent

    tex = TeX.TeX()
    tex.ownerDocument.config['files']['split-level'] = -100
    tex.ownerDocument.config['files']['filename'] = '%s.xml' % inputfile
    tex.input(latexcontent)

    document = tex.parse()
    # Render the document
    renderer = Renderer()
    renderer['chapter'] = renderer.section
    renderer['section'] = renderer.section
    renderer['subsection'] = renderer.section
    renderer['subsubsection'] = renderer.section
    renderer['par'] = renderer.par
    renderer['itemize'] = renderer.itemize
    renderer['keyconcepts'] = renderer.keyconcepts
    renderer['newwords'] = renderer.newwords
    renderer['bgroup'] = renderer.bgroup
    renderer['textbf'] = renderer.textbf
    renderer['textit'] = renderer.textit
    renderer['displaymath'] = renderer.displaymath
    renderer['textrm'] = renderer.textrm
    renderer['active::_'] = renderer.sub
    renderer['center'] = renderer.center
Exemplo n.º 26
0
 def __init__(self, *args, **kwargs):
     BaseRenderer.__init__(self, *args, **kwargs)
Exemplo n.º 27
0
 def render(self, document):
     """ Load templates and render the document """
     BaseRenderer.render(self, document)
Exemplo n.º 28
0
    def textDefault(self, node):
        """ Rendering method for all text nodes """
        return node.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')        


# Instantiate a TeX processor and parse the input text

fn = sys.argv[1]
print "fn=",fn

tex = TeX()
tex.ownerDocument.config['files']['split-level'] = -100
tex.ownerDocument.config['files']['filename'] = fn+'.wiki'

tex.ownerDocument.context.importMacros({1:BOX})
tex.ownerDocument.context.importMacros({2:inlinepsfig})
tex.ownerDocument.context.importMacros({3:matrix})
tex.ownerDocument.context.importMacros({4:wikitext})

ifn = fn + '.tex'

tex.input(open(ifn).read())
document = tex.parse()

# Render the document
renderer = Renderer()
renderer.render(document)

#print document
Exemplo n.º 29
0
 def render(self, document):
     """ Load templates and render the document """
     self.loadTemplates(document)
     BaseRenderer.render(self, document)
Exemplo n.º 30
0
    def __init__(self, *args, **kwargs):
        BaseRenderer.__init__(self, *args, **kwargs)

        htmlexts = ['.html','.htm','.xhtml','.xhtm','.zpt','.pt']
Exemplo n.º 31
0
 def __getitem__(self, key):
     print "Attempting to obtain %s"%key
     return BaseRenderer.__getitem__(self, key)
Exemplo n.º 32
0
def test_tikz(tmpdir):
    try:
        tmpdir = Path(tmpdir)
    except TypeError: # Fallback for older python
        tmpdir = Path(str(tmpdir))

    root = Path(__file__).parent
    test_id = "tikz-pdf2svg-gspdfpng"

    benchdir = root / "benchmarks" / test_id
    newdir = root / "new" / test_id

    images = ["images/img-0001.svg", "images/img-0002.svg", "images/img-0001.png", "images/img-0002.png"]

    config = base_config.copy()
    config['images']['vector-imager'] = 'pdf2svg'
    config['images']['imager'] = 'gspdfpng'

    doc = TeXDocument(config=config)
    tex = TeX(doc)

    tex.input(r'''
    \documentclass{article}
    \usepackage{tikz}
    \usepackage{tikz-cd}
    \begin{document}
    \begin{tikzpicture}
        \draw (0, 0) -- (0, 2) -- (2, 0) -- (0, 0);
    \end{tikzpicture}

    \begin{tikzcd}
        A \ar[r, "i"] & B \ar[d, "p"] \\ & C
    \end{tikzcd}
    \end{document}
    ''')

    renderer = Renderer()

    def render_image(obj):
        return "{}\n{}\n".format(obj.vectorImage.url, obj.image.url)

    renderer["tikzpicture"] = render_image
    renderer["tikzcd"] = render_image

    cwd = os.getcwd()
    os.chdir(str(tmpdir))
    renderer.render(tex.parse())
    os.chdir(cwd)

    def new_file(base: str):
        newfile = newdir / base
        newfile.parent.mkdir(parents=True, exist_ok=True)
        shutil.copy(str(tmpdir / base), str(newfile))

    # Compare image output
    error = False

    try:
        if not filecmp.cmp(str(tmpdir / "index"), str(benchdir / "index"), shallow=False):
            print('Differences were found: index', file=sys.stderr)
            error = True
            new_file("index")

    except FileNotFoundError as e:
        error = True
        if e.filename == str(tmpdir / "index"):
            print("Missing output file: index", file=sys.stderr)
        else:
            print("Missing benchmark file: index", file=sys.stderr)
            new_file("index")

    for f in images:
        if not (tmpdir / f).exists():
            error = True
            print('Missing output file: %s' % f, file=sys.stderr)
        elif not (benchdir / f).exists():
            error = True
            print('Missing benchmark file: %s' % f, file=sys.stderr)
            new_file(f)

        diff = cmp_img(str(tmpdir / f), str(benchdir / f))
        if diff > 0.0001:
            error = True
            print('Differences were found: {} ({})'.format(f, diff), file=sys.stderr)
            new_file(f)

    if error:
        assert False
Exemplo n.º 33
0
 def render(self, document):
     """ Load templates and render the document """
     self.loadTemplates(document)
     BaseRenderer.render(self, document)