コード例 #1
0
ファイル: wgo_contest.py プロジェクト: pquentin/gimp-web
def image_generate(title, image_file, author, email):
  img = (xhtml.div(title, {"class" : "title"})
         + xhtml.image({"src" : image_file})
         + xhtml.div(xhtml.span(author, {"class": "author"}) 
         # + xhtml.span(xhtml.mailto(email), {"class" : "email"})
         ))

  img = (xhtml.table(xhtml.table.row(xhtml.table.cell(xhtml.div(title, {"class" : "title"}), {"colspan": 2}))
                     + xhtml.table.row(xhtml.table.cell(xhtml.image({"src" : image_file}), {"colspan" : 2}))
                     + xhtml.table.row(xhtml.table.cell(xhtml.span(author, {"class" : "author"}), {"class" : "author"}))
                     # + xhtml.table.row(xhtml.table.cell(xhtml.span(email, {"class" : "email"}), {"class" : "email"}))
                     , {"class" : "splash-thumb"}))
  
  return (img)
コード例 #2
0
ファイル: pycode_to_html.py プロジェクト: cart0113/catalystlc
 def __init__(self, parent, code, num_start = 0, header = True, tab_size = 4):
     div_root.__init__(self, parent = parent)
     if isinstance(code, str):
         lines = Parser(raw = open(code).read()).out_lines
     else:
         source_lines = list(inspect.getsourcelines(code))[0]
         if header is False:
             source_lines.pop(0)
             for i,line in enumerate(source_lines):
                 source_lines[i] = line[tab_size:]
         lines = Parser(raw = ''.join(source_lines)).out_lines
             
     table = xhtml.table(parent = self)
     for i,line in enumerate(lines):        
         sec = tr_pycode_section(parent = table)
         if i%2 == 1:
             sec.style.background_color = css.rgb(240,240,240)
         td_pycode_number(parent = sec, text = str(i+num_start))
         td_pycode_line(parent = sec, text = line)
コード例 #3
0
ファイル: wgo_contest.py プロジェクト: pquentin/gimp-web
 def ashtml(self, which="image"):
   return (xhtml.table(xhtml.table.row(xhtml.table.cell(xhtml.div(self["title"], {"class" : "title"}), {"colspan": 2}))
                       + xhtml.table.row(xhtml.table.cell(xhtml.image({"src" : self[which]}), {"colspan" : 2}))
                       + xhtml.table.row(xhtml.table.cell(xhtml.span(self["author"], {"class" : "author"}), {"class" : "author"}))
                       # + xhtml.table.row(xhtml.table.cell(xhtml.span(self["email"], {"class" : "email"}), {"class" : "email"}))
                       , {"class" : "splash-thumb"}))
コード例 #4
0
def make_html(logfile='test_sum.log', outfile=''):
    '''
    Create an html file using information in the log file

    History

    150901 ksl  fixed so that the htmlfile could be specified
    151112 ksl  Modified so that number of saturating stars could be printed out
            and so that only some of the columns in the table created by actor.actor_main
        were included in the html table that is part of the output.
    '''
    xsize = 800
    ysize = 400

    try:
        root = logfile[0:logfile.rindex('_sum')]
    except ValueError:
        root = logfile[0:logfile.rindex('.')]

    hstring = html.begin('Summary for %s' % root)

    x = open(logfile, 'r')
    x = x.readlines()
    expcount = 0
    for line in x:
        xline = line.strip()
        words = xline.split()
        if len(words) > 0:
            if words[0] == 'Header':
                expcount += 1
                xline = "<a name=\"EXP%04d\">%s</a>" % (
                    expcount, xline.replace('Header', ''))
                hstring = hstring + html.h2(xline)
            elif words[0] == 'Table':
                xxx = read_table(words[1])
                # Drop some columns, and reorder sligthly
                xxx = xxx['Visit', 'ExpNo', 'Target', 'RA', 'Dec', 'Config',
                          'Aper', 'Filter', 'SAMP-SEQ', 'NSAMP', 'Exptime',
                          'Repeats', 'ScanRate', 'Comment']
                ### make links from exposure number
                links = []

                for i in range(len(xxx)):
                    link = '<a href=#EXP%04d>%d</a>' % (i + 1, xxx['ExpNo'][i])
                    links.append(link)

                xxx.add_column(Column(data=links, name='Exp'), 1)
                xxx.remove_column('ExpNo')

                # Note: ksl.  I had troble getting the column names to form a
                # sincle record.  This is what worked in the end
                my_table = [xxx.colnames[:]]

                for one in xxx:
                    my_table.append(one)

                hstring = hstring + html.table(my_table)
            elif words[0] == 'Image':
                ximage = words[1]
                hstring = hstring + html.image(ximage, 'Bright stars image',
                                               xsize, ysize)
            else:
                if xline.startswith('Saturated'):
                    print(xline)
                    data = xline.split()[-5::2]
                    colors = ['green', 'blue', 'red']
                    for i in range(3):
                        if int(data[i]) == 0:
                            data[
                                i] = "<span style=\"color:grey\">%s</span>" % (
                                    data[i])
                        else:
                            data[
                                i] = "<span style=\"color:%s; font-weight:bold;\">%s</span>" % (
                                    colors[i], data[i])

                    hstring += html.paragraph(
                        'Saturated pixels in image:') + html.table(
                            [xline.split()[-6::2], data], width="200px")
                elif xline.startswith('Number saturated'):
                    data = xline.split()[-5::2]
                    colors = ['green', 'blue', 'red']
                    for i in range(3):
                        if int(data[i]) == 0:
                            data[
                                i] = "<span style=\"color:grey\">%s</span>" % (
                                    data[i])
                        else:
                            data[
                                i] = "<span style=\"color:%s; font-weight:bold;\">%s</span>" % (
                                    colors[i], data[i])

                    hstring += html.paragraph(
                        'Saturated stars in field:') + html.table(
                            [xline.split()[-6::2], data], width="200px")
                else:
                    hstring = hstring + html.paragraph(xline)
    hstring = hstring + html.end()

    # Create the html file
    if outfile == '':
        html_file = root + '.html'
    elif outfile.count('html') == 0:
        html_file = outfile + '.html'
    else:
        html_file = outfile

    print('test ', html_file)
    g = open(html_file, 'w')
    g.write(hstring)
    g.close()