def format(trait, objs, *args, **kwargs) -> Htmlish: # TODO would be nice to have spinboard imported here for type checking.. res = T.div(cls='pinboard') title = trait.title(objs) link = trait.link(objs) res.add(T.div(T.a(title, href=link))) with adhoc_html('pinboard', cb=lambda children: res.add(*children)): with T.table(): for _, obj in objs: if not isempty(obj.description): with T.tr(): with T.td(colspan=3): T.span(obj.description, cls='description') with T.tr(): # TODO wtf is min?? with T.td(cls='min'): T.a(f'{fdate(obj.when)}', href=obj.blink, cls='permalink timestamp') with T.td(cls='min'): text('by ') trait.user_link(user=obj.user) with T.td(): for t in obj.ntags: trait.tag_link(tag=t, user=obj.user) # TODO userstats return res
def test_many_argument_strings(self): c = Converter('Man', file='links.man') c.translate() text = c.html.render() text = c.change_special_symbols(text) doc = tags.html(lang='en') doc = add_head(doc) doc_body = tags.body() row = tags.div(cls='row') row = add_row(row, 'GREP(1)', 'User Commands', 'GREP(1)') doc_body.add(row) with doc_body: paragraph = tags.p() paragraph += (tags.a('the bug-reporting address', href='mailto:[email protected]')) paragraph += tags.br() paragraph += (tags.a( 'email archive', href='http://lists.gnu.org/mailman/listinfo/bug-grep')) paragraph += tags.br() paragraph += tags.br() row = tags.div(cls='row') row = add_row(row, 'GNU grep 3.1', '2017-06-21', 'GREP(1)') doc_body.add(row) doc.add(doc_body) self.assertEqual(doc.render(), text)
def get_html_forms(self, datatset_name_form=True): """generates html forms for all the metadata elements associated with this logical file type :param datatset_name_form If True then a form for editing dataset_name (title) attribute is included """ root_div = div() with root_div: if datatset_name_form: self._get_dataset_name_form() keywords_div = div(cls="col-sm-12 content-block", id="filetype-keywords") action = "/hsapi/_internal/{0}/{1}/add-file-keyword-metadata/" action = action.format(self.logical_file.__class__.__name__, self.logical_file.id) delete_action = "/hsapi/_internal/{0}/{1}/delete-file-keyword-metadata/" delete_action = delete_action.format( self.logical_file.__class__.__name__, self.logical_file.id) with keywords_div: legend("Keywords") with form(id="id-keywords-filetype", action=action, method="post", enctype="multipart/form-data"): input(id="id-delete-keyword-filetype-action", type="hidden", value=delete_action) with div(cls="tags"): with div(id="add-keyword-wrapper", cls="input-group"): input(id="txt-keyword-filetype", cls="form-control", placeholder="keyword", type="text", name="keywords") with span(cls="input-group-btn"): a("Add", id="btn-add-keyword-filetype", cls="btn btn-success", type="button") with ul(id="lst-tags-filetype", cls="custom-well tag-list"): for kw in self.keywords: with li(cls="tag"): span(kw) with a(): span( cls= "glyphicon glyphicon-remove-circle icon-remove" ) p("Duplicate. Keywords not added.", id="id-keywords-filetype-msg", cls="text-danger small", style="display: none;") self.get_extra_metadata_html_form() self.get_temporal_coverage_html_form() return root_div
def writeContent(self): self.writeln('<h1>Using Webware with Dominate</h1>') self.writeln( '<p>Dominate is a Python library that can be used in Webware' ' applications to generate HTML programmatically.</p>') if not dominate: self.writeln( f'<p>Please install <a href="{self.homepage}">Dominate</a>' ' in order to view this demo.</p>') return content = div(id='content') with content: h2('Hello World!') with table(cls="NiceTable").add(tbody()): tr(th('Demo table', colspan=3)) r = tr() r += td('One') r.add(td('Two')) with r: td('Three') para = p(__pretty=False) with para: text('This content has been produced with ') a('Dominate', href=self.homepage) text(' programmatically.') self.write(content)
def generateStatsHTML(graph,statsFilePath = "stats.html",postStatsFilePath = "postStats.html"): #Generates the Stats HTML section firstLevel = checkFirstLevel(graph) softwareLabelNum = queryVersionNum(graph) softwareLabelNumList = addQueryToList(softwareLabelNum) stats = document(title="FSL Viewer") #Creates initial html page (stats) stats += h1("Sample FSL Viewer") stats += ul(li(a("Stats", href="stats.html")), li("-"),li(a("Post Stats", href = "postStats.html"))) stats += h2("Stats") stats += hr() stats += h3("Analysis Methods") if askSpm(graph) == True: #Checks if SPM was used stats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/)." % softwareLabelNumList[1]) elif askFsl(graph) == True: #Checks if FSL was used fslFeatVersion = queryFslFeatVersion(graph) stats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." % (fslFeatVersion[0], softwareLabelNumList[1])) stats += hr() stats += h3("Design Matrix") designMatrixLocation = queryDesignMatrixLocation(graph) stats += a(img(src = designMatrixLocation[1], style = "border:5px solid black", border = 0), href = designMatrixLocation[0]) #Adds design matrix image (as a link) to html page statsFile = open(statsFilePath, "x") print(stats, file = statsFile) #Prints html page to a file statsFile.close()
def get_html_string(style: Style) -> document: """Creates a HTML string for generating the summary file.""" utc_time = datetime.datetime.utcfromtimestamp(style.timestamp) style_attributes = [ ('code', style.code), ('number', style.number), ('precinct', style.precinct), ('built at', f'{utc_time.strftime("%Y-%m-%d %H:%M:%S")}'), ('built from number of ballots', style.build_from_count), ] script_abs_path = os.path.abspath('assets/copy_to_clipboard.js') version = utils.show_version() doc = document(title='Audit Engine version: ' + version) with doc.head: link( rel='stylesheet', href= 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css', integrity= "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T", crossorigin="anonymous", ) script(type='text/javascript', src=script_abs_path) with doc: with div(cls='container'): with div(cls='jumbotron'): h1('Audit Engine: {version} - style summary'.format( version=version)) build_time = datetime.datetime.now(datetime.timezone.utc) p(f'Summary built at: {build_time.strftime("%Y-%m-%d %H:%M:%S")}', cls='lead') with div(cls='col pl-3 mt-1') as style_details_column: for style_key, style_value in style_attributes: style_details_column.add( StyleSummary.get_details_row( style_key, str(style_value))) h3('Contests', cls='mb-0 mt-1') with div(cls='col pl-3') as contest_details_column: for style_contest in style.contests: contest_details_column.add( StyleSummary.get_contest_details(style_contest)) h3('Built from ballots', cls='mb-3 mt-1') with div(cls='col pl-3'): with div(cls='row flex-wrap') as images_column: for ballot_id in style.build_from_ballots: images = StyleSummary.get_ballot_images_path( ballot_id, style.code) images_column.add( StyleSummary.get_ballot_images_div( ballot_id, images)) h3('Style weighted images', cls='mb-3 mt-1') with div(): for image in StyleSummary.get_style_images(style.code): a(img(src=os.path.basename(image), cls='img-thumbnail', alt='File not found'), href=image) return doc
def visit_Link(self, node): if self._in_dropdown: return tags.a(node.text, href=node.get_url(), _class='dropdown-item') else: return tags.a(node.text, href=node.get_url(), _class='nav-item nav-link')
def output_intro(self): """Output introductory section""" tags.h3("Algorithm Support comparison results") tags.p("This module compares Java Card " "algorithm support between the cards.") tags.p("To learn more about testing methodology, visit:") tags.a("https://www.fi.muni.cz/~xsvenda/jcalgtest/table.html", href="https://www.fi.muni.cz/~xsvenda/jcalgtest/table.html") tags.h4("Overview:") tags.p( "The cards match in " + str(len(self.matching)) + " algorithms." ) tags.p( "There are " + str(len(self.missing)) + " algorithms with missing results for either card." ) tags.p( "There are " + str(len(self.support_mismatch)) + " algorithms with different results." ) mem_mismatch = len(self.memory_mismatch) + len(self.reset_mismatch) \ + len(self.deselect_mismatch) tags.p( "There are " + str(mem_mismatch) + " algorithms with suspicious differences in memory allocation." )
def __init__(self, vid): super().__init__(f"{vid.name} of {vid.series.name}") self.on_ready_scriptage.append("$('#content').fitVids()") with self.content: quality = flask.request.args.get('quality', 'auto') if quality == 'auto': vhtml = vid.html altdisp = altqual = '720p' else: tags.div(f"({quality} Version)", id="ver") vmatch = re.match(r'(.*src=")(\S+)(".*)', vid.html) vhtml = f"{vmatch.group(1)}{vmatch.group(2)}" vhtml = f"{vhtml}&quality={quality}{vmatch.group(3)}" altqual = 'auto' altdisp = 'Hi Res' tags.div( raw(vhtml), tags.a(tags.button("Play Audio"), href=url_for('play_audio', series=vid.series.name, video=vid.name)), tags.a(tags.button("Download Audio"), href=url_for('play_audio', series=vid.series.name, video=vid.name), download=vid.name), tags.a(tags.button(f"Play {altdisp} Video"), href=url_for('play_latest', series=vid.series.name, video=vid.name, quality=altqual)), tags.a(tags.button("Download Video"), href=vid.dlink), )
def output_intro(self): """Output introductory section""" tags.h3("Algorithm Performance comparison results") tags.p("This module compares Java Card " "algorithm performance between the cards.") tags.p("To learn more about testing methodology, visit") tags.a( "https://www.fi.muni.cz/~xsvenda/jcalgtest/knowledgebase.html", href="https://www.fi.muni.cz/~xsvenda/jcalgtest/knowledgebase.html" ) tags.h4("Overview:") tags.p( "The cards' performance match in " + str(len(self.matching)) + " algorithms." ) tags.p( "There are " + str(len(self.missing)) + " algorithms with missing results for either card." ) tags.p( "There are " + str(len(self.mismatch)) + " algorithms with different results." ) tags.p( "There are " + str(len(self.erroneous)) + " algorithms that failed with different error message." ) tags.p( str(len(self.skipped)) + " algorithms were omitted due to being too fast in general." )
def _contact(self): contact = self._toml['contact'] assert isinstance(contact, dict) with tr() as row: label = contact['label'] assert isinstance(label, str) td(label, rowspan=2, colspan=1, class_name='label') contact_points = contact['value'] assert isinstance(contact_points, dict) email = contact_points['email'] assert isinstance(email, str) with td(colspan=3, class_name='value'): a(email, href=f'mailto:{email}', target='_blank') yield row with tr() as row: url = contact_points['url'] assert isinstance(url, str) with td(colspan=3, class_name='value'): a(url, href=url, target='_blank') yield row
def convert_new_in_html(cmd_args, new, html_file): """ Convert one new to HTML format """ with html_file: with tag.div(): tag.h2(new.get('title')) tag.p(new.get('date')) tag.br() tag.a("Read the full article", href=new.get('link')) tag.br() tag.br() if cmd_args.date: for num, link in enumerate(new.get('img_link'), 1): tag.a(f"Image link № {num}", href=link) tag.br() else: for num, link in enumerate(new.get('img_link')): tag.img(src=link, alt=new.get('img_title')[num]) tag.br() tag.p(new.get('text')) tag.br() return html_file
def get_extra_metadata_html_form(self): def get_add_keyvalue_button(): add_key_value_btn = a(cls="btn btn-success", type="button", data_toggle="modal", data_target="#add-keyvalue-filetype-modal", style="margin-bottom:20px;") with add_key_value_btn: with span(cls="glyphicon glyphicon-plus"): span("Add Key/Value", cls="button-label") return add_key_value_btn if self.extra_metadata: root_div_extra = div(cls="col-xs-12", id="filetype-extra-metadata") with root_div_extra: legend('Extended Metadata') get_add_keyvalue_button() with table(cls="table table-striped funding-agencies-table", style="width: 100%"): with tbody(): with tr(cls="header-row"): th("Key") th("Value") th("Edit/Remove") counter = 0 for k, v in self.extra_metadata.iteritems(): counter += 1 with tr(data_key=k): td(k) td(v) with td(): a(data_toggle="modal", data_placement="auto", title="Edit", cls= "glyphicon glyphicon-pencil icon-button icon-blue", data_target="#edit-keyvalue-filetype-modal" "-{}".format(counter)) a(data_toggle="modal", data_placement="auto", title="Remove", cls= "glyphicon glyphicon-trash icon-button btn-remove", data_target= "#delete-keyvalue-filetype-modal" "-{}".format(counter)) self._get_add_key_value_modal_form() self._get_edit_key_value_modal_forms() self._get_delete_key_value_modal_forms() return root_div_extra else: root_div_extra = div(cls="row", id="filetype-extra-metadata") with root_div_extra: with div(cls="col-lg-12 content-block"): legend('Extended Metadata') get_add_keyvalue_button() self._get_add_key_value_modal_form() return root_div_extra
def generateMainHTML(graph,mainFilePath = "Main.html", statsFilePath = "stats.html", postStatsFilePath = "postStats.html"): #Generates the main HTML page main = document(title="FSL Viewer") main += h1("Sample FSL Viewer") main += ul(li(a("Stats", href="stats.html")), li("-"),li(a("Post Stats", href = "postStats.html"))) mainFile = open(mainFilePath, "x") print(main, file = mainFile) mainFile.close()
def user_summary_for(rtype, storages, output_path: Path): ustats = {} def reg(user, query, stats): if user not in ustats: ustats[user] = {} ustats[user][query] = stats with ProcessPoolExecutor() as pp: digests = pp.map(get_digest, [s.path for s in storages]) for s, digest in zip(storages, digests): everything = flatten([ch for ch in digest.changes.values()]) for user, items in group_by_key(everything, key=lambda x: x.user).items(): reg(user, s.name, len(items)) now = datetime.now() doc = dominate.document( title= f'axol tags summary for {[s.name for s in storages]}, rendered at {fdate(now)}' ) with doc.head: T.style(STYLE) raw_script(JS) # TODO necessary? # TODO FIXME can't inline due to some utf shit sortable_js = Path(__file__).absolute().parent / 'js' / 'sorttable.js' T.script(src=str(sortable_js)) ft = FormatTrait.for_(rtype) with doc.body: with T.table(cls='sortable'): emitted_head = False for user, stats in sorted(ustats.items(), key=lambda x: (-len(x[1]), x)): if not emitted_head: with T.thead(): T.td('user') for q, _ in stats.items(): T.td(q) emitted_head = True with T.tr(): T.td(ft.user_link(user)) for q, st in stats.items(): with T.td(sorttable_customkey=str(st)): # TODO I guess unclear which tag to choose though. T.a( q, href=f'summary/{q}.html' ) # TODO link to source in index? or on pinboard maybe # TODO also project onto user's tags straight away T.sup( str(st) if st < 5 else T.b( T.font(str(st), color='red'))) # TODO css output_path.write_text(str(doc)) logger.info('Dumped user summary to %s', output_path)
def visit_Navbar(self, node): # create a navbar id that is somewhat fixed, but do not leak any # information about memory contents to the outside node_id = self.id or sha1(str(id(node)).encode()).hexdigest() root = tags.nav() if self.html5 else tags.div(role='navigation') root_class = 'navbar navbar-inverse' if node.navbar_inverse else 'navbar navbar-default' if node.navbar_fixed == 'top': root_class += ' navbar-fixed-top' elif node.navbar_fixed == 'bottom': root_class += ' navbar-fixed-bottom' root['class'] = root_class cont = root.add(tags.div(_class='container-fluid')) # collapse button header = cont.add(tags.div(_class='navbar-header')) btn = header.add(tags.button()) btn['type'] = 'button' btn['class'] = 'navbar-toggle collapsed' btn['data-toggle'] = 'collapse' btn['data-target'] = '#' + node_id btn['aria-expanded'] = 'false' btn['aria-controls'] = 'navbar' btn.add(tags.span('Toggle navigation', _class='sr-only')) btn.add(tags.span(_class='icon-bar')) btn.add(tags.span(_class='icon-bar')) btn.add(tags.span(_class='icon-bar')) # add a custom _class `navbar-logo` to adjust logo image if node.logo_filename is not None: logo_a = tags.a(_class='navbar-left navbar-logo') logo_a.add(tags.img(src=node.get_logo_file_url())) header.add(logo_a) # title may also have a 'get_url()' method, in which case we render # a brand-link if node.title is not None: if hasattr(node.title, 'get_url'): header.add( tags.a(node.title.text, _class='navbar-brand', href=node.title.get_url())) else: header.add(tags.span(node.title, _class='navbar-brand')) bar = cont.add( tags.div( _class='navbar-collapse collapse', id=node_id, )) for item in node.items: bar.add(self.visit(item)) return root
def report_asciinema(self, asciinema_link, title='', **kwargs): """ Section creates a jumbotron to house an asciinema :param str asciinema_link: Link to asciinema. Could be http/s or local files :param str title: Set the title of the asciinema. If set, it will create its own section. If not, it will append to previous section :param tuple alert: Kwarg Create a dismissable alert box. First value of tuple is the color, and the second is the message :param bool section: Kwarg Set to True to append the cards section to the preceding section. Default is false :raises ObjectNotInitiated: Raises exception when the correct flags are not set in ReportWriter Example: >>> r += report.report_asciinema('https://asciinema.org/a/XvEb7StzQ3C1BAAlvn9CDvqLR', title='asciinema') """ logging.warning( 'This method only works with asciinema links because of the way\n \ browsers enforce CORS') # checks to see if asciinema has been intialized if not self.asciinema: raise rng.ObjectNotInitiated( 'To integrate asciinema, set asciinema=True in ReportWriter') # TODO: write a check here that validates the asciinema url # hacky way to bypass the CORS problem try: url = get('%s.json' % asciinema_link).url except: logging.warning('Need internet to get the proper url for %s' % asciinema_link) # controls if sticky or not if 'section' in kwargs: style = rng.CSSControl.sticky_section_css else: style = rng.CSSControl.not_sticky_section with tag.div( _class= "jumbotron jumbomargin container reportng-acsiinema-class", style=style) as a: if title != '': tag.h1(title, id="%s" % rng.HelperFunctions.id_with_random(5, title)) # create dismissable alert box if 'alert' in kwargs: rng.HelperFunctions.make_alert(kwargs.get('alert')) with tag.div(_class="container", style="text-align: center;" + style): raw('<asciinema-player src="%s"></asciinema-player>' % url) tag.script(src=rng.JSCSS.asciinema_js) tag.a('Asciinema link', _class= "btn btn-secondary row justify-content-center btn-sm", role="button", href=asciinema_link, target="_blank") return str(a)
def visit_Link(self, node): if self._in_dropdown: return tags.a(node.text, href=node.get_url(), _class='dropdown-item') item = tags.li(_class='nav-item') item.add(tags.a(node.text, href=node.get_url(), _class='nav-link')) return item
def visit_Link(self, node): if hasattr(node, '_in_dropdown'): item = tags.a(node.text, href=node.get_url(), _class="dropdown-item") else: item = tags.li(_class="nav-item") item.add(tags.a(node.text, href=node.get_url(), _class="nav-link")) return item
def text_or_ptr(s): if s.startswith("0x7"): sp = t.span() sp.add(t.a(s, href=f"#{s}")) sp.add(" (") sp.add(t.a("M", href=f"#mapentry-{s}")) sp.add(")") return sp else: return t.span(s)
def add_email_or_url(self, line): self.add_paragraph() r = re.findall(LINKS_RE, line) data = r[0] text = data[3] if data[3] else data[2] address = data[1] if data[0] == '.URL': self.paragraph.add(tags.a(text, href=address)) else: self.paragraph.add(tags.a(text, href='mailto:{}'.format(address)))
def generateHtml(): with open(path.join(current_dir, '../changelog/', 'storage.json'), 'r') as f: data = json.load(f)[::-1] doc = document(title='Changelog - lkellar.org') articles = [] with doc.head: tags.link(rel='stylesheet', href='style.css') tags.meta(charset="UTF-8") tags.meta(name="description", content="A log of all changes made on lkellar.org") tags.meta(name="viewport", content="width=device-width, initial-scale=1") tags.link(rel="alternate", title="Changelog Feed", type="application/json", href="https://lkellar.org/changelog/feed.json") with doc: with tags.nav().add(tags.ol()): with tags.li(): tags.a("Home", href="../") tags.li("Changelog") with tags.main(): tags.h1('Changelog') for entry in data: tags.hr() article_content = tags.article() with article_content: tags.h2( f'{entry["title"]} - {entry["date"].split("T")[0]}', id=f'{entry["title"]} - {entry["date"]}'.replace( ' ', ''.lower())) list_content = tags.ul() with list_content: for line in entry['items']: line = urls.sub(r'<a href="\2">\1</a>', line) tags.li(raw(line)) articles.append((f'{entry["title"]} - {entry["date"]}'.replace( ' ', ''.lower()), list_content.render(), entry["date"], entry['title'])) with open(path.join(current_dir, '../changelog/', 'index.html'), 'w') as f: f.write(doc.render()) generateFeed(articles)
def make_html(pixdir, route_name, results): title = "Pictures from %s" % route_name document = dominate.document(title=title) with document.head: meta(charset="UTF-8") style(""" table { page-break-inside:auto; border-spacing:3px; padding:3px; } table { margin-left:auto; margin-right:auto; } table, td, th, tr { border:1px solid green; } th { background-color: green; color: white; } th.tiny { width:3%; } th.narrow { width:47%; } th.wide { width:50%; } tr { page-break-inside:avoid; page-break-after:auto; } tr.center { margin-left:auto; margin-right:auto; } tr.alt { background-color: #f0f0f0; } caption { background-color: #c0c040; font-size: 16px; \ font-family: "Courier New"; } body { font-size: 16px; } @media print { body { font-size: 8px; font-family: "Courier New" } caption { font-size: 10px } a { text-decoration: none; font-style: italic; font-weight: bold} th { background-color: white; color: black; } } """) with document.body: with table(): caption(route_name) tr(th("Name"), th("Description"), th("Imagefile")) for time, filename, gc, tp in results: pathname = os.path.join(pixdir, filename) gcname, gcdesc = map(str, gc[1:]) gclink = "http://coord.info/%s" % quote(gcname) with tr(): td(a(gcname, href=gclink)) td(gcdesc) td(a(filename, href=quote(pathname))) print >> open("make_html.html", "w"), document
def create_mainpage_html(local, url_list, path, web_title): _html = dmtags.html(style="background-color:#fcfbeb;") _head, _body = _html.add(dmtags.head(dmtags.title(web_title)), dmtags.body(cls="main_page")) with _head: dmtags.comment("The page is genarated on {} by Ein".format( time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) dmtags.meta(charset="utf-8", name="viewport", content="width=device-width, initial-scale=1") dmtags.link( href="https://fonts.googleapis.com/css?family=Noto+Sans+JP:500", rel="stylesheet") dmtags.link( href= "https://cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.min.css", rel="stylesheet") dmtags.link(href="https://rawcdn.githack.com/c892836a/python_for_fun/" "b2fa53022b0ae5a26d6f140c38b860a210c21040/css/custom.css", rel="stylesheet") dmtags.link( href="https://lh3.googleusercontent.com/S__tM5EYqZDFLuv1uPG" + "mlZTTLLyNAbUvljzDH8-S0Pxq2nA9fnFF3SwU0w0wF8PlMu_hv3WhLMdlFodKbQ=s0", rel="shortcut icon", type="image/vnd.microsoft.icon") main_div = _body.add( dmtags.div( style= "text-align:center; font-family: 'Noto Sans JP', sans-serif; font-size:36px;" )) with main_div: _p1 = dmtags.p(style="color:#470000;") for url in url_list: _p2 = dmtags.p(style="font-size:20px;") with _p2: dmtags.a(url[0], href="{}".format(url[1])) with _p1: text("{}".format(web_title)) # create html file if local: os.chdir(path) os.chdir(os.pardir) with open("{}.html".format(web_title), "w", encoding='utf8') as f: f.write("<!DOCTYPE html>\n") f.write(_html.render()) else: with open("{}\\{}.html".format(path, web_title), "w", encoding='utf8') as f: f.write("<!DOCTYPE html>\n") f.write(_html.render())
def add_nulls(self): with self.doc: dtg.h2("Null tests", id='nulls') lst = dtg.ul() sorter = self.s_null.sortTracers() # All cross-correlations xcorrs = np.array(["%d_%d" % (s[0], s[1]) for s in sorter]) # Unique cross-correlations xc_un = np.unique(xcorrs) cls_null = self.s_null.mean.vector err_null = np.sqrt(self.s_null.precision.getCovarianceMatrix()) # Loop over unique correlations for comb in xc_un: t1, t2 = comb.split('_') t1 = int(t1) t2 = int(t2) # Find all power spectra for this pair of tracers ind_spectra = np.where(xcorrs == comb)[0] # Plot title title = self.s_null.tracers[t1].name[2:-1] title += " x " title += self.s_null.tracers[t2].name[2:-1] # Plot file fname = self.get_output('plots') + '/cls_null_' fname += self.s_null.tracers[t1].name[2:-1] fname += "_x_" fname += self.s_null.tracers[t2].name[2:-1] fname += ".png" print(fname) # Plot all power spectra plt.figure() plt.title(title, fontsize=15) for ind in ind_spectra: typ = sorter[ind][2].decode() ndx = sorter[ind][4] plt.errorbar(self.ells[self.msk], (cls_null[ndx] / err_null[ndx])[self.msk], yerr=np.ones(len(ndx))[self.msk], fmt=self.cols_typ[typ] + '-', label=typ) plt.xlabel('$\\ell$', fontsize=15) plt.ylabel('$C_\\ell/\\sigma_\\ell$', fontsize=15) plt.legend() plt.savefig(fname, bbox_index='tight') plt.close() lst += dtg.li(dtg.a(title, href=fname)) dtg.div(dtg.a('Back to TOC', href='#contents'))
def get_keywords_html(self): """generates html for viewing keywords""" keywords_div = div() if self.keywords: keywords_div = div(cls="col-sm-12 content-block") with keywords_div: legend('Keywords') with div(cls="tags"): with ul(id="list-keywords-file-type", cls="tag-list custom-well"): for kw in self.keywords: with li(): a(kw, cls="tag") return keywords_div
def _pagerlink(self, page, text): """ Create a URL that links to another page using url_for(). Parameters: page Number of the page that the link points to text Text to be printed in the A-HREF tag """ link_params = {} # Use the instance kwargs from Page.__init__ as URL parameters link_params.update(self.kwargs) # Add keyword arguments from pager() to the link as parameters link_params.update(self.pager_kwargs) link_params[self.page_param] = page # Get the URL generator if self._url_generator is not None: url_generator = self._url_generator else: from ckan.lib.helpers import pager_url # Create the URL to load a certain page link_url = url_generator(**link_params) if self.onclick: # create link with onclick action for AJAX # Create the URL to load the page area part of a certain page (AJAX # updates) link_params[self.partial_param] = 1 partial_url = url_generator(**link_params) try: # if '%s' is used in the 'onclick' parameter # (backwards compatibility) onclick_action = self.onclick % (partial_url, ) except TypeError: onclick_action = Template(self.onclick).safe_substitute({ u"partial_url": partial_url, u"page": page }) return tags.a(text, href=link_url, onclick=onclick_action, **self.link_attr) else: # return static link return tags.a(text, href=link_url, **self.link_attr)
def get_html(self): """Generates html for displaying all metadata elements associated with this logical file. Subclass must override to include additional html for additional metadata it supports. """ root_div = div() dataset_name_div = div() if self.logical_file.dataset_name: with dataset_name_div: with table(cls='custom-table'): with tbody(): with tr(): th("Title", cls="text-muted") td(self.logical_file.dataset_name) keywords_div = div() if self.keywords: keywords_div = div(cls="col-sm-12 content-block") with keywords_div: legend('Keywords') with div(cls="tags"): with ul(id="list-keywords-file-type", cls="tag-list custom-well"): for kw in self.keywords: with li(): a(kw, cls="tag") extra_metadata_div = div() if self.extra_metadata: extra_metadata_div = div(cls="col-sm-12 content-block") with extra_metadata_div: legend('Extended Metadata') with table(cls="table table-striped funding-agencies-table", style="width: 100%"): with tbody(): with tr(cls="header-row"): th("Key") th("Value") for k, v in self.extra_metadata.iteritems(): with tr(data_key=k): td(k) td(v) if self.logical_file.dataset_name: root_div.add(dataset_name_div) if self.keywords: root_div.add(keywords_div) if self.extra_metadata: root_div.add(extra_metadata_div) return root_div.render()
def visit_View(self, node): if hasattr(node, '_in_dropdown'): item = tags.a(node.text, href=node.get_url(), title=node.text, _class="dropdown-item") else: item = tags.li(_class="nav-item") item.add(tags.a(node.text, href=node.get_url(), _class="nav-link")) if node.active: item['class'] += ' active' return item
def _block(profession, toml): with div(id=profession): with div(class_name='content'): with div(id=f'{profession}-logo'): for style, token in toml['logo']['tokens']: span(raw(token), class_name=style) with div(class_name='text'): with div(class_name='biography'): for paragraph in toml['biography']['paragraphs']: p(paragraph) with div(class_name='links'): for link in toml['links']: a(link['label'], href=link['url'], target='_blank') p(link['summary'])
def regular(type, text): if type in ['footnote', 'footnote_recurrence']: with tags.a("(%s)" % text.strip()): tags.attr(cls="ptr") else: if "\n" in text: print "New:", text if u"°" in text: href = re.sub(u"°", "", text) href = re.sub(u"־", " ", href) with tags.span(tags.a(text, href="#"+href)): tags.attr(cls=type) else: with tags.span(text): tags.attr(cls=type)
def regular(type, text): if type in ['footnote', 'footnote_recurrence']: with tags.a("(%s)" % text.strip()): tags.attr(cls="ptr") else: if "\n" in text: print "New:", text if u"°" in text: href = re.sub(u"°", "", text) href = re.sub(u"־", " ", href) with tags.span(tags.a(text, href="#" + href)): tags.attr(cls=type) else: with tags.span(text): tags.attr(cls=type)
def visit_Subgroup(self, node): link = tags.li(cls="nav-item dropdown") with link: a = tags.a(node.title, cls="nav-link dropdown-toggle", href=".", id="dropdown{}".format(node.title)) a.attributes["data-toggle"] = "dropdown" div = tags.div(cls="dropdown-menu") div.attributes["aria-labelledby"] = "dropdown{}".format(node.title) with div: for item in node.items: tags.a(item.text, cls="dropdown-item", href=item.get_url()) return link
def visit_View(self, node): item = tags.li() item.add(tags.a(node.text, href=node.get_url(), title=node.text)) if node.active: item['class'] = 'active' return item
def visit_LogIn(self, node): item = tags.li() inner = item.add(tags.a(href=node.get_url(), _class="nav-image")) inner.add(tags.img(src=url_for("static", filename="sso_login.png"))) if node.active: item['class'] = 'active' return item
def render(self, posts_per_page=25): pages_count = (len(self.rendered_items) + posts_per_page - 1) // posts_per_page page_names = ["%d.html" % i for i in range(pages_count)] nav_section = T.nav( *[T.a(str(i), href=page_names[i], target=_PAGE_FRAME) for i in range(pages_count)] ) index = T.html( T.head( T.meta(charset='utf-8'), stylesheet(_STYLE_CSS), stylesheet(_NAVBAR_CSS), T.script(src=_JQUERY_URL), inline_script_from(get_resource(Path(_SELECTED_JS))) ), T.body( nav_section, T.iframe(name=_PAGE_FRAME, src=page_names[0] if pages_count > 0 else 'none', width='100%', height='100%', style='border:none') ) ) self.pages['index.html'] = index for page_index in range(pages_count): page_items = self.rendered_items[page_index * posts_per_page: (page_index + 1) * posts_per_page] chunk_html = T.html( T.head(stylesheet('page.css')), T.body( T.div(*page_items, id=ID_CONTAINER) ) ) self.pages[page_names[page_index]] = chunk_html
def makeHtml(path, fileName, sitename, authorname, usecss, usejs): doc = dominate.document(title=sitename) with doc.head: if (usecss.lower() == "y"): link(rel='stylesheet', href='style.css') if (usejs.lower() == "y"): script(type='text/javascript', src='script.js') with meta(): attr(author=authorname) with doc: with div(id='header').add(ol()): for i in ['home', 'about', 'contact']: li(a(i.title(), href='/%s.html' % i)) with div(): attr(cls='body') p('Lorem ipsum..') if not os.path.exists("./" + path): os.makedirs("./" + path) f = open("./" + path + "/" + fileName, 'w+') f.write(str(doc)) f.close() if (usejs.lower() == "y"): if not os.path.exists("./" + sitename + "/js"): os.makedirs("./" + sitename + "/js") if (usecss.lower() == "y"): if not os.path.exists("./" + sitename + "/css"): os.makedirs("./" + sitename + "/css")
def visit_View(self, node): kwargs = {} if node.active: kwargs['_class'] = 'active' return tags.a(node.text, href=node.get_url(), title=node.text, **kwargs)
def list_notices(buf): """Render the list of all notices to the file-like `buf`.""" title = u'HTTPolice notices' document = dominate.document(title=title) _common_meta(document) with document.body: H.attr(_class=u'notices-list') with document: H.h1(title) H.p(u'This is the list of all notices produced by ', H.a(u'HTTPolice', href=homepage, target='_self'), u' version ', version, u'.') H.p(u'See also the ', H.a(u'HTTPolice manual', href=u'index.html', target='_self'), u'.') placeholder = Placeholder() for id_ in sorted(notice.all_notices.keys()): _notice_to_html(notice.all_notices[id_], placeholder, with_anchor=True) buf.write(document.render().encode('utf-8'))
def __init__(self, text='', href=None, **kwargs): self.kclass_dep = KClassDep('navbar-header') self.kclass_default = KClassDefault() if href is not None: super().__init__(a(text, _class='navbar-brand', href=href), \ **self.update_kwargs(kwargs)) else: self.kclass_default.append('navbar-brand') super().__init__(text, **self.update_kwargs(kwargs))
def _render_known(obj): """Render an instance of one of the :data:`httpolice.known.classes`.""" text = printable(str(obj)) cite = known.citation(obj) if cite: with H.a(text, href=cite.url): title = known.title(obj, with_citation=True) if title: H.attr(title=title) else: text_node(text)
def visit_NavbarBrand(self, node): item = tags.a(href=node.get_url(), title=node.text, _class='navbar-brand') item['class'] = 'navbar-brand' if node.kwargs.get('class_'): item['class'] += (' ' + self.kwargs['class_']) if node.img: item.add(tags.img(src=node.img, _class='d-inline-block align-top')) if node.text: node.text = ' ' + node.text if node.text: item.add_raw_string(node.text) return item
def _render_known(obj): cls = type(obj).__name__ text = printable(six.text_type(obj)) cite = known.citation(obj) if cite: elem = H.a(text, _class=cls, href=cite.url, target=u'_blank') else: elem = H.span(text, _class=cls) title = known.title(obj, with_citation=True) if title: with elem: H.attr(title=title)
def visit_Navbar(self, node): # create a navbar id that is somewhat fixed, but do not leak any # information about memory contents to the outside node_id = self.id or sha1(str(id(node)).encode()).hexdigest() root = tags.nav() if self.html5 else tags.div(role='navigation') root['class'] = 'navbar navbar-default' cont = root.add(tags.div(_class='container-fluid')) # collapse button header = cont.add(tags.div(_class='navbar-header')) btn = header.add(tags.button()) btn['type'] = 'button' btn['class'] = 'navbar-toggle collapsed' btn['data-toggle'] = 'collapse' btn['data-target'] = '#' + node_id btn['aria-expanded'] = 'false' btn['aria-controls'] = 'navbar' btn.add(tags.span('Toggle navigation', _class='sr-only')) btn.add(tags.span(_class='icon-bar')) btn.add(tags.span(_class='icon-bar')) btn.add(tags.span(_class='icon-bar')) # title may also have a 'get_url()' method, in which case we render # a brand-link if node.title is not None: if hasattr(node.title, 'get_url'): header.add(tags.a(node.title.text, _class='navbar-brand', href=node.title.get_url())) else: header.add(tags.span(node.title, _class='navbar-brand')) bar = cont.add(tags.div( _class='navbar-collapse collapse', id=node_id, )) bar_list = bar.add(tags.ul(_class='nav navbar-nav')) bar_list_right = bar.add(tags.ul(_class='nav navbar-nav navbar-right')) to_right = False for item in node.items: if isinstance(item, SeparatorAlign): to_right = True continue if not to_right: bar_list.add(self.visit(item)) else: bar_list_right.add(self.visit(item)) return root
def get_html(self): """overrides the base class function""" html_string = super(RefTimeseriesFileMetaData, self).get_html() if self.abstract: abstract_div = div(cls="content-block") with abstract_div: legend("Abstract") p(self.abstract) html_string += abstract_div.render() if self.file_version: file_ver_div = div(cls="content-block") with file_ver_div: legend("File Version") p(self.file_version) html_string += file_ver_div.render() if self.symbol: symbol_div = div(cls="content-block") with symbol_div: legend("Symbol") if self.symbol.startswith('http'): with p(): a(self.symbol, href=self.symbol, target="_blank") else: p(self.symbol) html_string += symbol_div.render() if self.temporal_coverage: html_string += self.temporal_coverage.get_html() if self.spatial_coverage: html_string += self.spatial_coverage.get_html() html_string += self.get_ts_series_html().render() html_string += self.get_json_file_data_html().render() template = Template(html_string) context = Context({}) return template.render(context)
def visit_Navbar(self, node): # create a navbar id that is somewhat fixed, but do not leak any # information about memory contents to the outside node_id = self.id or sha1(str(id(node)).encode()).hexdigest() root = tags.nav(_class='navbar') if self.html5 else tags.div(role='navigation', _class='navbar') if node.kwargs.get('class_'): root['class'] += (' ' + node.kwargs['class_']) if node.kwargs.get('id'): root['id'] = node.kwargs['id'] # title may also have a 'get_url()' method, in which case we render # a brand-link if node.title is not None: if hasattr(node.title, 'img'): root.add(self.visit(node.title)) elif hasattr(node.title, 'get_url'): root.add(tags.a(node.title.text, _class='navbar-brand', href=node.title.get_url())) else: root.add(tags.span(node.title, _class='navbar-brand')) # collapse button if node.kwargs.get('responsive') in (None, True): btn = root.add(tags.button()) btn['type'] = 'button' btn['class'] = 'navbar-toggler navbar-toggler-right' btn['data-toggle'] = 'collapse' btn['data-target'] = '#' + node_id btn['aria-expanded'] = 'false' btn['aria-controls'] = 'navbar' btn['aria-label'] = 'Toggle navigation' btn.add(tags.span(_class='navbar-toggler-icon')) bar = root.add(tags.div( _class='collapse navbar-collapse', id=node_id, )) item_list = bar.add(tags.div(_class='navbar-nav mr-auto')) item_list_right = bar.add(tags.div(_class='navbar-nav')) for item in node.items: if item.kwargs.get('align') == 'right': item_list_right.add(self.visit(item)) else: item_list.add(self.visit(item)) return root
def visit_View(self, node): item = tags.a(href=node.get_url(), title=node.text, _class='nav-item nav-link') if node.kwargs.get('icon'): item.add(tags.span(_class='fas fa-{}'.format(node.kwargs.get('icon')))) node.text = ' ' + node.text item.add_raw_string(node.text) if node.kwargs.get('class_'): item['class'] += (' ' + node.kwargs['class_']) if node.active: item['class'] += ' active' return item
def visit_Navbar(self, node): # create a navbar id that is somewhat fixed, but do not leak any # information about memory contents to the outside node_id = self.id or sha1(str(id(node)).encode()).hexdigest() root = tags.nav() if self.html5 else tags.div(role="navigation") root["class"] = "navbar navbar-default" cont = root.add(tags.div(_class="container-fluid")) # collapse button header = cont.add(tags.div(_class="navbar-header")) btn = header.add(tags.button()) btn["type"] = "button" btn["class"] = "navbar-toggle collapsed" btn["data-toggle"] = "collapse" btn["data-target"] = "#" + node_id btn["aria-expanded"] = "false" btn["aria-controls"] = "navbar" btn.add(tags.span("Toggle navigation", _class="sr-only")) btn.add(tags.span(_class="icon-bar")) btn.add(tags.span(_class="icon-bar")) btn.add(tags.span(_class="icon-bar")) # title may also have a 'get_url()' method, in which case we render # a brand-link if node.title is not None: if hasattr(node.title, "get_url"): header.add(tags.a(node.title.text, _class="navbar-brand", href=node.title.get_url())) else: header.add(tags.span(node.title, _class="navbar-brand")) bar = cont.add(tags.div(_class="navbar-collapse collapse", id=node_id)) bar_list = bar.add(tags.ul(_class="nav navbar-nav")) for item in node.items: bar_list.add(self.visit(item)) return root
def visit_Subgroup(self, node): if not self._in_dropdown: li = tags.li(_class="dropdown") if node.active: li["class"] = "active" a = li.add(tags.a(node.title, href="#", _class="dropdown-toggle")) a["data-toggle"] = "dropdown" a["role"] = "button" a["aria-haspopup"] = "true" a["aria-expanded"] = "false" a.add(tags.span(_class="caret")) ul = li.add(tags.ul(_class="dropdown-menu")) self._in_dropdown = True for item in node.items: ul.add(self.visit(item)) self._in_dropdown = False return li else: raise RuntimeError("Cannot render nested Subgroups")
def visit_Subgroup(self, node): if not self._in_dropdown: div = tags.div(_class='nav-item dropdown') if node.active: div['class'] += ' active' a = div.add(tags.a(node.title, href='#', _class='nav-link dropdown-toggle')) a['data-toggle'] = 'dropdown' a['role'] = 'button' a['aria-haspopup'] = 'true' a['aria-expanded'] = 'false' menu = div.add(tags.div(_class='dropdown-menu')) self._in_dropdown = True for item in node.items: menu.add(self.visit(item)) self._in_dropdown = False return div else: raise RuntimeError('Cannot render nested Subgroups')
def visit_Subgroup(self, node): if not self._in_dropdown: li = tags.li(_class='dropdown') if node.active: li['class'] = 'active' a = li.add(tags.a(node.title, href='#', _class='dropdown-toggle')) a['data-toggle'] = 'dropdown' a['role'] = 'button' a['aria-haspopup'] = 'true' a['aria-expanded'] = 'false' a.add(tags.span(_class='caret')) ul = li.add(tags.ul(_class='dropdown-menu')) self._in_dropdown = True for item in node.items: ul.add(self.visit(item)) self._in_dropdown = False return li else: raise RuntimeError('Cannot render nested Subgroups')
def visit_Link(self, node): item = tags.li() item.add(tags.a(node.text, href=node.get_url())) return item
def _cite_to_html(cite, _): with H.cite(__inline=True): H.a(cite.title, href=cite.url, target=u'_blank', __inline=True)
def fix_links(html_docs_l): # fix outbound links print "Fixing links" for (doc) in html_docs_l: for (child) in doc.body.children[0].children: if 'definition' in child.attributes.get('class', ()): href = "" try: href = child.children[0].attributes.get("href") except AttributeError as e: pass # it's a link - try to update it if href: # first, strip it of weird chars try: href = clean_name(href) updated = False if update_values_for_href(child, href): updated = True else: if href[0] in (u"ה", u"ו", u"ש", u"ב", u"כ", u"ל", u"מ"): updated = update_values_for_href(child, href[1:]) if not updated: # failed to update - it's not a real link... update_href_no_link(child) except Exception as e: pass print e, "Exception of HREF update", href #TODO - investigate why it happens? (it's a single corner case, I think) def sorter(html_doc): if html_doc.name in [u"ערכים כלליים",]: return "FIRST" if html_doc.name in [u"נספחות",]: return u"תתתתתתתתתת" #last else: return html_doc.name # update sections menu for (doc) in html_docs_l: letters_l = [] # content_menu = doc.body.children[0].children[1].children[0].children[0].children[-1].children[0].children[1] content_menu = doc.body.children[0].children[1].children[0].children[1].children[-1] assert content_menu['class'] == 'dropdown-menu dropdown-menu-left scrollable-menu' with content_menu: with tags.li(): tags.a(u"אודות", href="index.html") with tags.li(): tags.a(u"הקדמות", href="opening_intros.html") with tags.li(): tags.a(u"הסכמות", href="opening_haskamot.html") with tags.li(): tags.a(u"קיצורים", href="opening_abbrev.html") with tags.li(): tags.a(u"סימנים", href="opening_signs.html") # if you add more entries here, please update add_menu_to_apriory_htmls(..) with tags.li(): tags.attr(cls="divider") sorted_html_docs_l = sorted(html_docs_l, key=sorter) for (html_doc) in sorted_html_docs_l: # Only if this a 'high' heading, and not just a letter - include it in the TOC if html_doc.name != "NEW_LETTER": with tags.li(): tags.a(html_doc.name, href=str(html_doc.index)+".html") if doc.section == html_doc.section: tags.attr(cls="active") else: # it's a letter - if it's related to me, save it if doc.section == html_doc.section: letters_l.append(html_doc) with doc.body.children[-1]: assert doc.body.children[-1]['class'] == 'container-fluid' with tags.ul(): tags.attr(cls="pagination") for (html_doc) in letters_l: tags.li(tags.a(html_doc.letter, href=str(html_doc.index)+".html")) return html_docs_l
def _cite_to_html(cite, _): with H.cite(): H.a(cite.title, href=cite.url)
def _cite_to_html(cite, _): with H.cite(): H.a(cite.title, href=cite.url, target=u'_blank')
def visit_LinkTab(self, node): item = tags.li() item.add(tags.a(node.text, href=node.get_url(), target="_blank")) return item
def generatePostStatsHTML(graph,statsFilePath = "stats.html",postStatsFilePath = "postStats.html"): #Generates Post-Stats page voxelWise = checkHeightThreshold(graph) clusterWise = checkExtentThreshold(graph) softwareLabelNum = queryVersionNum(graph) softwareLabelNumList = addQueryToList(softwareLabelNum) statisticType = queryStatisticType(graph) statisticType = statisticImage(statisticType[0]) statisticTypeString = statisticImageString(statisticType) contrastName = queryContrastName(graph) statisticMapImage = queryExcursionSetMap(graph) postStats = document(title="FSL Viewer") #Creates initial HTML page (Post Stats) postStats += h1("Sample FSL Viewer") postStats += ul(li(a("Stats", href="stats.html")), li("-"),li(a("Post Stats", href = "postStats.html"))) postStats += h2("Post-stats") postStats += hr() postStats += h3("Analysis Methods") if voxelWise == True: #If main threshold is Height Threshold mainThreshValue = queryHeightThresholdValue(graph) if askSpm(graph) == True: postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded at P = %s (corrected)" % (softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif askFsl(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." "%s statistic images were thresholded at P = %s (corrected)" %(fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif clusterWise == True: #If main threshold is extent threshold mainThreshValue = queryClusterThresholdValue(graph) heightThreshValue = queryUHeightThresholdValue(graph) clusterThreshType = clusterFormingThreshType(graph, statisticType) if askSpm(graph) == True: postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded using clusters determined by %s > %s and a (corrected) " "cluster significance of P = %s " % (softwareLabelNumList[1], statisticTypeString, clusterThreshType, heightThreshValue[0], mainThreshValue[0])) elif askFsl(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl). %s statistic images were thresholded " "using clusters determined by %s > %s and a (corrected) cluster significance of P = %s" %(fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, clusterThreshType, heightThreshValue[0], mainThreshValue[0])) else: #If there is no corrected threshold - assume voxel wise mainThreshValue = queryUHeightThresholdValue(graph) if askSpm(graph) == True and askIfPValueUncorrected(graph) == True: #SPM used and threshold type is nidm_PValueUncorrected postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded at P = %s (uncorrected)" % (softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif askSpm(graph) == True and askIfOboStatistic(graph) == True: #SPM used and threshold type is obo_statistic postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded at %s = %s (uncorrected)" % (softwareLabelNumList[1], statisticTypeString, statisticType, mainThreshValue[0])) elif askFsl(graph) == True and askIfPValueUncorrected(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." "%s statistic images were thresholded at P = %s (uncorrected)." % (fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif askFsl(graph) == True and askIfOboStatistic(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." "%s statistic images were thresholded at %s = %s (uncorrected)." % (fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, statisticType, mainThreshValue[0])) postStats += hr() postStats += h3("Thresholded Activation Images") postStats += hr() i = 0 if askFsl(graph) == True: while i < len(contrastName): postStats += p("%s" % contrastName[i]) postStats += img(src = statisticMapImage[i]) i = i + 1 postStatsFile = open(postStatsFilePath, "x") print(postStats, file = postStatsFile) postStatsFile.close()
def visit_Logo(self, node): a = tags.a(href=node.get_url()) a.add(tags.img(src=node.get_image_url())) return a