def get_rendered_for_toc(self, path_override=None): """Returns an html 'ul' element, that represents the entire table of contents for this category. Parameters --------- path_override : str If not None, gets urls for this path. Intended for use by parent categories getting the toc of their children. """ root_elm = E.UL(E.CLASS("toc_category")) # Children categories. nav = self.navigation for child in self.children: if path_override != None: child_path = get_url(path_override, child.file_path) else: child_path = get_url(self.file_path, child.file_path) child_elm = E.LI( E.A(child.name, href=child_path), child.get_rendered_for_toc(path_override=self.path) ) root_elm.append(child_elm) # Assets. for asset in self.assets: asset_path = get_new_ext(asset.path, 'html') if path_override != None: asset_path = get_url(path_override, asset_path) else: asset_path = get_url(self.file_path, asset_path) asset_elm = E.LI( E.A(asset.title, href=asset_path) ) root_elm.append(asset_elm) return root_elm
def template(name, contents): cpu_class = 'active' if name == 'cpu' else '' wc_class = 'active' if name == 'wc' else '' help_class = 'active' if name == 'help' else '' return E.HTML( E.HEAD( E.LINK(rel='stylesheet', type='text/css', href='bootstrap/css/bootstrap.css'), E.LINK(rel='stylesheet', type='text/css', href='profile.css'), E.SCRIPT(src='bootstrap/js/bootstrap.min.js'), E.TITLE('RUM Job Profile')), E.BODY( E.DIV(E.DIV(E.DIV(E.A(E.SPAN(CLASS='icon-bar'), E.SPAN(CLASS='icon-bar'), E.SPAN(CLASS='icon-bar'), CLASS='btn btn-navbar'), E.A('RUM Profile', CLASS='brand', href='#'), E.DIV(E.UL(E.LI(E.A('CPU time', href='cpu.html'), CLASS=cpu_class), E.LI(E.A('Wallclock time', href='wc.html'), CLASS=wc_class), E.LI(E.A('Help', href='help.html'), CLASS=help_class), CLASS='nav'), CLASS='nav-collapse collapse'), CLASS='container'), CLASS='navbar-inner'), CLASS='navbar navbar-inverse navbar-fixed-top'), E.BR(), E.BR(), E.BR(), E.DIV(contents, CLASS='container')))
def diff(base, new): u""" Return an Element that renders the version differences between the amis `base` and `new`. Arguments: base, new (dicts): Descriptions of a deployed AMI. Any keys that start with 'version:' should have values that are a repo and a sha, separated by a space. They must also have the keys 'environment', 'deployment', 'play', and 'ami_id'. """ diff_items = [] for delta in sorted(set(version_deltas(base, new))): version = delta.new or delta.base repo = GITHUB_PREFIX.sub(u'', version.repo) diff_items.append( E.LI( E.A( u"{}: {}...{}".format(repo, delta.base.sha, delta.new.sha), href=u"{}/compare/{}...{}".format(version.repo, delta.base. sha, delta.new.sha), ) if delta.base.sha != delta.new.sha else E.A( u"{}: {} (no change)".format(repo, delta.base.sha), href=u"{}/commit/{}".format(repo, delta.base.sha), ))) return SECTION( E. H3(u"Comparing {base.environment}-{base.deployment}-{base.play}: {base.ami_id} to {new.ami_id}" .format( base=base, new=new, )), E.UL(*diff_items, style=u"list-style-type: square"))
def get_boards(lines, position, hierarchy): divs = [] pattern = re.compile('([^\s]+)\s(.+)') while position < len(lines): line = lines[position] line = line.replace('\n', '') if line == '': position += 1 continue match = pattern.search(line) if match is None: return divs, position hierarchy.append(match.group(1)) cats, pos = get_categories(lines, position + 1, hierarchy) hierarchy.pop() divs.append( E.DIV( E.CLASS('fib'), E.A(match.group(2), id='board', target='main', href='http://' + match.group(1)), E.A('[+]', id='plus', onclick="toggle(this, '" + match.group(2) + "');"))) divs.append(E.DIV(*cats, style="display: none;", id=match.group(2))) position = pos return divs, position
def generate_right_up_corner_menu(): html = E.SPAN( E.CLASS('rightupmenu'), E.SPAN('[', E.A('Стили', href='#', onclick='stylechanger(this);'), ']'), E.SPAN('[', E.A('Главная', href='/'), ']'), E.SPAN('[', E.A('A', href='/admin'), ']'), ) return html
def visit_Component(self, node): inst = getattr(self, 'inst', None) if inst: title = 'Instance {} of {} Register Map'.format(inst, node.name) else: title = 'Base {} Register Map'.format(node.name) self.title = title # Create the main content by sweeping the tree. bc = E.DIV(id='breadcrumbs') try: if self.breadcrumbs is not None: bc.append(self.breadcrumbs) except AttributeError: pass ww = node.width // 8 an = ((node.size - 1).bit_length() + 3) // 4 with self.tempvars(wordwidth=ww, address_nibbles=an, hlev=2): nodes = ([E.H1(title, id='title'), bc] + [E.P(d) for d in node.description] + [c for c in self.visitchildren(node)] + [self.footer(node)]) contentnode = E.DIV(*nodes, id='content') # Add a table of contents sidebar. We'll assume that everything that # wants to be in the TOC is already a heading and just work from there. h2list = E.UL() for elem in contentnode.iter('h2', 'h3'): id = escape(elem.text) elem.attrib['id'] = id if elem.tag == 'h2': h2node = E.LI(E.A(elem.text, href='#' + id)) h2list.append(h2node) h3list = None else: if h3list is None: h3list = E.UL() h2list.append(h3list) h3list.append(E.LI(E.A(elem.text, href='#' + id))) # 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')), h2list, id='sidebar'), contentnode, id='wrapper')), )
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)
def list_boards_menu(board_list, purpose): """need to put boards table creating to a separate function in future""" posts_num_cell = E.DIV(E.SPAN('????', style = 'display:inline-block; width:4em; text-align:center;'), E.INPUT(type='number', size='6', min='0', value='1', style = 'width: 6em;'), E.SELECT(E.OPTION('Секунды', value='1'), E.OPTION('Минуты', value='60'), E.OPTION('Часы', value='3600'), E.OPTION('Дни', value='86400', selected='') ), E.BUTTON('GET', onclick='get_posts_num_from_time(this)', type = 'button')) tablerows = [E.TR(E.TD(E.A(b.address, href = '/'+b.address)), E.TD(b.tablename), E.TD(str(b.name)), E.TD(str(b.fullname)), E.TD(str(b.description)), E.TD(str(b.category)), E.TD(str(b.pictures)), E.TD(str(b.bumplimit)), E.TD(str(b.maxthreads)), E.TD(copy.copy(posts_num_cell)) )for b in board_list] #purpose will be applyed later html = E.HTML( E.HEAD( E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"), E.TITLE("Creating board"), E.SCRIPT(type = 'text/javascript', src = '/adminscript.js') #js ), E.BODY( E.DIV(E.CLASS('adminupdiv'), E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')), E.H2(E.CLASS("heading"), "Listing boards"), ), E.TABLE( E.CLASS("boardstable"), E.TR(E.TH('Адрес'), E.TH('Таблица'), E.TH('Название'), E.TH('Полное название'), E.TH('Описание'), E.TH('Категория'), E.TH('Максимум картинок'), E.TH('Бамплимит'), E.TH('Максимум тредов'), E.TH('Постов за последнее время') ), *tablerows ) ) ) return lxml.html.tostring(html)
def header(self): """Make the header bar of the webpage""" return E.E.header( E.ATTR(id='header'), E.DIV( E.ATTR(id='title'), E.H1( E.A( 'GCC Python Plugin', href='http://gcc-python-plugin.readthedocs.org/', ), ), E.DIV( E.ATTR(id='info'), E.SPAN( E.CLASS('label'), 'Filename: ', ), self.data['filename'], E.SPAN( E.CLASS('label'), 'Function: ', ), self.data['function']['name'], ), E.DIV( E.ATTR(id='report-pagination'), E.SPAN( E.CLASS('label'), 'Report: ', ), *( E.A(str(i + 1), href="#state{0}".format(i + 1)) for i in range(len(self.data['reports'])) ) ), E.DIV( E.ATTR(id='prev'), E.IMG( src=data_uri('image/png', 'images/arrow-180.png'), ), ), E.DIV( E.ATTR(id='next'), E.IMG( src=data_uri('image/png', 'images/arrow.png'), ), ), ), )
def main(results_file): summary = {} with open(results_file, 'r') as f: summary = json.loads(f.read()) summary['directory'] = os.path.dirname(results_file) date = datetime.datetime.fromtimestamp( summary['timestamp']).strftime('%Y-%m-%d-%H:%M:%S') token_create_rps = summary['token_creation']['requests_per_second'] token_create_tps = summary['token_creation']['time_per_request'] token_validate_rps = summary['token_validation']['requests_per_second'] token_validate_tps = summary['token_validation']['time_per_request'] index = e.HTML( e.HEAD(e.LINK(rel='stylesheet', type='text/css', href='theme.css'), e.TITLE('OpenStack Keystone Performance')), e.BODY( e.DIV(e.H1('OpenStack Keystone Performance'), e.P('Published reports after each merged patch.', CLASS('subtitle')), id='header'), e.DIV( e.P('Last run date: ' + date, ), e.P( 'keystone SHA: ', e.A(summary['sha'], target='_blank', href=KEYSTONE_LINK + summary['sha'])), e.P( 'os_keystone SHA: ', e.A(summary['osa_sha'], target='_blank', href=OSA_LINK + summary['osa_sha'])), e.P(e.A('Performance Data', href=PERF_LINK, target='_blank')), e.DIV(CLASS('left'), e.H2('Create Token'), e.P(e.STRONG(token_create_rps), ' requests per second'), e.P(e.STRONG(token_create_tps), ' ms per request')), e.DIV( CLASS('right'), e.H2('Validate Token'), e.P(e.STRONG(token_validate_rps), ' requests per second'), e.P(e.STRONG(token_validate_tps), ' ms per request')), id='content'), e.DIV(e.P( 'Results provided by the ', e.A('OSIC Performance Bot', target='_blank', href=BOT_LINK)), id='footer'))) with open(os.path.join(summary['directory'], 'index.html'), 'w') as f: f.write(et.tostring(index))
def dim_lcov_report(doc): # xpath() doc: # https://lxml.de/tutorial.html#using-xpath-to-find-text # https://devhints.io/xpath # "<title>LCOV - all.lcov - src/netaddress.cpp</title>" --> "src/netaddress.cpp" source_code_file = doc.xpath("//title")[0].text.split(" ")[-1:][0] dim_lcov_report_extend_legend(doc) modified_and_not_covered_lines = [] for line_num_span in doc.xpath("//*[@class='lineNum']"): line_num = int(line_num_span.text) line_a = line_num_span.getparent() line_a.addprevious(E.A("#", href="#" + str(line_num))) if source_code_file not in modified_lines or line_num not in modified_lines[ source_code_file]: line_a.set("style", dim_style) else: if len(line_a.xpath(".//*[@class='lineNoCov']")) > 0: modified_and_not_covered_lines.append(line_num) if len(modified_and_not_covered_lines) > 0: html_report = source_code_file + ".gcov.html" print("<a href='%s'>%s</a>: [%s]<br>" % (html_report, source_code_file, ", ".join( map( lambda n: "<a href='" + html_report + "#" + str(n) + "'>" + str(n) + "</a>", modified_and_not_covered_lines))))
def link(self): """Link for playing the YouTube video.""" if not hasattr(self, "_link"): url = self.VIDEO_URL.format(self.youtube_id) self._link = builder.A("Watch video on YouTube", href=url) return self._link
def pagify(dom): search_pattern = target_base_url + r'(?P<id>\d+).htm' a_links = dom.xpath("//a[@href]") for link in a_links: id = re.search(search_pattern, link.attrib['href']) if id is not None: if 'target' in link.attrib: link.attrib.pop('target') link.attrib['href'] = '/page/' + str(id.group('id')) b_links = dom.xpath("//b[@onclick]") for link in b_links: id = re.search(search_pattern, link.attrib['onclick']) if id is not None: new_href = '/page/' + str(id.group('id')) new_tag = E.A(link.text_content(), title=link.attrib["title"], href=new_href) parent_node = link.getparent() parent_node.replace(link, new_tag) p_tags = dom.xpath("//div[@id='nr1']/p") for p in p_tags: if (('class' in p.attrib and p.attrib['class'] == 'pcinvisible') or (re.search('落.*霞.*小.*说', p.text_content()) is not None)): # print(p.text_content()) p.getparent().remove(p) return dom
def write_t_rec(self, t, autoAnchor=None, align='left', parent=None, level=0): """ Recursively writes a <t> element If no parent is specified, a dummy div will be treated as the parent and any text will go in a <p> element. Otherwise text and child elements will be insert directly into the parent -- meaning we are in a list """ if parent is None: parent = self.temp_div # Dummy div current = E.P() parent.append(current) else: current = parent if t.text: if "anchor" in t.attrib: a = E.A(name=t.attrib["anchor"]) a.tail = t.text current.append(a) else: current.text = t.text if autoAnchor: current.attrib['id'] = autoAnchor for child in t: if child.tag in ['xref', 'eref', 'iref', 'cref', 'spanx']: for element in self._expand_ref(child): current.append(element) elif child.tag == 'u': for element in self._expand_u(child): current.append(element) elif child.tag == 'vspace': br = E.BR() current.append(br) blankLines = int( child.attrib.get('blankLines', self.defaults['vspace_blanklines'])) for i in range(blankLines): br = E.BR() current.append(br) if child.tail: br.tail = child.tail elif child.tag == 'list': self.write_list(child, parent, level=level) if child.tail: parent.append(E.P(child.tail)) elif child.tag == 'figure': # Callback to base writer method self.write_figure(child) elif child.tag == 'texttable': # Callback to base writer method self.write_table(child) # If we are back at top level, serialize the whole temporary structure # Add to body buffer if parent == self.temp_div: self.buf.append(self._flush_temp_div())
def _update_commands(toolshed, doc_ul, doc): from lxml.html import builder as E missing = {} for bi in toolshed.bundle_info(None): for cmd in bi.commands: words = cmd.name.split(maxsplit=2) name = words[0] if name in doc or name in missing: continue synopsis = cmd.synopsis if len(words) > 1: # synopsis not appropriate for multiword commands synopsis = bi.synopsis href = bi.get_path(os.path.join("docs", "user", "commands", "%s.html" % name)) if href: missing[name] = ("commands/%s.html" % name, synopsis) names = list(doc) missing_names = list(missing) missing_names.sort(key=str.casefold) all_names = names + missing_names all_names.sort(key=str.casefold) for name in missing_names: i = all_names.index(name) href, synopsis = missing[name] if synopsis: synopsis = " \N{En dash} " + synopsis doc_ul.insert( i, E.LI(E.A(E.B(name), href=href), synopsis))
def diff_link(delta): u""" Return a nicely formatted link that links to a github commit/diff page comparing ``delta.base`` and ``delta.new``. """ if delta.base is None: summary = u"{} (added)".format(delta.new.sha) href = format_commit_url(delta.new) elif delta.new is None: summary = u"{} (removed)".format(delta.base.sha) href = format_commit_url(delta.base) elif delta.base.sha == delta.new.sha: summary = u"{} (no change)".format(delta.base.sha) href = format_commit_url(delta.new) else: summary = u"{}...{}".format(delta.base.sha, delta.new.sha) href = u"{}/compare/{}...{}".format(delta.new.repo, delta.base.sha, delta.new.sha) return [ u"{} ({}): ".format( delta.app, GITHUB_PREFIX.sub(u'', (delta.new or delta.base).repo), ), E.A(summary, href=href), ]
def list_bans_menu(ban_list, purpose): """need to put bans and boards table creating to a joint function in future""" tablerows = [E.TR(E.TD(str(b.id)), E.TD(b.ip), E.TD(b.initiator), E.TD(time.strftime('%d/%m/%Y %H:%M', time.localtime(b.date))), E.TD(str(b.level)), E.TD(E.BUTTON('Снять', type = 'button', onclick = 'remove_ban(this);')) )for b in ban_list] #purpose will be applyed later html = E.HTML( E.HEAD( E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"), E.TITLE("Creating board"), E.SCRIPT(type = 'text/javascript', src = '/adminscript.js') #js ), E.BODY( E.DIV(E.CLASS('adminupdiv'), E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')), E.H2(E.CLASS("heading"), "Listing bans"), ), E.TABLE( E.CLASS("boardstable"), E.TR(E.TH('ID'), E.TH('IP'), E.TH('Забанивший'), E.TH('Дата'), E.TH('Уровень'), E.TH('') ), *tablerows ) ) ) return lxml.html.tostring(html)
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
def generate_navigation_board_list(boards): #would be redone categories = {} for b in boards: #if b.hidden = none #should add for hidden boards if b.category in categories: categories[b.category].append((b.address, b.name)) else: categories[b.category] = [((b.address, b.name))] spans = [] iter_list = list(categories.keys()) iter_list.sort() for category in iter_list: #probably another order would be better urls = [] for params in categories[category]: urls.append( E.A( params[0], #the name title = params[1],#bydlocode, better to find another way href = '/' + params[0] + '/', ) ) urls.append('/') urls.pop() if category is None: category = '' urls = [E.CLASS('boardcategory'), category+' ['] + urls + [']'] spans.append(E.SPAN(*urls)) code = EM('nav', E.CLASS('boardlist'), *spans ) return code
def make_short_papers(p_list, count=None): authors_dict = json.load(open("authors.json")) def gen_author_link(a): if a in authors_dict: return "<a href=\"" + authors_dict[a] + "\">" + a + "</a>" else: return a tag_list = [] for paper in p_list[:count]: authors = gen_author_link(paper.authors[0]) for a in paper.authors[1:-1]: authors += ", " + gen_author_link(a) if len(paper.authors) > 1: authors += " and " + gen_author_link(paper.authors[-1]) links = [] for key in paper.links: links += [builder.A(key, href=paper.links[key])] tag_list.append( builder.DIV( builder.H1(paper.title, builder.CLASS("paper-title")), builder.DIV(html.fromstring(authors), builder.CLASS("paper-authors")), builder.DIV(paper.date.strftime("%d %b. %Y"), builder.CLASS("paper-date")), builder.DIV(*links, builder.CLASS("paper-links")), builder.CLASS("paper-container"))) return tag_list
def change_representation_compressed(change: Dict[str, Any], link: str, filepath: str, current_depth: int, max_depth: int) -> Optional[Any]: """ Generator of compressed html markdown. """ change_elements: List[Any] = [ E.B(change["type"]), E.SPAN(" "), E.A(change["name"], href=link), E.B(" changed lines: "), E.SPAN(str(change["changed_lines"])), ] if change["total_lines"]: change_elements.extend( [E.SPAN("/"), E.SPAN(str(change["total_lines"]))]) if change["children"]: change_elements.extend([E.BR()]) child_elements = [] for child in change["children"]: child_element = render_change_as_html(child, filepath, current_depth + 1, max_depth, True) if child_element is not None: child_elements.append(child_element) change_elements.append(E.UL(*child_elements)) return change_elements
def visit_Instance(self, node): """ Create a table row for this Instance and a new file giving it a memory map of its own. """ # If we're writing files, write another one for the instance and # create an HTML link. Otherwise just give it a name. try: relativefile = htmlpathjoin(self.subdir, node.name + self.extension) filename = os.path.join(self.path, relativefile) except TypeError: linkelement = node.name else: obj = type(self)(output=filename) try: obj.offset = node.offset + self.base except TypeError: obj.offset = node.offset obj.inst = node.name obj.breadcrumbs = E.A(self.title, href=htmlpathjoin('..', self.filename)) obj.styledir = htmlpathjoin(self.styledir, '..') obj.execute(node.binding) linkelement = E.A(node.name, href=relativefile) # And provide a table row for the MemoryMap desc = node.description or node.binding.description if isinstance(self.base, int): offset = '0x{:0{}X}'.format(node.offset + self.base, self.address_nibbles) else: offset = '{}+0x{:0{}X}'.format(self.base, node.offset, self.address_nibbles) return E.TR( E.TD(linkelement, CLASS('peripheral')), E.TD(offset, CLASS('paddress')), E.TD('0x{:0{}X}'.format(node.size, self.address_nibbles), CLASS('psize')), E.TD(CLASS('pdesc'), *[E.P(d) for d in desc]))
def _format_gocd(self): u""" Return an Element that links to the GoCD build pipeline. """ if self.gocd_url: return SECTION(E.H2(u"GoCD Release Pipeline"), E.A(self.gocd_url, href=self.gocd_url)) else: return None
def transform_demo(div): div.append(E.BUTTON('Run demo')) demo_dir = op.join(FILEBASE, div.get('demo')) div.set('demo', demo_dir) files = (f for f in os.listdir(demo_dir) if not f.startswith('.')) ul = E.UL(*(E.LI(E.A(f, href=op.join(demo_dir, f))) for f in files)) div.append(ul)
def make_summary_row(test, result): def output(suffix): rel_path = test.url_map[test.url] return urllib.quote(os.path.join(test.name, rel_path) + suffix) if test.enabled: s = ResultSummary(result) return B.TR( B.TD(test.name), B.TD('%d (%d)' % (s.insertions, s.insertion_blocks)), B.TD('%d (%d)' % (s.deletions, s.deletion_blocks)), B.TD(B.A('original', href=output('')), ' ', B.A('benchmark', href=output(READABLE_SUFFIX)), ' ', B.A('result', href=output(RESULT_SUFFIX)), ' ', B.A('diff', href=output(DIFF_SUFFIX))), B.TD(test.notes)) else: return B.TR(B.CLASS('skipped'), B.TD('%s (SKIPPED)' % test.name), B.TD('N/A'), B.TD('N/A'), B.TD('N/A'), B.TD(test.notes))
def write_heading(self, text, bullet=None, autoAnchor=None, anchor=None, level=1): # Use a hierarchy of header tags if docmapping set h = E.H1() if self.pis['docmapping'] == 'yes': if level == 2: h = E.H2() elif level == 3: h = E.H3() elif level >= 4: h = E.H4() if autoAnchor: h.attrib['id'] = autoAnchor if bullet: # Use separate elements for bullet and text a_bullet = E.A(bullet) a_bullet.tail = ' ' if autoAnchor: a_bullet.attrib['href'] = '#' + autoAnchor h.append(a_bullet) if anchor: # Use an anchor link for heading a_text = E.A( text.strip(), href='#' + anchor, ) a_text.attrib["id"] = anchor h.append(a_text) else: # Plain text a_bullet.tail += text else: # Only use one <a> pointing to autoAnchor a = E.A(text) if autoAnchor: a.attrib['href'] = '#' + autoAnchor h.append(a) # Add to body buffer self.buf.append(self._serialize(h))
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')), )
def _generate_project_report_in_html(self, project_name, project_bugs): report = E.BODY( E.H2(E.CLASS("heading"), "%s (%d)" % (project_name, len(project_bugs)))) for bug in project_bugs: bug_link = E.A(bug.title, href=bug.web_link, target='_blank') report.append( E.P("[%s:%s] " % (bug.importance, bug.status), bug_link)) if bug.assignee: report.append( E.P("Assigned to: %s" % (bug.assignee.display_name))) return report
def html_file_section_handler_vanilla(item: Dict[str, Any]) -> Any: filepath = item["file"] file_url = item.get("file_url", filepath) change_elements = [ render_change_as_html(change, filepath, 0, 2) for change in item["changes"] ] file_elements = [ E.H4(E.A(filepath, href=file_url)), E.B("Changes:"), E.UL(*change_elements), ] return E.DIV(*file_elements)
def make_short_posts(p_list): tag_list = [] for post in p_list: tag_list.append( builder.DIV( builder.H1( builder.A(post.title, href=base_url + "posts/" + post.id), builder.CLASS("post-title")), html.fromstring(post.summary), builder.DIV(post.date.strftime("%d %b. %Y, %H:%M"), builder.CLASS("post-date")), builder.CLASS("post-container"))) return tag_list