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 mailgen(): d = DataCmp().cmp_result() news_topic = {'hot_news': '热点新闻', 'hot_inform': '最新公告', 'hot_msg': '最新简讯'} def test(): for key, value in d.items(): yield E.H2(news_topic[key]) if any(value): for i in value: yield lxml.html.fromstring( '<a href="http://news.gdut.edu.cn/viewarticle.aspx?articleid={id}">{title}[{loc}]</a><br></br>' .format_map(i)) else: del news_topic[key] yield E.P('无') yield E.P('Sent at {}'.format( time.strftime("%y-%m-%d %H:%M", time.localtime()))) sub = [i for i in test()] if not any(news_topic): sub = [E.H2('今日无事可做')] html = E.HTML( E.HEAD( E.META(charset='UTF-8'), E.META(name='viewport', content='width=device-width, initial-scale=1.0'), E.TITLE("GDUTNews Stream")), E.BODY(*sub)) 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 _format_status(self): u""" Return an Element that renders the current release status. """ return SECTION( E.H2(u"Current Status: {}".format(self.status.value)) )
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 compare_tables(body, old, new): body.append(builder.H2("Table Comparisons")) for name in sorted(old.tables): body.append(builder.H3(name)) if name in new.tables: compare_table(body, name, old, new) else: body.append(builder.UL(builder.LI(builder.B("TABLE LOST"))))
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 _format_diffs(self): u""" Return an Element that contains formatted links to a diff between all AMI pairs. """ return SECTION( E.H2(u"Code Diffs"), *[ diff(old, new) for (old, new) in self.ami_pairs ] )
def _format_changes(self): u""" Return an Element that contains tables with all merged PRs for each repository that changed. """ deltas = [version_deltas(old, new) for (old, new) in self.ami_pairs] tables = [ pr_table(self.github_token, self.jira_url, delta) for delta in set().union(*deltas) if delta.new.sha != delta.base.sha ] return SECTION(E.H2(u"Detailed Changes"), *tables)
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 test(): for key, value in d.items(): yield E.H2(news_topic[key]) if any(value): for i in value: yield lxml.html.fromstring( '<a href="http://news.gdut.edu.cn/viewarticle.aspx?articleid={id}">{title}[{loc}]</a><br></br>' .format_map(i)) else: del news_topic[key] yield E.P('无') yield E.P('Sent at {}'.format( time.strftime("%y-%m-%d %H:%M", time.localtime())))
def board_creation_menu(): #here is the html board creation menu html = E.HTML( E.HEAD( E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"), E.TITLE("Creating board") ), E.BODY( E.DIV(E.CLASS('adminupdiv'), E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')), E.H2(E.CLASS("heading"), "Create new board"), ), E.DIV(E.CLASS("boardcreateform"), E.FORM( E.INPUT(type = 'hidden', name = 'action', value = 'create'), E.INPUT(type = 'hidden', name = 'instance', value = 'board'), E.TABLE( E.TR(E.TD('Address'), E.TD(E.INPUT(type = 'text', name = 'address', value = '')) ), E.TR(E.TD('Tablename'), E.TD(E.INPUT(type = 'text', name = 'tablename', value = '')) ), E.TR(E.TD('Name'), E.TD(E.INPUT(type = 'text', name = 'name', value = '')) ), E.TR(E.TD('Fullname'), E.TD(E.INPUT(type = 'text', name = 'fullname', value = '')) ), E.TR(E.TD('Description'), E.TD(E.INPUT(type = 'text', name = 'description', value = '')) ), E.TR(E.TD('Pics number'), E.TD(E.INPUT(type = 'number', name = 'picsnum', value = '', min = '0', max = '10')) ), E.TR(E.TD('Bumplimit'), E.TD(E.INPUT(type = 'number', name = 'bumplimit', value = '', min = '0')) ), E.TR(E.TD('Max threads'), E.TD(E.INPUT(type = 'number', name = 'maxthreads', value = '', min = '-1')) ), E.TR(E.TD(E.INPUT(type='checkbox', name='delposts', value='1', checked='checked'), 'Удаление постов', colspan='2', style='text-align:center;')), E.TR(E.TD(E.INPUT(type='checkbox', name='delopposts', value='1', checked='checked'), 'Удаление тредов', colspan='2', style='text-align:center;')), ), E.INPUT(type = 'submit', value = 'Create'), method='POST', action='/admin/' ) ) ) ) return lxml.html.tostring(html)
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 _format_amis(self): u""" Return an Element that contains formatted description of the deployed AMIs. """ return SECTION( E.H2(u"Final AMIs"), E.UL(*[ E. LI(u"{ami.environment}-{ami.deployment}-{ami.play}: {ami.ami_id}" .format(ami=ami)) for _, ami in self.ami_pairs if ami is not None ], style=u"list-style-type: square"), )
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 _parse_chapter(self, url): doc = self.fetch(url) title, = doc.find_class('entry-title') yield E.H2(title.text_content) content, = doc.find_class('entry-content') # Remove next/previous chapter links # The only other link is an Urban Dictionary definition of "trigger warnings" for link in content.xpath('.//a'): if link.text_content().strip() in ('Last Chapter', 'Next Chapter', 'End'): # Remove parent <p> tag completely parent = link.getparent() if parent.getparent() is not None: parent.drop_tree() yield from content
def main_page_gen(): html = E.HTML( E.HEAD( E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"), E.TITLE("Administration and moderation") ), E.BODY( E.DIV( E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')), E.H2(E.CLASS("heading"), "Admin menu"), ), E.P(E.CLASS("loginmessage"), "You are logged in"), E.DIV(E.CLASS('adminmainmenu'), E.A("create board", href = '?action=create&instance=board'), E.A("manage boards", href = '?action=list&list=boards&purpose=admin'), E.A("manage bans", href = '?action=list&list=bans&purpose=moderator'), E.A("manage users", href = '?action=list&list=users&purpose=admin'), E.A("change password", href = '?action=change&instance=password'), ) ) ) return lxml.html.tostring(html)
def _parse_chapter(self, url): self.info('Parsing chapter: %s', url) doc = self.fetch(url) title, = doc.xpath('//title/text()') title = title.split(' | ')[-1].strip() yield E.H1(title) for tag in doc.get_element_by_id('content'): # Start of section if tag.tag == 'h3': yield E.H2(tag.text_content().strip()) # Section content elif 'grafset' in tag.classes: yield from tag # End note elif 'endnote' in tag.classes: # Change tag into a <blockquote class="endnote"> tag.tag = 'blockquote' yield tag
def manifest_html(self): """ This is manifest.html the human useable form of the manifest.xml special object to list needed criteria or return a manifest given a set of criteria """ web_page = \ E.HTML( E.HEAD( E.TITLE(_("%s A/I Webserver -- " "Maninfest Criteria Test") % _DISTRIBUTION) ), E.BODY( E.H1(_("Welcome to the %s A/I " "webserver") % _DISTRIBUTION), E.H2(_("Manifest criteria tester")), E.P(_("To test a system's criteria, all " "criteria listed are necessary. The " "format used should be:"), E.BR(), E.TT("criteria1=value1;criteria2=value2"), E.BR(), _("For example:"), E.BR(), E.TT("arch=sun4u;mac=EEE0C0FFEE00;" "ipv4=172020025012;" "manufacturer=sun microsystems") ), E.H1(_("Criteria:")), E.P(str(list(AIdb.getCriteria( self.AISQL.getQueue(), strip=True)))), E.FORM(E.INPUT(type="text", name="postData"), E.INPUT(type="submit"), action="manifest.xml", method="POST" ) ) ) return lxml.etree.tostring(web_page, pretty_print=True)
def compare_docs(body, old, new, verbose): body.append(builder.H2("Document Comparisons")) for name in sorted(old.docs): body.append(builder.H3(f"{name} Docs")) new_docs = new.docs[name] if not new_docs.docs: body.append(builder.UL(builder.LI(builder.B(LOST)))) else: old_docs = old.docs[name] items = [] for key in old_docs.docs: old_id, old_title, old_xml = old_docs.docs[key] if key not in new_docs.docs: items.append(builder.I(builder.LI(old_title))) else: diffs = diff_xml(old_xml, new_docs.docs[key][2], verbose) if diffs is not None: title = builder.B(old_title) items.append(builder.LI(title, diffs)) if not items: body.append(builder.P(CHECK, OK)) else: body.append(builder.UL(*items))
def __make_tree(self): """Build a tree using lxml.html.builder and our subtrees""" # create div with "container" class div = E.DIV(E.CLASS("container")) # append header with title div.append(E.H2(self.__title)) # next, iterate through subtrees appending each tree to div for subtree in self.__subtrees: div.append(subtree.get_html()) # Connect div to body body = E.BODY(div) # attach body to html self.__htmltree = E.HTML( E.HEAD( E.TITLE(self.__title) ), body )
"Databases": "Databases (Custom)", "Design": "Design (Custom)", "General": "General (Custom)", "Integration": "Integration (Custom)", "Misc1": "Misc 1 (Custom)", "Misc2": "Misc 2 (Custom)", "Revisions": "Revisions (Custom)", "Shapes": "Shapes (Custom)", "Structure": "Structure (Custom)" } css = """\ img { border: 1px black solid } * { font-family: Arial; } """ paths = glob.glob("d:/Inetpub/wwwroot/images/xmetal/*.jpg") content = B.CENTER(B.H1("XMetaL CDR Icons")) for path in sorted(paths): if "xmetal_cdr" not in path and "Standard" not in path: name = path.replace("\\", "/").split("/")[-1][:-4] content.append(B.H2(names.get(name, name))) content.append(B.IMG(src="/images/xmetal/%s.jpg" % name)) page = B.HTML( B.HEAD( B.TITLE("XMetaL CDR Icons"), B.STYLE(css) ), B.BODY(content) ) xml = etree.tostring(page, pretty_print=True, encoding="unicode") print(f"Content-type: text/html\n\n{xml}")
# print(" " + termin["s_termin_typ"]) # print(" " + termin["s_termin_von"] + " - " + termin["s_termin_bis"]) counter += 1 # Alle Module eingeladen, hoffe ich htmlfile = E.HTML( E.HEAD(E.LINK(rel="stylesheet", href="plan.css", type="text/css"), E.SCRIPT(src="plan.js", type="text/javascript"), E.META(charset="utf-8"), E.TITLE("Test")), E.BODY(E.H1("Stundenplan"))) document = htmlfile.find("body") for studiengang in studiengaenge: print(studiengang) document.append(E.H2(studiengang, name=studiengang)) container = E.DIV(E.CLASS("plancontainer")) # E.DIV(E.CLASS("plancontainer")) for stunde in range(59): style = "top: " + str(2 + (100 / 60) * stunde) + "%; " mnt = str(int((stunde + 2) % 4 * 15)) if mnt == "0": mnt = "00" container.append( E.DIV(E.CLASS("stunde"), E.B(str(int(stunde / 4 + 7.5)) + ":" + mnt), style=style)) plan = {}