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 _add_item(self, pocket_item: PocketItem) -> None: """Add a pocket item to the HTML report page Args: pocket_item (PocketItem): Returns: None """ self.doc.add(tags.h3(pocket_item.title, cls="defaultfontfamily")) # Add bullets pocket_item_description = tags.ul() pocket_item_description += tags.li( "Link: ", tags.a(pocket_item.url, href=pocket_item.url), cls="defaultfontfamily", ) pocket_item_description += tags.li( "Tags: ", ", ".join([elem for elem in pocket_item.tags]), cls="defaultfontfamily", ) pocket_item_description += tags.li( "Time added: ", pocket_item.convert_datetime_to_string(pocket_item.time_added), cls="defaultfontfamily", ) self.doc.add(pocket_item_description)
def render(self): if len(self.highlights) == 0 \ and len(self.notes) == 0 \ and len(self.bookmarks) == 0: return with div(): h2(self.title) if self.authors is not None: p(f'Authors: {self.authors}') p(f'File: {self.file_name}') if len(self.bookmarks) > 0: h3('Bookmarks') with ol(): for bookmark in self.bookmarks: with li(): bookmark.render() if len(self.highlights) > 0: h3('Highlights') with ol(): for highlight in self.highlights: with li(): highlight.render() if len(self.notes) > 0: h3('Notes') with ol(): for note in self.notes: with li(): note.render()
def __init__(self, subtitle=''): self.doc = dominate.document(self.site_name) self.subtitle = subtitle if subtitle else self.__class__.__name__ self.on_ready_scriptage = [] with self.doc.head: for css in self.cssfiles.split(): self._link_css(css) for scripturl in self.scripturls: tags.script(crossorigin="anonymous", src=scripturl) self.script_list = tags.script().children with self.doc.body.add(tags.div(cls="container")): self.header = tags.div(id="header") with self.header.add(tags.h2()): tags.a(self.site_name, href='/', id="site_name") tags.h3(self.subtitle, id="subtitle") with tags.ul(id="status", style=self.status_style): for msg in flask.get_flashed_messages(): tags.li(msg) self.content = tags.div(id="content") self.footer = tags.div(id="footer") with self.footer: tags.a("Latest", href=url_for("list_latest")) tags.a("Back to the Front", href="/") tags.a("Catalog", href=url_for("show_catalog_page"), onclick="shift_edit(event, this)") tags.a("Register", href=url_for('loginbp.new_user')) tags.label("") if flask_login.current_user.is_authenticated: tags.a(f"Log out", href=url_for('loginbp.logout')) else: tags.a(f"Login", href=url_for('loginbp.login'))
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 append_list(self, *items): with self.doc.body: with ul() as unorderedList: for item in items: if type(item) is list: self.append_list(*item) else: li(item)
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 visit_Navbar(self, node): nav = tags.nav(cls="navbar navbar-expand-lg navbar-dark bg-primary") with nav: tags.span(node.title, cls="navbar-brand") with tags.div(id='navbarColor01', cls="collapse navbar-collapse"): with tags.ul(cls='navbar-nav mr-auto'): for item in node.items: tags.li(self.visit(item)) return nav
def report_list_group(self, items, **kwargs): """ Creates a list group. Each arg is a line :param str title: Title of the section :param list items: Each arg passed will be treated as a new list item :param bool section: Kwarg Set to True to append the cards section to the preceding section. Default is false :param tuple alert: Kwarg Create a dismissable alert box. First value of tuple is the color, and the second is the message :param tuple reference: Kwarg Adds a small button which hrefs to a user supplied link. Is a tuple. First value is color, second is link :param dict badge: Kwarg Adds badges. Key is the color, and value is the message. :param str custom_html: Insert raw html to be added to the end of the section :param dict modal: Create a modal. Is a dictionary. Valid keys are button, title and content :raises NoValidTag: Raises not valid tag Example: >>> r += report.report_list_group('First entry', 'Second entry', ...) """ if not kwargs.get('title'): raise rng.NotValidTag('Need a title') title = kwargs.get('title') if not isinstance(items, list): raise rng.NotValidTag('Items have to be in the form of a list') if 'section' in kwargs: style = rng.CSSControl.sticky_section_css else: style = rng.CSSControl.css_overflow with tag.div( _class="jumbotron container context reportng-list-group-class", style=style) as r: t = tag.h1(title, id="%s" % rng.HelperFunctions.id_with_random(5, title)) # creates a reference button with link if 'reference' in kwargs: t.add(rng.HelperFunctions.ref_button(kwargs.get('reference'))) # creates dismissable alert box if 'alert' in kwargs: rng.HelperFunctions.make_alert(kwargs.get('alert')) with tag.ul(_class="list-group"): for i in range(len(items)): tag.li( items[i], _class= "list-group-item d-flex justify-content-between align-items-center text-primary" ) if 'badge' in kwargs: rng.HelperFunctions.create_badges(kwargs.get('badge')) if 'custom_html' in kwargs: raw(kwargs.get('custom_html')) if 'modal' in kwargs: if isinstance(kwargs.get('modal'), dict): rng.HelperFunctions.make_modals(title.replace(' ', ''), kwargs.get('modal')) return rng.HelperFunctions.convert_to_string(r)
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 new_user(form, ws_url, errors=None): title = 'New User' d = _doc(title) with d: with t.form(action=form.action, method='post'): with t.fieldset(): t.legend(title) _errors(errors) with t.ol(cls='step_numbers'): with t.li(): t.p('First, create a one-word username for yourself (lowercase, no spaces)...' ) _text_input( *form.nv('new_username'), ('required', 'autofocus'), { 'pattern': valid.re_username, 'oninput': 'check_username(this.value)' }, 'Type new username here', _invalid(valid.inv_username, form.invalid('new_username'))) _invalid(valid.inv_username_exists, False, 'username_exists_message') with t.li(): t.p("Next, invent a password; type it in twice to make sure you've got it..." ) _text_input('password', None, ('required', ), {'pattern': valid.re_password}, 'Type new password here', _invalid(valid.inv_password, form.invalid('password')), type_='password') _text_input('password_confirmation', None, ('required', ), None, 'Type password again for confirmation', _invalid( valid.inv_password_confirmation, form.invalid('password_confirmation'), 'password_match_message'), type_='password') with t.li(): t.p("Finally, type in an email address that can be used if you ever need a password reset (optional, but this may be very useful someday!)..." ) _text_input( *form.nv('email'), None, {'pattern': valid.re_email}, 'Type email address here', _invalid(valid.inv_email, form.invalid('email'))) t.input_(type="submit", value="Done!") t.script(_js_validate_new_user_fields()) t.script(_js_check_username(ws_url)) return d.render()
def slide_indicator(num): """ Helper function that controls how image slide count works """ with tag.ol(_class="carousel-indicators") as o: for cnt in range(num): if cnt == 0: tag.li(data_target="#carousel_controls", data_slide_to="0", _class="active") else: tag.li(data_target="#carousel_controls", data_slide_to="%s" % str(cnt)) return o
def render_comment(self, row: Row): """Render description column.""" comment = row.get('comment', '') or '' if comment: yield raw(comment) if row['prov_value'] is None: return see_also_links = list( map( operator.itemgetter('link'), self.query( ''' SELECT ?link WHERE { $node rdfs:seeAlso ?link . OPTIONAL { $node octa:position ?position . } } ORDER BY ?position ''', node=row['prov_value'], ), ), ) if see_also_links: yield ul( li(render( node=link, octiron=self.octiron, ), ) for link in see_also_links)
def _pagerlink(self, page: int, text: str, extra_attributes: Optional[dict[str, Any]] = None): anchor = super(Page, self)._pagerlink(page, text) extra_attributes = extra_attributes or {} return str(tags.li(anchor, **extra_attributes))
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 author(self): authors = self.octiron.query(''' SELECT ?name ?url WHERE { ?page adr:author [ schema:name ?name ; schema:url ?url ] . } ''', page=self.iri) if not authors: return '' if len(authors) < 2: author, = authors dom = tags.li( tags.a( tags.strong('Author: '), author['name'], cls='md-nav__link', href=author['url'], target='_blank', ), cls='md-nav__item', ) return str(dom) raise ValueError('page has too many authors!')
def visit_Subgroup(self, node): if not self._in_dropdown: node_id = sha1(str(id(node)).encode()).hexdigest() li = tags.li(_class='dropdown') if node.active: li['class'] = 'active' a = li.add( tags.a(href='javascript:void(0);', _class='dropdown-toggle')) a.add(tags.i(_class='fa fa-fw fa-arrows-v')) a.add(node.title) a['data-toggle'] = 'collapse' a['data-target'] = '#' + node_id a['role'] = 'button' a['aria-haspopup'] = 'true' a['aria-expanded'] = 'false' if hasattr(node, 'icon') and node.icon != None: a.add(tags.i(_class='fa fa-fw fa-%s' % node.icon)) ul = li.add(tags.ul(_class='collapse', id=node_id)) active = node.active self._in_dropdown = True for item in node.items: ul.add(self.visit(item)) if item.active: active = True self._in_dropdown = False if active == True: li['class'] = 'sub_active' ul['class'] = 'collapse in' return li else: raise RuntimeError('Cannot render nested Subgroups')
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_Subgroup(self, node): if not self._in_dropdown: li = tags.li(_class='dropdown') if node.active: li['class'] = 'active' a = li.add(tags.a(href='#', _class='dropdown-toggle')) if node.icon is not None: a.add(tags.i(_class=str(node.icon))) a.add(tags.span(node.title)) else: a.add_raw_string(node.title) 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_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 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 construct_list_items(violations) -> Iterable[li]: """Construct list items.""" for violation in violations: yield li( strong(code(violation['code'])), a(violation['title'], href=violation['url']), )
def visit_View(self, node): item = tags.li() a = item.add(tags.a(node.text, href=node.get_url(), title=node.text)) if hasattr(node, 'icon') and node.icon != None: a.add(tags.i(_class='fa fa-fw fa-%s' % node.icon)) if node.active: item['class'] = 'active' return item
def dict_html(container, query, dict_, source, target): container.add(div(query, cls='word')) container.add(div(raw( f'{langs[source]} -> {langs[target[0]]}'), cls='lang')) for w in dict_: def_box = container.add(div()).add(ul()) defin = dict_[w] def_box.add(li(f'{w} ({defin["word_type"]})'.lower(), cls='definition')) synonyms = def_box.add(ol()) for syn in defin['variants']: if not syn[1]: synonyms.add(li(syn[0], cls='synonyms')) else: syn_word = synonyms.add(li(f'{syn[0]} ', cls='synonyms has_example')) syn_word.add(sup(syn[1]))
def visit_SuperGroup(self, node): li = tags.li(_id=sanitise_for_css(node.title.text), _class="parent") if node.title.active: li['class'] = 'parent active' a = li.add(tags.a(node.title.text, href=node.title.get_url())) ul = tags.ul(*[self.visit(item) for item in node.items]) ul2 = li.add(ul) return li
def visit_View(self, node): item = tags.li() item.add(tags.a(node.text, _class='nav-link', href=node.get_url(), title=node.text)) if node.active: item['class'] = 'nav-item active' else: item['class'] = 'nav-item' return item
def create_page(self): # Open plots directory if not os.path.isdir(self.get_output('plots')): os.mkdir(self.get_output('plots')) # Create HTML page self.doc = dom.document(title='BBPipe plots page') with self.doc.head: dtg.link(rel='stylesheet', href='style.css') dtg.script(type='text/javascript', src='script.js') with self.doc: dtg.h1("Pipeline outputs") dtg.h2("Contents:", id='contents') lst = dtg.ul() lst += dtg.li(dtg.a('Bandpasses', href='#bandpasses')) lst += dtg.li(dtg.a('Coadded power spectra', href='#coadded')) lst += dtg.li(dtg.a('Null tests', href='#nulls')) lst += dtg.li(dtg.a('Likelihood', href='#like'))
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 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 add(self, *items, active=False): added = [] _items = parse_into_single_tuple(items) for item in _items: _type = getattr(type(item), 'tagname', None) if _type is 'li' or isinstance(item, li): super().add(item) added.append(item) else: if active is True: element = super().add(li(item, _class='active', style='float:left;')) else: element = super().add(li(item, style='float:left;')) added.append(element) if len(added) == 1: return added[0] else: return tuple(added)
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 visit_Link(self, node): a = tags.a(href=node.get_url()) if node.icon is not None: a.add(tags.i(_class=str(node.icon))) a.add(tags.span(node.text)) else: a.add_raw_string(node.text) li = tags.li() li.add(a) return li
def visit_Navbar(self, node): kwargs = {'_class': 'navbar'} kwargs.update(self.kwargs) cont = tags.nav(**kwargs) ul = cont.add(tags.ul()) for item in node.items: ul.add(tags.li(self.visit(item))) return cont
def visit_Subgroup(self, node): group = tags.ul(_class='subgroup') title = tags.span(node.title) if node.active: title.attributes['class'] = 'active' for item in node.items: group.add(tags.li(self.visit(item))) return tags.div(title, group)
def add_footnote_to_output(paragraphs): with tags.li(): for (para) in paragraphs: for (run) in para.runs: style = footer.get_style(run) if style == "bolded": with tags.span(run.text): tags.attr(cls="sub-subject_small") else: with tags.span(run.text): tags.attr(cls="definition_small") tags.br()
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: 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_Separator(self, node): if not self._in_dropdown: raise RuntimeError('Cannot render separator outside Subgroup.') return tags.li(role='separator', _class='divider')
def visit_Link(self, node): item = tags.li() item.add(tags.a(node.text, href=node.get_url())) return item
def visit_Text(self, node): if not self._in_dropdown: return tags.p(node.text, _class='navbar-text') return tags.li(node.text, _class='dropdown-header')
def add_footnote_to_output(paragraphs): text = "" for (para) in paragraphs: text += para.text tags.li(text)
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_Separator(self, node): if not self._in_dropdown: raise RuntimeError("Cannot render separator outside Subgroup.") return tags.li(role="separator", _class="divider")
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 visit_Text(self, node): if not self._in_dropdown: raise RuntimeError('Cannot render label outside Subgroup') return tags.li(node.text, _class='dropdown-header')