Ejemplo n.º 1
0
def scene_breaks(root):
    # Empty <h3> tags appear as a rule on qntm.org
    for e in root.xpath('.//h3'):
        if len(e) == 0 and e.text_content().strip() == "":
            e.addprevious(E.HR())
            e.drop_tree()

    # Other stories use a centered orange * as a scene break
    for e in root.xpath('.//h4'):
        if e.text_content().strip() == "*":
            e.addprevious(E.HR(E.CLASS('scene-break')))
            e.drop_tree()
Ejemplo n.º 2
0
def html_page_return(board, thread, default_style):
    html = E.HTML(
        E.HEAD(
            E.META(**{'http-equiv':"Default-Style", 'content':default_style, 'id':'stylemetatag'}),
            E.TITLE("/"+board+"/ - №"+str(thread)), #title
            E.SCRIPT(type = 'text/javascript', src = '/mainscript.js'), #js
            *initiate.style_cache
            ),
        E.BODY(
            E.P(E.CLASS("board"), board, id = 'board'),
            E.P(E.CLASS("thread"), str(thread), id = 'thread'),
            E.TABLE(
                E.CLASS("maintable"),
                E.THEAD(E.TR(E.TD(
                    E.TABLE(E.TR(E.TD(E.CLASS('left'), copy.copy(initiate.board_cache_navigation)),
                                 E.TD(E.CLASS('right'), utilfunctions.generate_right_up_corner_menu()),
                                 ),
                            id='headblock'),
                    E.HR(E.CLASS("delimeter")),
                    )), id = 'header'),
                E.TBODY(E.TR(E.TD(
                    E.H2(E.CLASS("boardname"),
                         E.A('/' + board + '/ - '+ initiate.board_cache[board].name, href = '/' + board),
                         ),
                    E.HR(E.CLASS("delimeter")),
                    initiate.board_cache[board].post_form, #need to make it depending on post_form_type
                    E.SCRIPT('function open_form() {document.getElementById("postform").style.display = "block"; document.getElementById("closeform").style.display = "block"; document.getElementById("threadcreate").style.display = "none";}'),
                    E.SCRIPT('function close_form() {document.getElementById("postform").style.display = "none"; document.getElementById("closeform").style.display = "none"; document.getElementById("threadcreate").style.display = "block";}'),
                    E.H3(E.A('Ответить в тред', href = "javascript:open_form();"), id = 'threadcreate'),
                    E.H4(E.A('Скрыть форму', href = "javascript:close_form();"), id = 'closeform'),
                    E.HR(E.CLASS("delimeter")),
                    EM('main', '', id = 'mainframe'),
                    E.DIV('', id = 'optionsdiv'),
                    )), id = 'mainpart'),
                E.TFOOT(E.TR(E.TD(
                       E.DIV(
                           E.HR(E.CLASS("delimeter"), id = 'end')
                           ),
                       initiate.board_cache_navigation,
                       E.DIV('powered by ',
                             E.A('Farlight Imageboard Engine',
                                 href='https://github.com/Alpherie/farlight_board_engine',
                                 target='_blank',
                                 ),
                             id='credentials'),
                    )), id = 'footer'),#we make it a footer
                ),
            onload = 'threadfunc()'
            )
        )
    return lxml.html.tostring(html)
Ejemplo n.º 3
0
    def render_html(results: Dict[str, Any]) -> str:
        heading = E.H2(
            E.A("Locust", href="https://github.com/simiotics/locust"),
            " summary")
        body_elements = [heading]

        refs = results.get("refs")
        if refs is not None:
            body_elements.extend([E.H3("Git references")])
            body_elements.extend(
                [E.B("Initial: "),
                 E.SPAN(refs["initial"]),
                 E.BR()])
            if refs["terminal"] is not None:
                body_elements.extend(
                    [E.B("Terminal: "),
                     E.SPAN(refs["terminal"]),
                     E.BR()])

        body_elements.append(E.HR())

        changes_by_file = results["locust"]
        for item in changes_by_file:
            item_element = file_section_handler(item)
            body_elements.append(item_element)

        html = E.HTML(E.BODY(*body_elements))
        results_string = lxml.html.tostring(html).decode()
        return results_string
Ejemplo n.º 4
0
def dim_lcov_report_extend_legend(doc):
    try:
        legend = doc.xpath("//td[@class='headerValueLeg']")[0]
        legend.text = ""

        modified_by_patch = E.SPAN(E.SPAN("Modified by patch:"), E.BR(),
                                   E.SPAN("Lines: "))
        not_modified_by_patch = E.SPAN(E.SPAN("Not modified by patch:"),
                                       E.BR(),
                                       E.SPAN("Lines: "),
                                       style=dim_style)
        for c in legend.getchildren():
            memo = {}
            modified_by_patch.append(c.__deepcopy__(memo))
            memo = {}
            not_modified_by_patch.append(c.__deepcopy__(memo))

        legend.clear()
        legend.set("class", "headerValueLeg")
        legend.append(modified_by_patch)
        legend.append(E.HR())
        legend.append(not_modified_by_patch)
    except:
        # ignore errors in case there is no legend
        pass
Ejemplo n.º 5
0
def main_page_gen(default_style):
    html = E.HTML(
        E.HEAD(
            E.META(**{'http-equiv':"Default-Style", 'content':default_style, 'id':'stylemetatag'}),
            E.TITLE("U2ch - Main Page"),
            E.SCRIPT(type = 'text/javascript', src = '/mainscript.js'), #js
	    *initiate.style_cache
            ),
        E.BODY(
            E.UL(initiate.stats_cache,
                 style = "display: none;",
                 id = "mblstatscache"),
	    E.TABLE(
                E.CLASS("maintable"),
                E.THEAD(E.TR(E.TD(E.DIV(E.CLASS("mainslogandiv"),
                                        E.SPAN("U2CH"),
                                        E.SPAN("",
                                               style="display: inline-block; width: 5em;"),
                                        E.SPAN("Viewing above imageboards"),
                                        ),
                                  E.DIV(E.CLASS("mainimagediv"),
                                        E.IMG(src="u-2.jpg", style="width:496px;height:334px;"),
                                        ),
                                  )), id = 'header'),
                E.TBODY(E.TR(E.TD(
                    E.HR(E.CLASS("delimeter")),
                    E.DIV(E.CLASS("mblcontainer"),
                          E.DIV(E.CLASS("mblcentering"),
                                initiate.board_cache_main_page,
                                ),
                          ),
                    E.HR(E.CLASS("delimeter")),
                    )), id = 'mainpart'),
                E.TFOOT(E.TR(E.TD(
                    E.DIV('powered by ',
                        E.A('Farlight Imageboard Engine',
                            href='https://github.com/Alpherie/farlight_board_engine',
                            target='_blank',
                            ),
                        id='credentials'),
                    )), id = 'footer'),
                ),
            onload = 'mainpagefunc()'
            )
        )
    return lxml.html.tostring(html)
Ejemplo n.º 6
0
 def footer(self, node):
     """Create a standard footer block for HTML files."""
     footer = Element('footer')
     footer.append(E.HR())
     footer.append(
         E.
         P("Generated automatically from {source} at {time:%d %b %Y %H:%M}."
           .format(source=node.sourcefile, time=datetime.datetime.now())), )
     return footer
Ejemplo n.º 7
0
    def visit_MemoryMap(self, node):
        """Create an HTML file for a MemoryMap."""
        self.title = title = node.name + ' Peripheral Map'
        an = ((node.size - 1).bit_length() + 3) // 4

        # Sweep the document tree to build up the main content
        with self.tempvars(wordwidth=1,
                           address_nibbles=an,
                           base=node.base,
                           subdir=node.name + '_instances',
                           hlev=2):
            children = list(self.visitchildren(node))
            table = E.TABLE(
                E.TR(E.TH('Peripheral'), E.TH('Base Address'), E.TH('Size'),
                     E.TH('Description'), *children), CLASS('component_list'))
            nodes = ([E.H1(title, id='title')] +
                     [E.P(d) for d in node.description] +
                     [E.HR(), table, self.footer(node)])
            contentnode = E.DIV(*nodes, id='content')

        # Add a table of contents sidebar for each table row.
        instlist = E.UL()
        for elem in contentnode.xpath("//td[contains(@class, 'peripheral')]"):
            text = tostring(elem, method="text", encoding="unicode")
            id = escape(text)
            elem.attrib['id'] = id
            node = E.LI(E.A(text, href='#' + id))
            instlist.append(node)

        # And put it all together.
        return E.HTML(
            E.HEAD(
                E.TITLE(title),
                E.LINK(rel='stylesheet',
                       type='text/css',
                       href=htmlpathjoin(self.styledir, 'reg.css'))),
            E.BODY(
                E.DIV(E.DIV(E.P(E.A(title, href='#title')),
                            instlist,
                            id='sidebar'),
                      contentnode,
                      id='wrapper')),
        )
Ejemplo n.º 8
0
def scene_breaks(root):
    for e in root:
        if re.match(r'(\s*[—–-]+\s*)+', e.text_content()):
            e.addprevious(E.HR(E.CLASS('scene-break')))
            e.drop_tree()
Ejemplo n.º 9
0
 def parse(self, block):
     """"""
     return E.HR()
Ejemplo n.º 10
0
def scene_breaks(root):
    for e in root:
        if e.text_content().strip() == '■':
            e.addprevious(E.HR(E.CLASS('scene-break')))
            e.drop_tree()
Ejemplo n.º 11
0
def scene_breaks(root):
    # Replace empty <h6> tags with <br>
    for h6 in root.xpath('.//h6'):
        h6.addprevious(E.HR(E.CLASS('scene-break')))
        h6.drop_tree()