コード例 #1
0
def process_navbar():
    # get images here
    lockimage = img(src='static/img/lock.png', height='20', width='20')
    unlockimage = img(src='static/img/unlock.png', height='20', width='20')
    separator = img(src='static/img/separate.png', height='25', width='10')

    # Find all the samples in the data directory
    dir_list = []
    if current_user.is_authenticated:
        current_app.config['DATA_DIR'] = current_app.config['ALL_DATA_DIR']
    else:
        current_app.config['DATA_DIR'] = current_app.config[
            'PUBLISHED_DATA_DIR']
    dir_list = next(walk(current_app.config['DATA_DIR'] + "/ensembles"))[1]
    published_dir_list = next(
        walk(current_app.config['PUBLISHED_DATA_DIR'] + "/ensembles"))[1]

    dir_list_links = []

    first = True

    for x in dir_list:
        if not first:
            dir_list_links.append(Text(separator))
        dir_list_links.append(Link(x, "/" + x))
        if current_user.is_authenticated:
            # x is public: add unlockimage
            if x in published_dir_list:
                dir_list_links.append(Text(unlockimage))
            # x is private: add lockimage
            else:
                dir_list_links.append(Text(lockimage))
        first = False

    nav.register_element('frontend_top', Navbar('', *dir_list_links))
コード例 #2
0
def cv():
    base = Path('cv')
    with (base / 'content' / 'data.toml').open() as toml, \
         (base / 'style' / 'index.css').open() as css:
        data = loads(toml.read())
        with html(lang='en') as document:
            with head():
                meta(charset='utf-8')
                meta(name='description',
                     content=f'{SHARED.info.person_name} (engineer|designer)')
                meta(name='keywords', content=','.join(SHARED.meta.keywords))
                meta(name='author', content=f'{SHARED.info.person_name}')
                title(SHARED.info.person_name)
                style(raw(css.read()))
            with body():
                with table(id='content') as content:
                    with tr():
                        with td(id='image', colspan=4):
                            img(src='img/header.png', alt='...')
                            div('Curriculum Vitae')
                for row in chain(
                        Basic(data['basic']).as_rows(),
                        Skills(data['skills']).as_rows(),
                        Experience(data['experience']).as_rows(),
                        Education(data['education']).as_rows()):
                    content.add(row)

    copyright = comment(f'Copyright (C) 2015 - {datetime.now().year} '
                        f'{SHARED.info.person_name}. '
                        'All rights reserved.')
    return f'<!DOCTYPE html>{copyright}{document.render(pretty=False)}'
コード例 #3
0
ファイル: html_report.py プロジェクト: lqiang2003cn/dps
 def add_image(self,
               im,
               title,
               txt='',
               width=None,
               height=None,
               font_pct=100):
     if width is None:
         width = self.default_image_width
     if height is None:
         height = self.default_image_height
     if self.t is None or self.row_image_count >= self.images_per_row:
         self._add_table()
     with self.t:
         # with tr():
         # with td(style="word-wrap: break-word;", halign="center", valign="top"):
         with tags.td(halign="center", valign="top"):
             with tags.p():
                 if height is not None:
                     img_style = "width:{}px; height:{}px".format(
                         width, height)
                 else:
                     img_style = "width:{}px;".format(width)
                 tags.img(style=img_style,
                          src=r'data:image/png;base64,' +
                          self._encode_image(im))
                 tags.br()
                 tags.p(
                     "{}\n{}".format(title, txt),
                     style=
                     'width:{}px; word-wrap: break-word; white-space: pre-wrap; font-size: {}%;'
                     .format(width, font_pct))
     self.row_image_count += 1
コード例 #4
0
def formatDoubleWeek(week1, week2, image, backgroundImage, imageDescription):
    # week frame with background
    bg = "background-image:url({});".format(backgroundImage)
    with div(cls="page", style=bg):
        # image
        with div(cls="week-image-container"):
            with div(cls="week-image-aspect-ratio"):
                img(src=image, cls="week-image", alt="")
        # image description
        div(imageDescription, cls="week-image-description")
        # month name(s)
        month1 = week1.month1
        month2 = week2.month2 if week2 else month1
        if month1 is month2:
            monthName = month1.name
        else:
            monthName = u"{} / {}".format(month1.name, month2.name)
        div(monthName, cls="month-name")
        # days
        with div(cls="double-week"):
            with div(cls="week week-1"):
                formatWeek(week1)
            if week2:
                with div(cls="week week-2"):
                    formatWeek(week2)
コード例 #5
0
def createHtmlStructure(channel, limit, html_path, pdf_path):
    '''
    1. in loop create html structure
    2. return html_structure 
    3. or file name of pdf for send_from_directory function
    '''
    html_document = dominate.document(title="HTML document")

    for index, item in enumerate(channel.entries):
        if (index == limit):
            break
        with html_document:
            with div():
                h2("Title: " + html.unescape(item.title))
                p("Link: " + item.link)
                media_content = news_parser.checkMediaContent(item)
                if (media_content):
                    img(src=media_content)
                description = news_parser.getDescription(item.description)
                if (description):
                    p("Description: " + description)

    if (html_path):
        return str(html_document)
    elif (pdf_path):
        return topdf.convertHtmlToPdf(str(html_document), pdf_path)
コード例 #6
0
def createHtmlFromDB(limit, html_path, pdf_path, arg_date):
    '''
    1. in loop create html structure
    2. create html document or convert html structure into pdf
    '''
    records = getCacheFromDB(arg_date)

    html_document = dominate.document(title="HTML document")
        
    for index, row in enumerate(records):
        if(limit and index == limit):
            break
        with html_document:
            with div():
                h2("Title: " + row[0])
                p("Link: " + row[1])
                if (row[2]):
                    img(src="data:image/jpg;base64," + base64.b64encode(row[2]).decode('ascii'))
                if (row[3]):
                    p("Description: " + row[3])

    if (html_path):
        return str(html_document)
    elif (pdf_path):
        return topdf.convertHtmlToPdf(str(html_document), pdf_path)
コード例 #7
0
    def add_images(self, ims, txts, links, width=400):
        """add images to the HTML file

        Parameters:
            ims (str list)   -- a list of image paths
            txts (str list)  -- a list of image names shown on the website
            links (str list) --  a list of hyperref links; when you click an image, it will redirect you to a new page
        """
        self.t = table(border=1,
                       style="table-layout: fixed;")  # Insert a table
        self.doc.add(self.t)
        with self.t:
            with tr():
                for im, txt, link in zip(ims, txts, links):
                    with td(style="word-wrap: break-word;",
                            halign="center",
                            valign="top"):
                        with p():
                            with a(href=os.path.join('images', link)):
                                #img(style="width:%dpx" % width, src=os.path.join('images', im))
                                img(style="width:%dpx" % width,
                                    src=os.path.join(self.folder, im))

                            br()
                            p(txt)
コード例 #8
0
ファイル: html.py プロジェクト: PeterZhouSZ/SketchPatch
    def add_images(self, epoch, ims, txts, links, width=400):
        if epoch != -1:
            img_dir_epoch = os.path.join(self.img_dir, str(epoch))
            util.mkdirs(img_dir_epoch)
        else:
            img_dir_epoch = self.img_dir

        path_parts = img_dir_epoch.split('/')

        if self.is_test:
            rel_path = path_parts[-1:]
        else:
            rel_path = path_parts[-2:]
        rel_path = '/'.join(rel_path)

        self.add_table()
        with self.t:
            with tr():
                for im, txt, link in zip(ims, txts, links):
                    with td(style="word-wrap: break-word;",
                            halign="center",
                            valign="top"):
                        with p():
                            with a(href=os.path.join(rel_path, link)):
                                img(style="width:%dpx" % width,
                                    src=os.path.join(rel_path, im))
                            br()
                            p(txt)
コード例 #9
0
 def add_images(self, ims, txts, links, width=400):
     """add images to the HTML file
     Parameters:
         ims (str list)   -- a list of image paths
         txts (str list)  -- a list of image names shown on the website
         links (str list) --  a list of hyperref links; when you click an image, it will redirect you to a new page
     """
     self.t = table(border=1,
                    style="table-layout: fixed;")  # Insert a table
     self.doc.add(self.t)
     with self.t:
         with tr():
             for im, txt, link in zip(ims, txts, links):
                 with td(style="word-wrap: break-word;",
                         halign="center",
                         valign="top"):
                     with p():
                         with a(href=link):
                             img(style="width:%dpx" % width, src=im)
                         br()
                         #                            attrs_path = os.path.join(self.web_dir,'attributes', txt)
                         #                            with open(attrs_path, "r") as attr_log_file:
                         #                                attrs_str =attr_log_file.read()  # save the message
                         #                            attrs_str.replace('\n','<br>')
                         text(txt)
コード例 #10
0
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
コード例 #11
0
ファイル: html.py プロジェクト: a-martyn/pix2pix
 def add_header(self, text, im):
     """Insert a header to the HTML file
     Parameters:
         text (str) -- the header text
     """
     with self.doc:
         h3(text)
         with a(href=im):
             img(style="width:1024px", src=im)
コード例 #12
0
def formatTitlePage(calendar):
    # title page frame with background
    bg = "background-image:url({});".format(calendar.titlePageBackground)
    with div(cls="page", id="title-page", style=bg):
        # title image
        with div(id="title-page-image-container"):
            with div(id="title-page-image-aspect-ratio"):
                img(src=calendar.titlePageImage, alt="", id="title-page-image")
        # title
        div(calendar.title, id="title")
コード例 #13
0
ファイル: html.py プロジェクト: ShengCN/soft_shadow
 def add_images(self, ims, txts, links, width=400, height=300):
     self.add_table()
     with self.t:
         with tr():
             for im, txt, link in zip(ims, txts, links):
                 with td(style="word-wrap: break-word; height:{}px; width:{}px".format(height + 10,width + 10), halign="center", valign="top"):
                     with p():
                         with a(href=os.path.join('/',link)):
                             img(style="width:{}px;height:{}".format(width, height), src=os.path.join('/',im))
                         br()
                         p(txt)
コード例 #14
0
ファイル: html.py プロジェクト: ChenQingya/instagan-part
 def add_images(self, ims, txts, links, width=400):
     self.add_table()
     with self.t:
         with tr():
             for im, txt, link in zip(ims, txts, links):
                 with td(style="word-wrap: break-word;", halign="center", valign="top"):
                     with p():
                         with a(href=os.path.join('images', link)):
                             img(style="width:%dpx" % width, src=os.path.join('images', im))
                         br()
                         p(txt)
コード例 #15
0
ファイル: visdom.py プロジェクト: jma100/SPADE_eval
 def html(self, root_dir):
     self.save(root_dir)
     with p():
         with a(href=self.relative_save_path):
             img_style = "image-rendering:pixelated;"
             if self.display_height is not None:
                 img_style += 'height:{}px;'.format(self.display_height)
             img(style=img_style, src=self.relative_save_path)
         if self.desc is not None:
             br()
             pre(self.desc)
コード例 #16
0
 def image(self, src, alt):
     with tags.figure(cls='figure'):
         tags.img(cls='figure-img img-fluid rounded', src=src, alt=alt)
         with tags.figcaption(
                 cls='figure-caption',
                 # Requires browser-specific hyphens to work in different browsers.
                 style=('-webkit-hyphens: auto; '
                        '-moz-hyphens: auto; '
                        '-ms-hyphens: auto; '
                        'hyphens: auto;')):
             util.text(alt)
コード例 #17
0
ファイル: write_page.py プロジェクト: cnovel/TheDailyCommute
def write_events(doc: dominate.document, events):
    """
    Write events to HTML document
    :param doc: Dominate document
    :param events: List of events
    """
    with doc:
        with tags.div(cls='agenda'):
            tags.img(src='Icons/Calendar.svg', alt='Calendar icon', cls='icon')
            for event in events:
                write_event(event)
コード例 #18
0
def make_subregion_html(doc_url, region):
    region_href = urls.link(doc_url, urls.region_page(region))
    with tags.a(cls="subregion", href=region_href):
        with tags.div(cls="subregion_label", __pretty=False):
            util.text(region.name)
            with tags.div():
                pop = region.totals["population"]
                util.text(f"{pop:,.0f}\xa0pop")
                vax = region.totals.get("vaccinated", 0)
                util.text(f", {100 * vax / pop:,.2g}%\xa0vax" if vax else "")

        tags.img(width=200, src=urls.link(doc_url, urls.thumb_image(region)))
コード例 #19
0
ファイル: utils.py プロジェクト: OkayMing/BPGAN
 def add_images(self, ims, txts, links, width=400):
     self.t = table(border=1, style="table-layout: fixed;")  # Insert a table
     self.doc.add(self.t)
     with self.t:
         with tr():
             for im, txt, link in zip(ims, txts, links):
                 with td(style="word-wrap: break-word;", halign="center", valign="top"):
                     with p():
                         with a(href=os.path.join('images', link)):
                             img(style="width:%dpx" % width, src=os.path.join('images', im))
                         br()
                         p(txt)
コード例 #20
0
ファイル: html.py プロジェクト: ph4r05/trezor-firmware
def image(src: Path) -> None:
    with td():
        if src:
            # open image file
            image = src.read_bytes()
            # encode image as base64
            image = base64.b64encode(image)
            # convert output to str
            image = image.decode()
            # img(src=src.relative_to(fixture_test_path))
            img(src="data:image/png;base64, " + image)
        else:
            i("missing")
コード例 #21
0
def generate_output_pc(setup, title, pc_cutoff, pc_height, img_height, skin, cache, imgs=[]):
    #not the penultimate bag, need to go deeper
    if len(setup.continuations[0].continuations) > 0:
        #store images in list to print at the end
        new_imgs = imgs.copy()  #don't think this needs to be a deepcopy
        new_imgs.append(fumen_to_image(setup.solution.fumen, img_height, skin))
        for i, s in enumerate(tqdm(setup.continuations, unit="setup", leave=False)):
            generate_output_pc(s, title + (" - Sub-Setup %d" % i), pc_cutoff, pc_height, img_height, skin, cache,
                               new_imgs)
    else:
        sf = SFinder(setup_cache=cache)
        h2(title)
        with div():
            best_continuation = setup.continuations[0].solution
            best_pc = sf.path(
                fumen=best_continuation.to_fumen(), pieces=best_continuation.get_remaining_pieces(),
                height=pc_height)[0]  #todo: hack! change this when i fix cache

            for url in imgs:
                img(src=url)
            img(src=fumen_to_image(setup.solution.fumen, img_height, skin))
            img(src=fumen_to_image(best_continuation.fumen, img_height, skin))
            img(src=fumen_to_image(best_pc.fumen, img_height, skin))
        with p():
            text("Best continuation: ")
            b("%.2f%%" % setup.continuations[0].PC_rate)
            text(" PC success rate – ")
            b(a("%d continuations" % len(setup.continuations), href=fumen_url + setup.to_fumen()))
            text("with >%.2f%% PC success rate" % pc_cutoff)
コード例 #22
0
def Item(file_name):
    with open(f'{file_name}.jpg', 'rb') as img_file:
        b64_str = base64.b64encode(img_file.read())
    with dom.div(cls=RESULT_ITEM) as ResultItem:
        dom.p(f"{ file_name }.jpg", {
            "ic-action": "slideToggle",
            "ic-target": f"#{file_name}"
        },
              cls="w-full text-xl text-gray-400")
        dom.img(src=f"data:image/jpeg;base64,{b64_str.decode('utf-8')}",
                id=f"{file_name}",
                cls="w-full",
                style="display:none")

    return ResultItem.render() + dom.span(id="here").render()
コード例 #23
0
 def add_images(self, ims, txts, links, width=400):
     """Add images to table."""
     table = self.add_table()
     tr = table.add(htags.tr())
     with tr:
         for im, txt, link in zip(ims, txts, links):
             with htags.td(style="word-wrap: break-word;",
                           halign="center",
                           valign="top"):
                 with htags.p():
                     with htags.a(href=os.path.join('images', link)):
                         htags.img(style="width:%dpx" % width,
                                   src=os.path.join('images', im))
                     htags.br()
                     htags.p(txt)
コード例 #24
0
def formatMonth(year, month, image, backgroundImage, imageDescription):
    # month frame with background
    bg = "background-image:url({});".format(backgroundImage)
    with div(cls="page month", style=bg):
        # image
        with div(cls="month-image-container"):
            with div(cls="month-image-aspect-ratio"):
                img(src=image, cls="month-image", alt="")
        # image description
        div(imageDescription, cls="month-image-description")
        # month name and year
        with div(cls="month-description"):
            div(month.name, cls="month-name")
            div(year, cls="month-year")
        formatDays(month, year)
コード例 #25
0
    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
コード例 #26
0
 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
コード例 #27
0
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()
コード例 #28
0
def create_html(items: list) -> document:
    """
        convert article data in html format
    """
    html_document = document(title='Dominate your HTML')
    log.info('Start make html format')
    for item in items:
        item = printers.prepare_one_item(item)
        with html_document:
            with div():
                h2("Title: " + item['Title:'])
                p("Link: " + item['Link: '])
                img(src=item['Media content:\n'])
                p("Description: " + item['Description: '])
                p("Date: " + item['Date:'])
    return html_document
コード例 #29
0
ファイル: html.py プロジェクト: trezor/trezor-firmware
def image(src: Path, image_width: Optional[int] = None) -> None:
    with td():
        if src:
            # open image file
            image = src.read_bytes()
            # encode image as base64
            image = base64.b64encode(image)
            # convert output to str
            image = image.decode()
            # img(src=src.relative_to(fixture_test_path))
            img(
                src="data:image/png;base64, " + image,
                style=f"width: {image_width}px; image-rendering: pixelated;"
                if image_width else "",
            )
        else:
            i("missing")
コード例 #30
0
    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
コード例 #31
0
 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
コード例 #32
0
ファイル: html.py プロジェクト: AlamiMejjati/Gaze-Shift-Net
 def add_images_filterchart(self, ims, txts, links, width=400):
     self.add_table()
     with self.t:
         with tr():
             for im, txt, link in zip(ims, txts, links):
                 with td(style="word-wrap: break-word;",
                         halign="center",
                         valign="top"):
                     with p():
                         with a(href=link):
                             img(style="width:%dpx" % width, src=link)
                         br()
                         splitted = txt.split('separator')
                         if len(splitted) > 1:
                             for h in splitted:
                                 p(h)
                         else:
                             p(txt)
コード例 #33
0
ファイル: nav.py プロジェクト: Sigilai5/News-Highlight-Flask
 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
コード例 #34
0
 def visit_Logo(self, node):
     a = tags.a(href=node.get_url())
     a.add(tags.img(src=node.get_image_url()))
     return a
コード例 #35
0
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()