当前位置: 首页>>代码示例>>Python>>正文


Python html.HTML类代码示例

本文整理汇总了Python中html.HTML的典型用法代码示例。如果您正苦于以下问题:Python HTML类的具体用法?Python HTML怎么用?Python HTML使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HTML类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_email

def send_email(user, event, message, **kw):
  if not user in config['email']['user_emails']:
    return

  args = {
    'f': config['email']['from_address'],
    't': config['email']['user_emails'][user],
    'u': kw['subject'] if 'subject' in kw else 'Notification',
  }

  if not 'app' in kw:
    kw['app'] = config['default_app']

  body = HTML('html')
  tr = body.table().tr()
  tr.td(valign='top').img(src=config['icons'][kw['app']], style='float:left; margin: 15px')
  try:
    if 'email_body' in kw:
      tr.td().text(kw['email_body'], escape=False)
    else:
      getattr(notifications, event + '_email')(tr.td(), message, **kw)
  except:
    with tr.td().p(style='margin-top: 15px') as p:
      p.b("Message:")
      p.br()
      p.text(message)

  ip = curl('ifconfig.me').strip()
  if ip != config['ip']:
    ybdst = ssh.bake(config['ip'])
    print "Sent %s email to %s" % (event, user)
    return ybdst.sendemail(_in=str(body), **args)
  else:
    print "Sent %s email to %s" % (event, user)
    return sendemail(_in=str(body), **args)
开发者ID:adharris,项目名称:yb-scripts,代码行数:35,代码来源:notifications.py

示例2: _sprite_proof

    def _sprite_proof(self, sprite_width, sprite_height, sprite_layout):
        """ Create a sprite proof showing how the image was cut. Should look like
        original. """
        h = HTML('html')
        head = h.head()
        title = h.title('Sprite Proof')
        stylesheet = head.link(href="%s.css" % self.scale, rel="stylesheet",
                type="text/css")
        style = head.style(type="text/css")
        style.raw_text("""
        .pc {
            position: absolute;
            text-indent: -999em;
        }
        .pc:hover {
            text-indent: 0;
        }
        """)
        body = h.body()
        for (k, v) in self.pieces.items():
            x = v[0]
            y = v[1]
            el = body.div(klass='pc pc-%s-%s' % (self.scale, k),
                    style="left:%spx;top:%spx;" % (x, y))
            el.text(str(k))

        f = open(os.path.join(self._mydir, 'sprite_proof.html'), 'w')
        f.write(str(h))
        f.close()
开发者ID:nadar71,项目名称:piecemaker,代码行数:29,代码来源:base.py

示例3: create_binary_correlation_stat_html

    def create_binary_correlation_stat_html(self, output_dir, roidb=None):
        from html import HTML
        # Create the directory if necessary
        if not osp.exists(output_dir):
            os.makedirs(output_dir)

        present_cache_file = osp.join(self.cache_path, self.name + '_present_stats.pkl')
        assert os.path.exists(present_cache_file)

        with open(present_cache_file, 'rb') as fid:
            present_stats = cPickle.load(fid)
        print '{} present stats loaded from {}'.format(self.name, present_cache_file)

        config_html = HTML()
        config_table = config_html.table(border='1')

        for i in xrange(self.num_classes):
            r = config_table.tr
            if i == 0:
                r.th('---')
            else:
                r.th('%s'%self.classes[i])
            for j in xrange(1, self.num_classes):
                c = r.td
                if i == 0:
                    c.a('%s'%self.classes[j])
                else:
                    c.a('%d'%int(present_stats[i, j]), href='images/%02d_%02d.jpg'%(i,j))

        html_file = open(osp.join(output_dir, 'coco_offsets_table.html'), 'w')
        print >> html_file, config_table
        html_file.close()
开发者ID:liuguoyou,项目名称:who_where,代码行数:32,代码来源:imdb.py

示例4: getHTMLTeamTable

 def getHTMLTeamTable(self, div_age, div_gen, team_id):
     # https://pypi.python.org/pypi/html/
     return_dict = self.get_schedule('team_id', team_id,
         div_age=div_age, div_gen=div_gen)
     game_list = return_dict['game_list']
     html = HTML()
     table = html.table(width='100%', border='1px solid black')
     table.caption(self.userid_name+" "+self.schedcol_name+" "+div_age+div_gen+str(team_id))
     header_row = table.tr
     header_row.th('Game Date', padding='5px')
     header_row.th('Start Time', padding='5px')
     header_row.th('Field', padding='5px')
     header_row.th('Home', padding='5px')
     header_row.th('Away', padding='5px')
     for game in game_list:
         game_row = table.tr
         game_row.td(game['game_date'])
         game_row.td(game['start_time'])
         findex = self.fieldinfo_indexerGet(game['venue'])
         if findex is not None:
             field_name = self.fieldinfo_list[findex]['field_name']
             game_row.td(field_name)
         game_row.td(str(game['home']))
         game_row.td(str(game['away']))
     return str(html)
开发者ID:yukonhenry,项目名称:datagraph,代码行数:25,代码来源:schedmaster.py

示例5: _WriteErrorReport

 def _WriteErrorReport(self, errorTable):
     h = HTML()
     
     t = h.table()
     tr = t.tr()
     tr.th("Line ID")
     tr.th("Error Message")
     tr.th("Error Details")
     
     for lineId, errorMsg, errorDetail in errorTable:
         tr = t.tr()
         tr.td(lineId)
         tr.td(errorMsg)
         tr.td(str(errorDetail))
     
     pb = _m.PageBuilder(title= "Error Report")
     
     headerText = "<b>Source Emmebank:</b> %s" %self.SourceEmmebankPath +\
                 "<br><b>Source Scenario:</b> %s" %self.SourceScenarioId +\
                 "<br><b>Target Scenario:</b> %s" %self.TargetScenario
     
     pb.add_text_element(headerText)
     
     pb.wrap_html(body= str(t))
     
     _m.logbook_write("Error report", value= pb.render())
     
     pass
         
开发者ID:MTTST,项目名称:TMGToolbox,代码行数:28,代码来源:copy_transit_lines.py

示例6: preload_auto_modes

 def preload_auto_modes(self):
     options = []
     h = HTML()
     for id, type, description in _util.getScenarioModes(self.Scenario,  ['AUTO', 'AUX_AUTO']):
         text = "%s - %s" %(id, description)
         options.append(str(h.option(text, value= id)))
     return "\n".join(options)
开发者ID:nmpeterson,项目名称:TMGToolbox,代码行数:7,代码来源:check_network_connectivity.py

示例7: create_html_report

def create_html_report(topwords,top_index,Pi):
    ht = HTML()
    div = ht.div(align="center")
    heading = div.h2(style="text-align:center")
    subhead = div.h3(style="text-align:center")
    # Creating the header 
    No_of_topics = len(topwords) - 1
    No_of_clusters = top_index.shape[0]
    head = "Topics : %d \n, Cluster : %d" %(No_of_topics,No_of_clusters)
    heading(head)
    
    # Creating the table
    for i in range(top_index.shape[0]):
        head_sub = div.h4(style="text-align:center")
        head_sub("Top Topics in Cluster %d (%.5f)" %(i+1,Pi[i]))
        t = div.table(align="center",border="2",cellpadding="12",cellspacing="0",width="80%")
        tb = t.tbody()
        tr = tb.tr(style="text-align:center")
        tr.th("Alpha")
        tr.th("Top Words")
        ind_alpha_index = top_index[i]
        for index in ind_alpha_index:
            tr = tb.tr(style="text-align:center")
            alpha_val = '%.5f' %index[1]
            tr.td(alpha_val)
            tr.td(topwords[int(index[0])])

    return(ht)
开发者ID:Anantha-Ravi-Kiran,项目名称:learning-correlated-topic-modelling,代码行数:28,代码来源:create_html.py

示例8: _AddReportSection

 def _AddReportSection(self, pb, type, modes, fountains, sinks, orphans):
     modes = [str(mode) for mode in modes]
     
     h = HTML()
     
     plural = ''
     if len(modes) > 1: plural = "s"
     sectionTitle = "{0} results for mode{1} {2!s}".format(type, plural, modes)
     
     #h.h3(sectionTitle)
     
     nFountains = len(fountains)
     nSinks = len(sinks)
     nOrphans = len(orphans)
     
     if nFountains > 0:
         
         plural = ''
         if nFountains > 1: plural = 's'
         title= "Found %s fountain node%s:" %(nFountains, plural)
         
         t = h.table()
         tr = t.tr()
         tr.th(title)
         
         for node in fountains:
             t.tr().td(str(node))
         
     if nSinks > 0:
         
         plural = ''
         if nSinks > 1: plural = 's'
         title= "Found %s sink node%s:" %(nSinks, plural)
         
         t = h.table()
         tr = t.tr()
         tr.th(title)
         
         for node in sinks:
             t.tr().td(str(node))
             
     if nOrphans > 0:
         
         plural = ''
         if nOrphans > 1: plural = 's'
         title= "Found %s orphan node%s:" %(nOrphans, plural)
         
         t = h.table()
         tr = t.tr()
         tr.th(title)
         
         for node in orphans:
             t.tr().td(str(node))
     
     pb.wrap_html(sectionTitle, body= str(h))
开发者ID:nmpeterson,项目名称:TMGToolbox,代码行数:55,代码来源:check_network_connectivity.py

示例9: page

    def page(self):
        pb = _tmgTPB.TmgToolPageBuilder(self, title="TMG Toolbox Index" ,
                     description="Lists all tools and libraries within the TMG Toolbox, \
                         alphabetically by tool name, with links to each tool.",
                     branding_text="- TMG Toolbox", runnable= False)
        
        tmg = [tb for tb in _MODELLER.toolboxes if tb.namespace() == 'tmg'][0]
        toolNames = self.get_tool_names(tmg)
        topCategories = self.get_top_categories(tmg)
        
        alphabetizedToolNames = {}
        for name, namespacce in toolNames:
            firstChar = name[0].upper()
            if firstChar in alphabetizedToolNames:
                alphabetizedToolNames[firstChar].append((name, namespacce))
            else:
                alphabetizedToolNames[firstChar] = [(name, namespacce)]
        orderedKeys = [key for key in alphabetizedToolNames.iterkeys()]
        orderedKeys.sort()
        
        for firstChar in orderedKeys:
            #pb.add_header(firstChar)
            
            toolNames = alphabetizedToolNames[firstChar]
            h = HTML()
            t = h.table(style= 'border-style:none;', width= '100%')
            tr = t.tr()
            tr.th(firstChar, colspan= '3', align= 'left')
            
            for name, namespace in toolNames:
                
                #Get description from the code
                tool = _MODELLER.tool(namespace)
                if hasattr(tool, 'short_description'):
                    description = tool.short_description()
                else:
                    description = "<em>--No description--</em>"
                
                #Determine the top-level category
                topNamespace = namespace.split('.')[1]
                if topNamespace in topCategories:
                    category = topCategories[topNamespace]
                else: continue #Skip top-level tool
                
                #Add data to table
                tr = t.tr()
                tr.td("<em>%s</em>" %category, escape= False, width= '20%')
                link = '<a data-ref="%s" class="-inro-modeller-namespace-link" style="text-decoration: none;">' %namespace
                link += name + "</a>"
                tr.td(link, escape= False, width= '40%')
                tr.td(description, escape= False, align= 'left')

            pb.wrap_html(body= str(t))
        
        return pb.render()
开发者ID:nmpeterson,项目名称:TMGToolbox,代码行数:55,代码来源:tool_list.py

示例10: build_html

def build_html():
    matrices = []
    check_make_dir('matrices_html')

    for root, dirs, files in os.walk('matrices'):
      h = HTML()
      matrix = os.path.basename(root)
      if not dirs:
        print root, dirs, files
        h.p('Matrix: ' + matrix)
        sparsity_plot = None
        for f in files:
          if not f.endswith('.png'):
            with open(os.path.join(root, f)) as fin:
              h.p(fin.read(), style='white-space: pre-wrap;')
          else:
            p = h.p()
            p.img(src=matrix + '.png')
            sparsity_plot = os.path.join(root, f)

        path = 'matrices_html/' + matrix + '.html'
        with open(path, 'w') as fout:
          matrices.append(matrix + '.html')
          fout.write(str(h))
          shutil.copyfile(sparsity_plot, 'matrices_html/' + matrix + '.png')

    with open('matrices_html/index.html', 'w') as fout:
      h = HTML()
      h.p('matrices: ')
      l = h.ol

      for m in matrices:
        l.li.a(m, href=m)

      fout.write(str(h))
开发者ID:caskorg,项目名称:cask,代码行数:35,代码来源:spark.py

示例11: dashboard

def dashboard():
    page = HTML()
    t = page.table()
    r = t.tr
    r.th("Count")
    r.th("Page name")
    for name in pageviews:
        r = t.tr
        r.td(str(pageviews[name]))
        r.td(name)
    return str(page)
开发者ID:parrt,项目名称:msan692,代码行数:11,代码来源:server.py

示例12: get

    def get(self):
        q = HTML()

        if self.request.GET:
            search = self.request.GET['search']

            wolframModel = WolframModel()
            answer = wolframModel.search(search)
            q.answer = answer
            q.search = search

        self.response.write(q.print_out())
开发者ID:ctrovato,项目名称:DPWgit,代码行数:12,代码来源:main.py

示例13: buy_used

    def buy_used(self, buy_info, used_info):
        alarm_num = 0
        used_info = Counter(all_type_list)
        buy_info = Counter(all_type_pur)
        # print used_info, buy_info, type(used_info)
        all_info = Counter(used_info + buy_info)
        # print all_info
        # print list(all_info)
        from html import HTML
        inline_css = {
            'class1': 'color:#00FF00;width:500;valign:middle;vertical-line:top;', #green
            'class2': 'color:#FF0000;width:500;valign:middle;vertical-line:top;', #red
            'class3': 'color:#FFFF00;width:500;valign:middle;vertical-line:top;', #yellow
            'class4': 'color:#000000;width:500;valign:middle;vertical-line:top;', #black
        }

        b = HTML()
        t = b.table(border='1px solid black')
        r = t.tr()
        t2 = t.tr()
        t3 = t.tr()
        r.td('Type', style=inline_css['class4'])
        t2.td('Purd', style=inline_css['class4'])
        t3.td('Used', style=inline_css['class4'])
        for m_title in list(all_info):
            r.td(str(m_title), style=inline_css['class4'])
            if m_title in dict(buy_info).keys():
                # print dict(buy_info)[m_title]
                t2.td(str(dict(buy_info)[m_title]), style=inline_css['class1'])
            else:
                # print 'no key'
                t2.td('Null', style=inline_css['class2'])
            if m_title in dict(used_info).keys():
                # print dict(used_info)[m_title]
                t3.td(str(dict(used_info)[m_title]), style=inline_css['class1'])
            else:
                # print 'nn key'
                t3.td('Null', style=inline_css['class2'])
            if m_title in dict(buy_info).keys() and m_title in dict(used_info).keys():
                if dict(buy_info)[m_title] < dict(used_info)[m_title]:
                    # print 'haha %s' % m_title
                    alarm_num = alarm_num + 1
            elif m_title not in dict(buy_info).keys() and m_title in dict(used_info).keys():
                # print 'used but not buy: %s' % m_title
                alarm_num = alarm_num + 1
            # elif m_title in dict(buy_info).keys() and m_title not in dict(used_info).keys():
            #     print 'buy but not used: %s' % m_title

        alarm_info_ec2 = {'status':str(alarm_num), 'report':str(b)}
        # print alarm_info_ec2
        return alarm_info_ec2
开发者ID:Arvon2014,项目名称:arvon-scripts,代码行数:51,代码来源:get_ec2_instance_list.py

示例14: alert_html

def alert_html(checklist,checkup):	
	h = HTML()	
	try:
		for key in checklist.keys():
			# If the key exceeds a threshhold, look for drivers.
		# 	print '''checkup[key]['Abs_Avg_Day_Diff']''',checkup[key]['Abs_Avg_Day_Diff']
		# 	print '''checklist[key]['l'])''', checklist[key]['l']
			if float(checkup[key]['Abs_Avg_Day_Diff'])>float(checklist[key]['l']): 
		# 		
		# 		#generate alert text
				txt=key+'value of '+str(checkup[key]['Abs_Avg_Day_Diff'])+' is over alert threshold of '+str(checklist[key]['l'])
				print txt
				h.p(txt)
		# 		
		# 		#run driver analytics
				lev=0
		# 		# for this dependent variable, get the list of driver variables.
				driverlist=checklist[key]['d']
		# 		
		# 		print 'driverlist', driverlist		
		# 		print '''driverlist[key]['l']''', checklist[key]['l']
			
				for driver in driverlist.keys():
					lev=driverlist[driver]['l']
		# 			# if no driver-level threshold was provided...
					if lev==0:
						lev=checklist[key]['l']
					subdrivlist=checkup[driver]
					for subdriv in subdrivlist.keys():
		# 				print 'subdrivlist', subdrivlist[subdriv]
		# 	# 				# default to the same threshold for the primary variable
		# 				print '''checkup[key]['Day_Avg_Diff']''', checkup[key]['Day_Avg_Diff']
		# 				print '''sign(subdrivlist[subdriv]['Day_Avg_Diff'])''', subdrivlist[subdriv]['Day_Avg_Diff']
				
				
						if sign(checkup[key]['Day_Avg_Diff'])==sign(subdrivlist[subdriv]['Day_Avg_Diff']):
							# and it's over the threshold...
							driverlev=subdrivlist[subdriv]['Day_Avg_Diff']
		# 					print 'triverlev', driverlev, 'lev', lev
		# 					print '''abs(driverlev)''',abs(driverlev), '''abs(lev)''',abs(lev)
							if abs(driverlev)>abs(lev):
								# generate driver text note
								txt=' Driver variable '+driver+':'+subdriv+' is at '+ str(subdrivlist[subdriv]['Day_Avg_Diff'])
								print txt
						h.p(txt)
		return h
	except:
		e = sys.exc_info()[0]
		el=sys.exc_traceback.tb_lineno
		print 'Error: %s' % e 
		print 'lineno: %s' % el	
开发者ID:mgoold,项目名称:Monitor-Lizard,代码行数:51,代码来源:sqlalchhelp.py

示例15: _WriteErrorReport

 def _WriteErrorReport(self, linesMissingInNetwork):
     h = HTML()
     t = h.table()
     tr = t.tr()
     tr.th("Line ID")
     for id in linesMissingInNetwork:
         tr = t.tr()
         tr.td(str(id))
     
     pb = _m.PageBuilder(title="Lines not in network report")
     
     pb.wrap_html("Lines references in file but not in network", body= str(t))
     
     _m.logbook_write("Error report", value= pb.render())
开发者ID:nmpeterson,项目名称:TMGToolbox,代码行数:14,代码来源:export_boardings.py


注:本文中的html.HTML类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。