def test_field_tail(self): replacement = ET.tostring(h.LI( h.SPAN( "+12 3456789", attrs(model='res.company', id=1, type='char', field='phone', expression="edmund")), "whop whop"), encoding="utf-8") self.view_id.save(value=replacement, xpath='/div/div[2]/ul/li[3]') self.eq( ET.fromstring(self.view_id.arch.encode('utf-8')), h.DIV( h.DIV(h.H3("Column 1"), h.UL(h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("Item 1"), h.LI( h.SPAN( "My Company", attrs(model='res.company', id=1, field='name', type='char'))), h.LI(h.SPAN({'t-field': "edmund"}), "whop whop"), ))))
def test_fixup_arch(self): replacement = h.H1("I am the greatest title alive!") result = self.registry('ir.ui.view').replace_arch_section( self.cr, self.uid, self.view_id, '/div/div[1]/h3', replacement) self.eq( result, h.DIV( h.DIV(h.H3("I am the greatest title alive!"), h.UL(h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("Item 1"), h.LI( h.SPAN( "My Company", attrs(model='res.company', id=1, field='name', type='char'))), h.LI( h.SPAN( "+00 00 000 00 0 000", attrs(model='res.company', id=1, field='phone', type='char')))))))
def setUp(self): super(TestViewSaving, self).setUp() self.arch = h.DIV( h.DIV(h.H3("Column 1"), h.UL(h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("Item 1"), h.LI( h.SPAN( "My Company", attrs(model='res.company', id=1, field='name', type='char'))), h.LI( h.SPAN( "+00 00 000 00 0 000", attrs(model='res.company', id=1, field='phone', type='char')))))) self.view_id = self.registry('ir.ui.view').create( self.cr, self.uid, { 'name': "Test View", 'type': 'qweb', 'arch': ET.tostring(self.arch, encoding='utf-8').decode('utf-8') })
def test_save(self): Company = self.env['res.company'] View = self.env['ir.ui.view'] # create a view with an xmlid, like the file import would with self.env.norecompute(): self.view_id = View.create({ 'name': "Test View", 'type': 'qweb', 'arch': ET.tostring(self.arch, encoding='utf-8').decode('utf-8') }) imd = self.env['ir.model.data'].create({ 'module': 'website', 'name': 'test_view', 'model': 'ir.ui.view', 'res_id': self.view_id, }) # the xml_id of the view should not be flagged as 'noupdate' self.assertEqual(self.view_id.model_data_id, imd) self.assertFalse(imd.noupdate) replacement = ET.tostring(h.DIV( h.H3("Column 2"), h.UL( h.LI("wob wob wob"), h.LI(h.SPAN("Acme Corporation", attrs(model='res.company', id=1, field='name', expression="bob", type='char'))), h.LI(h.SPAN("+12 3456789", attrs(model='res.company', id=1, field='phone', expression="edmund", type='char'))), ) ), encoding='utf-8') self.view_id.save(value=replacement, xpath='/div/div[2]') # the xml_id of the view should be flagged as 'noupdate' self.assertTrue(imd.noupdate) company = Company.browse(1) self.assertEqual(company.name, "Acme Corporation") self.assertEqual(company.phone, "+12 3456789") self.eq( ET.fromstring(self.view_id.arch.encode('utf-8')), h.DIV( h.DIV( h.H3("Column 1"), h.UL( h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL( h.LI("wob wob wob"), h.LI(h.SPAN({'t-field': "bob"})), h.LI(h.SPAN({'t-field': "edmund"})) )) ) )
def test_save(self): Company = self.env['res.company'] # create an xmlid for the view imd = self.env['ir.model.data'].create({ 'module': 'website', 'name': 'test_view', 'model': self.view_id._name, 'res_id': self.view_id.id, }) self.assertEqual(self.view_id.model_data_id, imd) self.assertFalse(imd.noupdate) replacement = ET.tostring(h.DIV( h.H3("Column 2"), h.UL( h.LI("wob wob wob"), h.LI( h.SPAN( "Acme Corporation", attrs(model='res.company', id=1, field='name', expression="bob", type='char'))), h.LI( h.SPAN( "+12 3456789", attrs(model='res.company', id=1, field='phone', expression="edmund", type='char'))), )), encoding='unicode') self.view_id.save(value=replacement, xpath='/div/div[2]') # the xml_id of the view should be flagged as 'noupdate' self.assertTrue(imd.noupdate) company = Company.browse(1) self.assertEqual(company.name, "Acme Corporation") self.assertEqual(company.phone, "+12 3456789") self.eq( ET.fromstring(self.view_id.arch), h.DIV( h.DIV(h.H3("Column 1"), h.UL(h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL(h.LI("wob wob wob"), h.LI(h.SPAN({'t-field': "bob"})), h.LI(h.SPAN({'t-field': "edmund"}))))))
def buildHTML(self, *args): if self.title: self.addTags(E.H3(self.title)) self.addText(self.text) self.addAttributes() return super(Form, self).buildHTML(*args)
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 body(self): """The BODY of the html document""" reports = E.OL(id='reports') code = self.code() for i, (state_html, state_problem) in enumerate(self.states(), 1): reports.append( E.LI( E.ATTR(id="state{0}".format(i)), E.E.header( E.DIV( E.CLASS('error'), state_problem, ), E.DIV( E.CLASS('report-count'), E.H3('Report'), str(i), ), ), E.DIV( E.CLASS('body'), E.DIV( E.CLASS('source'), deepcopy(code), ), state_html, ), ), ) return E.BODY( self.header(), reports, self.footer(), )
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 test_save(self): Company = self.registry('res.company') View = self.registry('ir.ui.view') replacement = ET.tostring(h.DIV( h.H3("Column 2"), h.UL( h.LI("wob wob wob"), h.LI( h.SPAN( "Acme Corporation", attrs(model='res.company', id=1, field='name', expression="bob", type='char'))), h.LI( h.SPAN( "+12 3456789", attrs(model='res.company', id=1, field='phone', expression="edmund", type='char'))), )), encoding='utf-8') View.save(self.cr, self.uid, res_id=self.view_id, value=replacement, xpath='/div/div[2]') company = Company.browse(self.cr, self.uid, 1) self.assertEqual(company.name, "Acme Corporation") self.assertEqual(company.phone, "+12 3456789") self.eq( ET.fromstring( View.browse(self.cr, self.uid, self.view_id).arch.encode('utf-8')), h.DIV( h.DIV(h.H3("Column 1"), h.UL(h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL(h.LI("wob wob wob"), h.LI(h.SPAN({'t-field': "bob"})), h.LI(h.SPAN({'t-field': "edmund"}))))))
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('GCC Python Plugin', ), E.DIV( E.ATTR(id='filename'), E.SPAN( E.CLASS('label'), 'Filename: ', ), self.data['filename'], ), ), E.E.nav( E.ATTR(id='nav'), E.DIV( E.ATTR(id='function'), E.H3('Function'), self.data['function']['name'], ), E.DIV( E.ATTR(id='report-pagination'), E.H3('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='bug-toggle'), E.IMG(src='images/bug.png', ), E.H3('Bug'), ' [count]', ), E.DIV( E.ATTR(id='prev'), E.IMG(src='images/arrow-180.png', ), ), E.DIV( E.ATTR(id='next'), E.IMG(src='images/arrow.png', ), ), ), )
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 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 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 = [] unique_version_changes = set(version_deltas(base, new)) sorted_version_changes = sorted(unique_version_changes, key=lambda delta: delta.base or delta.new) for delta in sorted_version_changes: diff_items.append(E.LI(*diff_link(delta))) 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 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 process_robot_output(robot_output): root = etree.parse(robot_output).getroot() print("one time") for suite in root.xpath("//suite[@source]"): suite_id = suite.get("id", "") suite_container = E.DIV(E.CLASS("suite span12"), id=suite_id) suite_container.append(E.H3(E.CLASS("span12"), suite.get("name", ""))) tests = suite.xpath(".//test") for i, test in enumerate(tests): test_id = "{0}".format(test.get("id", "")) test_container = E.DIV(E.CLASS("span6")) test_name = test.get("name", "") test_container.append(E.H4(test_name)) doc = "".join([ doc.text for doc in test.xpath("./doc") if doc.text is not None ]) test_container.append(E.P(doc)) status_tags = test.xpath("./status") status = "" if status_tags != []: status = status_tags[0].get("status") if status == "PASS": btn_class = "btn-success" text_class = "text-success" elif status == "FAIL": btn_class = "btn-danger" text_class = "text-error" btn_id = test_id + "-btn" test_container.append( E.BUTTON(status, E.CLASS("btn " + btn_class), type="button", id=btn_id)) btn = test_container.get_element_by_id(btn_id) btn.set("data-target", "#" + test_id) btn.set("data-toggle", "collapse") messages = E.DIV(E.CLASS("collapse " + text_class), id=test_id) for kw in test.xpath("./kw"): for msg in kw.xpath(".//msg"): messages.append(format_msg(msg, status=status)) if kw.get( "name") == "Selenium2Library.Wait Until Page Contains": text_check = [ "text" in doc.text for doc in kw.xpath(".//doc") ] if text_check: text_match = " ".join( [arg.text for arg in kw.xpath(".//arg")]) messages.append( E.P("Checking the page contains: " + text_match)) test_container.append(messages) # Two columns per row if i % 2 == 0 or i == len(tests): row = E.DIV(E.CLASS("row"), test_container) suite_container.append(row) else: row.append(test_container) content_area.append(E.DIV(E.CLASS("row"), suite_container)) # ScrollSpy might be nice # report.body.set("data-spy","scroll") # report.body.set("data-target", ".suite") report.append(E.SCRIPT(src="http://code.jquery.com/jquery-1.9.1.min.js")) report.append( E.SCRIPT( src= "http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js" # noqa: E501 ))
def test_save(self): Company = self.env['res.company'] # create an xmlid for the view imd = self.env['ir.model.data'].create({ 'module': 'website', 'name': 'test_view', 'model': self.view_id._name, 'res_id': self.view_id.id, }) self.assertEqual(self.view_id.model_data_id, imd) self.assertFalse(imd.noupdate) replacement = ET.tostring(h.DIV( h.H3("Column 2"), h.UL( h.LI("wob wob wob"), h.LI( h.SPAN( "Acme Corporation", attrs(model='res.company', id=1, field='name', expression="bob", type='char'))), h.LI( h.SPAN( "+12 3456789", attrs(model='res.company', id=1, field='phone', expression="edmund", type='char'))), )), encoding='unicode') self.view_id.with_context(website_id=1).save(value=replacement, xpath='/div/div[2]') self.assertFalse( imd.noupdate, "view's xml_id shouldn't be set to 'noupdate' in a website context as `save` method will COW" ) # remove newly created COW view so next `save()`` wont be redirected to COW view self.env['website'].with_context(website_id=1).viewref( self.view_id.key).unlink() self.view_id.save(value=replacement, xpath='/div/div[2]') # the xml_id of the view should be flagged as 'noupdate' self.assertTrue(imd.noupdate) company = Company.browse(1) self.assertEqual(company.name, "Acme Corporation") self.assertEqual(company.phone, "+12 3456789") self.eq( ET.fromstring(self.view_id.arch), h.DIV( h.DIV(h.H3("Column 1"), h.UL(h.LI("Item 1"), h.LI("Item 2"), h.LI("Item 3"))), h.DIV( h.H3("Column 2"), h.UL(h.LI("wob wob wob"), h.LI(h.SPAN({'t-field': "bob"})), h.LI(h.SPAN({'t-field': "edmund"}))))))
def pr_table(token, jira_url, delta): u""" Return an Element that renders all changes in `delta` as a table listing merged PRs.abs Arguments: token: The github token to access the github API with. jira_url: The base url of the JIRA instance to link JIRA tickets to. delta (VersionDelta): The AMIs to compare. """ version = delta.new or delta.base match = re.search(u"github.com/(?P<org>[^/]*)/(?P<repo>.*)", version.repo) api = GitHubAPI(match.group(u'org'), match.group(u'repo'), token) try: prs = api.get_pr_range(delta.base.sha, delta.new.sha) change_details = E.TABLE( E.CLASS(u"wrapped"), E.TBODY( E.TR( E.TH(u"Merged By"), E.TH(u"Author"), E.TH(u"Title"), E.TH(u"PR"), E.TH(u"JIRA"), E.TH(u"Release Notes?"), ), *[ E.TR( E.TD( E.A( pull_request.merged_by.login, href=pull_request.merged_by.html_url, )), E.TD( E.A( pull_request.user.login, href=pull_request.user.html_url, )), E.TD(pull_request.title), E.TD( E.A( str(pull_request.number), href=pull_request.html_url, )), E.TD( format_jira_references(jira_url, pull_request.body)), E.TD(u""), ) for pull_request in sorted( prs, key=lambda pr: pr.merged_by.login) ])) except Exception: # pylint: disable=broad-except LOGGER.exception(u'Unable to get PRs for %r', delta) change_details = E.P("Unable to list changes") return SECTION( E.H3(u"Changes for {} (".format(delta.app), E.A(GITHUB_PREFIX.sub(u'', version.repo), href=version.repo), ")"), E.P(E.STRONG(u"Before: "), E.A(delta.base.sha, href=format_commit_url(delta.base))), E.P(E.STRONG(u"After: "), E.A(delta.new.sha, href=format_commit_url(delta.new))), change_details, )
def doc(self, action='', id=None): if action == 'list' and id is None: list_tmpl = self._env.get_template('doc/list.html') return list_tmpl.render(title='Document List', documents=self._docs.get_list()) d = Document(self._redis, id=id) if not d.content: raise cherrypy.HTTPError(404, "No such document") if action == 'raw': raw_tmpl = self._env.get_template('doc/raw.html') return raw_tmpl.render(title='Raw Document', doc=d) elif action == 'struc': struc_tmpl = self._env.get_template('doc/struc.html') elements = self._render(d.id) # TODO migrate this to jinja or keep lxml? if elements: html = [] for start, end, sel in elements: if len(d.content[start:end].strip()) > 0: cclass = b.CLASS('s' + str(start) + 'e' + str(end)) if sel is not None and sel.docid == d.id: node = b.E(NAMESPACE[sel.ref], cclass) node.text = d.content[start:end] html.append(node) else: html.append(b.PRE(d.content[start:end], cclass)) return struc_tmpl.render(title="Document Semantic", doc=d, struc=lxhtml.tostring(b.DIV(*html))) else: return struc_tmpl.render(title="Document Semantic", doc=d, struc='Nothing here jet') elif action == 'view': view_tmpl = self._env.get_template('doc/view.html') elements = self._render(d.id) if elements: content_html = [] meta_html = [] metalist = {} for start, end, sel in elements: if len(d.content[start:end]) > 0: if sel is not None and sel.docid == d.id: node = b.E(NAMESPACE[sel.ref]) node.text = d.content[start:end].strip() content_html.append(node) else: content_html.append( b.PRE(d.content[start:end].strip())) for pre in ('person', 'place', 'date', 'event'): metalist[pre] = set() #for sel, sub, pre, obj, start, end in self._triples: # if sel is not None and sel.docid == d.id: # metalist[pre].add(obj) for pre in ('person', 'place', 'date', 'event'): metali = [] for m in sorted(metalist[pre]): metali.append(b.LI(m)) meta_html.append(b.H3(pre)) meta_html.append(b.UL(*metali)) content = lxhtml.tostring(b.DIV(*content_html)) meta = lxhtml.tostring(b.DIV(*meta_html)) return view_tmpl.render(title='Document View', doc=d, content=content, meta=meta) else: return view_tmpl.render(title='Document View', doc=d, content='Nothing to render', meta='') else: raise cherrypy.HTTPError(400, 'No such action')
def create_table(): """HTML generation by lxml.html tree.""" divisions = ['All', 'E', 'CMS', 'T', 'A', 'AE', 'PPD', 'AD/APC', 'TD', 'CD', 'ND', 'LBN', 'Other'] pubtypes = ['All', 'PUB', 'THESIS', 'CONF', 'TM', 'FN', 'SLIDES', 'POSTER'] dates = [YEAR_2, YEAR_1, YEAR, MONTH_2, MONTH_1, MONTH] years = [YEAR_2, YEAR_1, YEAR] months = [MONTH_2, MONTH_1, MONTH] # This is a doctype work around for a lxml.etree bug doctype_wa = etree.parse(StringIO('''<!DOCTYPE html>\n<html>\n</html>''')) head_tag = E.HEAD( E.META({'charset': 'utf-8'}), E.TITLE("FERMILAB RESEARCH AT A GLANCE"), E.STYLE( {'type': 'text/css'}, "td {text-align: right;}", " td.l {text-align: left;padding: 7px;}", " a.t {display: block;}" ) ) body = E.BODY(E.P( E.A("Fermilab Technical Publications", href="http://ccd.fnal.gov/techpubs/fermilab_spires.html") )) tag_h3 = E.H3("FERMILAB RESEARCH AT A GLANCE") tag_p = E.P("Glossary at end.") tag_p_and_i = E.P(E.I("Updated: " + DATE_TIME_STAMP)) body.append(tag_h3) body.append(tag_p) body.append(tag_p_and_i) table = E.TABLE() tag_tr_td = E.TR(E.TD, E.TD("Date")) for division in divisions: if division == 'A': division = 'AT' tag_tr_td.append(E.TD(division)) table.append(tag_tr_td) pub_table_row = E.TR() for pubtype in pubtypes: pub_table_row.append(E.TD(pubtype)) pub_type_datelist = E.TD() year_list = E.UL() month_list = E.UL() for year in years: year_list.append(E.LI(year)) for month in months: month_list.append(E.LI(month)) pub_type_datelist.append(year_list) pub_type_datelist.append(month_list) pub_type_datelist.append(E.UL()) pub_table_row.append(pub_type_datelist) pub_type_datelist = E.TD() for division in divisions: tdg = E.TD() list_of_searches = E.UL() for date in dates: if division == 'All': division = '' if pubtype == 'All': pubtype = '' search = 'find r fermilab ' + pubtype if division == 'Other': for good_division in divisions[1:len(divisions)-1]: if good_division == 'AD/APC': search += ' not (r AD or APC)' else: search += ' not r ' + good_division elif division == 'AD/APC': search = 'find r fermilab ' + pubtype + \ ' and (r AD or APC)' else: search += ' ' + division search += ' and de ' + date search = re.sub(r'\s+', ' ', search) result = perform_request_search(p=search, cc="Fermilab") result = len(result) if result == 0: hit_number = E.LI() else: link = search.replace(' ', '+') link = 'https://inspirehep.net/search?cc=Fermilab&p=' + link link += '&rg=100&sf=earliestdate' hit_number = E.LI(E.A({'class': 't'}, str(result), href=link)) list_of_searches.append(hit_number) if date == YEAR or date == MONTH: tdg.append(list_of_searches) list_of_searches = E.UL() pub_table_row.append(tdg) table.append(pub_table_row) pub_table_row = E.TR() glos = E.H4('Glossary') table2 = E.TABLE() glos_tr_td = E.TR( E.TD({'class': 'l'}, "E: Experimental papers"), E.TD({'class': 'l'}, "PPD: Particle Physics Division papers") ) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "T: Particle Physics Division \ Theoretical Physics Department papers"), E.TD({'class': 'l'}, "AD/APC: Accelerator Division \ and Accelerator Physics Center papers")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "AT: Fermilab Center for Particle \ Astrophysics theoretical papers"), E.TD({'class': 'l'}, "TD: Technical Division papers")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "AE: Fermilab Center for Particle \ Astrophysics experimental papers"), E.TD({'class': 'l'}, "CD: Computing Sector papers")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "ND: Neutrino Division papers"), E.TD({'class': 'l'}, "LBN: Long Baseline Neutrino \ Sector papers")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, " "), E.TD({'class': 'l'}, " ")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, " "), E.TD({'class': 'l'}, " ")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, " "), E.TD({'class': 'l'}, " ")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "PUB: Paper intended for \ publication in a journal"), E.TD({'class': 'l'}, "FN: Physics note - short paper not \ fitting the other categories")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "CONF: Paper written as part of a \ conference"), E.TD({'class': 'l'}, "SLIDES: Slides presented at a \ conference or lecture")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "THESIS: Ph.D. thesis based on \ work done at Fermilab"), E.TD({'class': 'l'}, "POSTER: Poster presented at a \ conference")) table2.append(glos_tr_td) glos_tr_td = E.TR(E.TD({'class': 'l'}, "TM: Technical memo"), E.TD({'class': 'l'}, "")) table2.append(glos_tr_td) body.append(table) body.append(glos) body.append(table2) doctype_wa.getroot().append(head_tag) doctype_wa.getroot().append(body) out = lxml.html.tostring(doctype_wa, encoding='UTF-8', pretty_print=True, method='html').rstrip('\n') return out
## this way of doing it seems not to work whereas the above "dumber" way does; quite mysterious #finalthreadclasses = {} #for thread in list(threads): # finalthreadclasses[thread] = threadclasses[thread] # for other_thread in list(threads): # if thread != other_thread: # finalthreadclasses[thread] -= threadclasses[other_thread] #print(yaml.dump(threadclasses, default_flow_style=False)) from lxml.html import builder as E report_page = E.HTML( E.HEAD(E.TITLE('BSCS Threads Analysis')), E.BODY( E.H1('BSCS Threads Analysis'), E.H3('Common classes'), E.TABLE(*[ E.TR( E.TD(cls.hours), *[ E.TD(lxml.html.fromstring(req)) for req in cls.urlled_alternatives ]) for cls in commons ], border="1"), *[ E.DIV( E.H3(thread), E.TABLE(*[ E.TR( E.TD(cls.hours), *[ E.TD(lxml.html.fromstring(req)) for req in cls.urlled_alternatives