本文整理汇总了Python中HTML.list方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.list方法的具体用法?Python HTML.list怎么用?Python HTML.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML
的用法示例。
在下文中一共展示了HTML.list方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RunStrategies
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
def RunStrategies():
tipList = []
for name, strategy in STRATEGY_FUNCS.items():
logging.info('Running strategy: %s\n'%(name))
tip = strategy()
if tip != '':
tipList.append('<pre>\n' + tip + '\n</pre>')
return HTML.list(tipList)
示例2: create_diamond_html_pages
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
def create_diamond_html_pages(self):
diamonds = self.get_list_of_diamonds(self.results)
diamondLinkList = []
for diamond in diamonds:
print 'Create Page for diamond: "%s"' % diamond
results = filter(lambda x: self.results[x].get('RunInfo', 'dia') == diamond, self.results)
results = {key: self.results[key] for key in results}
fileName = '%s/results_%s.html' % (self.config.get('HTML', 'outputDir'), diamond)
diamondLinkList.append(HTML.link(diamond, 'results_%s.html' % diamond))
self.create_html_overview_table(results, fileName)
htmlcode = HTML.list(diamondLinkList)
fileName = '%s/results_diamonds.html' % self.config.get('HTML', 'outputDir')
if self.verbosity:
print 'save diamond file to: "%s"' % fileName
utilities.save_html_code(fileName, htmlcode)
pass
示例3: create_diamond_html_pages
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
def create_diamond_html_pages(newResults, mapping):
diamonds = map(lambda x: x[mapping['dia']], newResults)
diamonds = sorted(list(set(diamonds)))
diamondLinkList = []
for diamond in diamonds:
results = filter(lambda x: x[mapping['dia']] == diamond, newResults)
fileName = 'results_%s.html' % diamond
diamondLinkList.append(HTML.link(diamond, fileName))
create_html_overview_table(results, fileName, mapping)
print diamond
htmlcode = HTML.list(diamondLinkList)
fileName = 'results_diamonds.html'
with open(fileName, "w") as f:
f.write('%s' % htmlcode)
pass
示例4:
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
for current_node in as_pydot_graph.get_nodes():
#print current_node.get('as_cc')
if current_node.get('as_cc') == cc_input:
current_node.set('style', 'filled')
current_node.set('shape', 'box')
#current_node.set('fillcolor', '.7 .3 1.0')
current_node.set('fillcolor', 'orange')
current_node.set('URL',"http://bgp.he.net/AS%s" % current_node.get_name())
current_node.set('label','AS %s' % current_node.get_name()+'\n'+current_node.get('as_name'))
as_dot_cluster.add_node(current_node)
else:
current_node.set('style', 'filled')
current_node.set('shape', 'ellipse')
#current_node.set('fillcolor', '.4 .3 1.0')
current_node.set('fillcolor', 'green')
current_node.set('URL',"http://bgp.he.net/AS%s" % current_node.get_name())
current_node.set('label','AS %s' % current_node.get_name()+'\n'+current_node.get('as_name'))
as_pydot_graph.add_subgraph(as_dot_cluster)
as_pydot_graph.write_dot(figure_folder+output_dot_filename)
as_pydot_graph.write_png(figure_folder+output_png_filename)
#html_file.write('<h1>IPv%s AS graph</h1>\n' %ip_input)
html_file.write('<h2>Graph statistics</h2>\n')
htmlcode = HTML.list(['Number of nodes: %s' %filtered_graph.number_of_nodes(), 'Number of edges: %s' %filtered_graph.size()])
html_file.write(htmlcode)
html_file.write('<h2>IPv%s AS graph</h2>\n' %ip_input)
html_file.write('<p>This graph was last updated on %s based on RIS raw data %s</p>\n' %(time.strftime('%X %x %Z'), date_input))
html_file.write('<img src=''%s'' alt="IPv%s AS graph" width="90%%" class="center" />' %(rel_figure_folder+output_png_filename, ip_input))
html_file.close()
示例5: printDataHtml
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
def printDataHtml(self, filename, countStats = True, filterDataBoolean = False):
if( self.size() == 0):
print "no Data!"
return 0
f = open(filename,'w')
#adds the unfiltered data
f.write('computed stats for ' + self.pathname + '<p> un-filtered Statistics <p>')
stringValue = '<p> number of points %s <p>' % ( str(self.size(dataBoolean = True)))
f.write(stringValue)
dataLabel = ['min','max','stdev','mean']
#add a dummy line to the header, this will be the other top
headers = np.hstack(('-',self.header_num())).tolist()
#print "headers", headers
#get the statistical data
#min/max
min,max =self.splitRange(dataBoolean = True)
#turn into numpy matrices
min = np.matrix(min)
max = np.matrix(max)
#stdev values
stdevValues = np.matrix(self.stdev_num())
#mean values
meanValues = np.matrix(self.mean_num())
#combined all of the data so that they are columns
data = np.hstack((min.T,max.T,stdevValues.T,meanValues.T))
#add the labels of what each column is ( max,min,stdev,mean)
data = np.vstack((dataLabel, data))
#add the headers which are the rows
data = np.hstack((np.matrix(headers).T, data))
#turn this numpy matrix to a list
value = data.tolist()
#turn this list to an html table string
htmlTable = HTML.table(value)
#write out this string to our file
f.write(htmlTable)
#if we have filteres applied print out that stats
if( len(self.filters) != 0):
#print out the filters
filterStrings = []
#create a list of all the filters, printed out as a string
for i in range(len(self.filters)):
filterStrings.append(self.getFilterString(self.filters[i], i))
# this will create an HTML list of all of the filters
htmlcode = HTML.list(filterStrings)
f.write('<p>Filters<p>')
f.write(htmlcode)
f.write('<p>')
#adds the filtered data
f.write('<p> computed stasts for filtered data <p>')
#number of points in the filtered data set
stringValue = '<p> number of points %s <p>' % ( str(self.size(dataBoolean = False)))
f.write(stringValue)
# this will make the statistical table for the filtered data, this is the same process as above for the full
# data and compare comments for information
#get filtered data
dataLabel = ['min','max','stdev','mean']
#add a dummy line to the header, this will be the other top
headers = np.hstack(('-',self.header_num())).tolist()
#get statistical data
min,max =self.splitRange(dataBoolean = False)
min = np.matrix(min)
max = np.matrix(max)
stdevValues = np.matrix(self.stdev_numFiltered())
meanValues = np.matrix(self.mean_numFiltered())
#compile data into one large matrix
data = np.hstack((min.T,max.T,stdevValues.T,meanValues.T))
data = np.vstack((dataLabel, data))
data = np.hstack((np.matrix(headers).T, data))
value = data.tolist()
#write out table
htmlTable = HTML.table(value)
f.write(htmlTable)
#print out the count stats if the boolean is true and
# there are counts data
if( countStats == True and len(self.counts) != 0):
f.write('<p> Counted occurances within the data set <p>')
tableValues = []
tableValues.append(['Condition1', 'Condition2', 'counts'])
#for each count, make it a row in our table
for i in range (len(self.counts)):
row = []
countDic = self.counts[i]
#.........这里部分代码省略.........
示例6: list
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
header_row = ['Last name', 'First name', 'Age', 'Score'],
col_width=['', '20%', '10%', '10%'],
col_align=['left', 'center', 'right', 'char'],
col_styles=['font-size: large', '', 'font-size: small', 'background-color:yellow'])
f.write(htmlcode + '<p>\n')
print htmlcode
print '-'*79
#=== LISTS ===================================================================
# 1) a HTML list (with bullets) may be built from a Python list of strings:
a_list = ['john', 'paul', 'jack']
htmlcode = HTML.list(a_list)
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
# 2) it is easy to change it into a numbered (ordered) list:
htmlcode = HTML.list(a_list, ordered=True)
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
示例7: len
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
for pref_list in prefix_per_asn_dict.values():
total_country_nb_prefix = total_country_nb_prefix + len(pref_list)
# Rounding the number of AS paths in global_international_as_counter
for as_name, as_path_nb in global_international_as_counter.items():
global_international_as_counter[as_name] = float(as_path_nb)*100/total_nb_as_path
output_routing_report_file.write('### Routing report for %s based on RIS raw data %s\n### Samer Lahoud - July 2012\n' % (cc_input, date_input))
output_routing_report_file.write('\n### Summary routing report for %s\n' % cc_input)
output_routing_report_file.write('\n## Summary statistics\nTotal number of ASes: %s\nTotal number of prefixes: %s\nTotal number of AS paths: %s\n' %(len(asn_list), total_country_nb_prefix, total_nb_as_path))
#html_file.write('<h1>Routing report for Lebanon</h1>')
html_file.write('<h2>Global provider statistics</h2>')
html_file.write('<p>This report was last updated on %s based on RIS raw data %s</p>' %(time.strftime('%X %x %Z'), date_input))
htmlcode = HTML.list(['Total number of ASes: %s' %len(asn_list), 'Total number of prefixes: %s' %total_country_nb_prefix, 'Total number of AS paths: %s' %total_nb_as_path])
html_file.write(htmlcode)
output_routing_report_file.write('\n## International transit provider distribution for %s\n' %cc_input)
all_transit_table = HTML.Table(header_row=['International transit provider', 'Percentage of AS paths'])
for all_global_inter_asn in global_international_as_counter.most_common():
output_routing_report_file.write("%.2f %%\tvia\t AS%s\t%s\n" % (all_global_inter_asn[1], all_global_inter_asn[0], asn2name_list[all_global_inter_asn[0]]))
all_transit_table.rows.append([asn2name_list[all_global_inter_asn[0]], "%.2f" %all_global_inter_asn[1]])
global_figname = plot_as_pie([elem[0] for elem in global_international_as_counter.most_common()], [elem[1] for elem in global_international_as_counter.most_common()], 'International transit provider distribution for %s' % cc_input)
# html_file.write('<h4>Top 10 international transit providers</h4>')
# html_file.write('<img src=''%s'' alt="Top 10 international transit providers" width="450" height="450" />' %(rel_figure_folder+global_figname))
# htmlcode = str(top_transit_table)
# html_file.write(htmlcode)
示例8: data2html
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
#.........这里部分代码省略.........
}
# dict of colors for each result:
result_colors = {
'success': 'lime',
'failure': 'red',
'error': 'yellow',
}
t = HTML.Table(header_row=['Test', 'Result'])
for test_id in sorted(test_results):
# create the colored cell:
color = result_colors[test_results[test_id]]
colored_result = HTML.TableCell(test_results[test_id], bgcolor=color)
# append the row with two cells:
t.rows.append([test_id, colored_result])
htmlcode = str(t)
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
#-------------------------------------------------------------------------------
# 7) sample table with column attributes and styles:
table_data = [
['Smith', 'John', 30, 4.5],
['Carpenter', 'Jack', 47, 7],
['Johnson', 'Paul', 62, 10.55],
]
htmlcode = HTML.table(table_data,
header_row = ['Last name', 'First name', 'Age', 'Score'],
col_width=['', '20%', '10%', '10%'],
col_align=['left', 'center', 'right', 'char'],
col_styles=['font-size: large', '', 'font-size: small', 'background-color:yellow'])
f.write(htmlcode + '<p>\n')
print htmlcode
print '-'*79
#=== LISTS ===================================================================
# 1) a HTML list (with bullets) may be built from a Python list of strings:
a_list = ['john', 'paul', 'jack']
htmlcode = HTML.list(a_list)
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
# 2) it is easy to change it into a numbered (ordered) list:
htmlcode = HTML.list(a_list, ordered=True)
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
# 3) Lines of a list may also be added one by one, when using the List class:
html_list = HTML.List()
for i in range(1,10):
html_list.lines.append('square(%d) = %d' % (i, i*i))
htmlcode = str(html_list)
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
# 4) To save memory, a large list may be built from a generator:
def gen_lines(i):
'lines generator'
for x in range(1,i):
yield 'square(%d) = %d' % (x, x*x)
htmlcode = HTML.list(gen_lines(10))
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
#=== LINKS ===================================================================
# How to create a link:
htmlcode = HTML.link('Decalage website', 'http://www.decalage.info')
print htmlcode
f.write(htmlcode)
f.write('<p>')
print '-'*79
f.close()
print '\nOpen the file %s in a browser to see the result.' % HTMLFILE
示例9: int
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
# set a nice graphic status for prefix visibility
if int(seen_nb_RRC) == 0:
prefix_status = '<img src=%s alt="NOK"/>' %(rel_figure_folder+'nok_icon.png')
elif int(seen_nb_RRC) == int(total_nb_RRC):
prefix_status = '<img src=%s alt="OK"/>' %(rel_figure_folder+'ok_icon.png')
else:
prefix_status = '<img src=%s alt="MID_OK"/>' %(rel_figure_folder+'mid_ok_icon.png')
# put everything in a table row in the output files
output_table.rows.append([prefix_status, ipv6_prefix, prefix_allocation_type[ipv6_prefix], RRC_visibility, str(prefix_asn), first_seen_time, last_seen_time, str(prefix_holder), prefix_descr])
txt_report_file.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' %(ipv6_prefix, prefix_allocation_type[ipv6_prefix], RRC_visibility, prefix_asn, first_seen_time, last_seen_time, prefix_holder, prefix_descr))
if seen_nb_RRC > 0:
cc_announced_prefix_nb = cc_announced_prefix_nb +1
# put global statistics and insert html headers
htmltable = str(output_table)
#html_file.write('<h1>IPv6 report for %s</h1>' %country_name)
html_file.write('<h2>Prefix statistics</h2>')
htmlcode = HTML.list(['Total number of allocated prefixes: %s' %len(cc_allocated_ipv6_prefix_list), 'Number of announced prefixes: %s' %cc_announced_prefix_nb])
html_file.write(htmlcode)
html_file.write('<h2>Allocation and visibility report</h2>')
html_file.write('<p>This report was last updated on %s</p>' %time.strftime('%X %x %Z'))
html_file.write(htmltable)
html_file.close()
# put global statistics in txt file
txt_report_file.write('###\nSummary IPv6 report for %s\n###\n' % cc_input)
txt_report_file.write('%s\t%s\t%s\n' %('Country Code', 'Total Number of Allocated Prefixes', 'Number of Announced Prefixes'))
txt_report_file.write('%s\t%s\t%s\n' %(cc_input, len(cc_allocated_ipv6_prefix_list), cc_announced_prefix_nb))
示例10: write_note
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import list [as 别名]
def write_note(title, data): # TODO: Improve this
output = "<h2>%s</h2>" % title
output += HTML.list(data)
write_to_file(output, 'a')