本文整理汇总了Python中html.HTML.p方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.p方法的具体用法?Python HTML.p怎么用?Python HTML.p使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类html.HTML
的用法示例。
在下文中一共展示了HTML.p方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: alert_html
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import p [as 别名]
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
示例2: build_html
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import p [as 别名]
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))
示例3: writeHTML
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import p [as 别名]
def writeHTML(options):
from html import HTML
titles = options.titles
h = HTML('html')
h.p('Results')
h.br()
path = '.'
#methods = ['planenet', 'pixelwise', 'pixelwise+RANSAC', 'GT+RANSAC', 'planenet+crf', 'pixelwise+semantics+RANSAC']
#methods = ['planenet', 'pixelwise', 'pixelwise+RANSAC', 'GT+RANSAC']
for image_index in xrange(options.numImages):
t = h.table(border='1')
r_inp = t.tr()
r_inp.td('input ' + str(image_index + options.startIndex))
r_inp.td().img(src=path + '/' + str(image_index + options.startIndex) + '_image.png')
r = t.tr()
r.td('methods')
for method_index, method in enumerate(titles):
r.td(method)
continue
r = t.tr()
r.td('segmentation')
for method_index, method in enumerate(titles):
r.td().img(src=path + '/' + str(image_index + options.startIndex) + '_segmentation_pred_' + str(method_index) + '.png')
r.td().img(src=path + '/' + str(image_index + options.startIndex) + '_segmentation_pred_blended_' + str(method_index) + '.png')
continue
r = t.tr()
r.td('depth')
for method_index, method in enumerate(titles):
r.td().img(src=path + '/' + str(image_index + options.startIndex) + '_depth_pred_' + str(method_index) + '.png')
continue
h.br()
continue
metric_titles = ['depth error 0.1', 'depth error 0.2', 'depth error 0.3', 'IOU 0.3', 'IOU 0.5', 'IOU 0.7']
h.p('Curves on plane accuracy')
for title in metric_titles:
h.img(src='curve_plane_' + title.replace(' ', '_') + '.png')
continue
h.p('Curves on pixel coverage')
for title in metric_titles:
h.img(src='curve_pixel_' + title.replace(' ', '_') + '.png')
continue
html_file = open(options.test_dir + '/index.html', 'w')
html_file.write(str(h))
html_file.close()
return
示例4: Html
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import p [as 别名]
class Html(object):
def __init__(self):
self.h = HTML()
def table(self, title, data):
self.t = self.h.table(border="1")
self.t.caption(title)
for i in data:
r = self.t.tr
for j in xrange(len(i)):
r.td(str(i[j]))
return str(self.t)
def text(self, data):
self.p = self.h.p()
for line in data:
self.p.text(str(line))
self.p.br
return str(self.h)
def link(self, url):
self.a = self.h.a(str(url))
return str(self.a)
示例5: int
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import p [as 别名]
for ds in root.findall('ds'):
# name = ds.find('name').text
last = ds.find('last_ds').text
ms = int(last)
def colour(x):
if x < 2000:
return ('green')
else:
return ('red')
fontc = colour(ms)
# unable to escape the - from http-equiv
dct = {
'http-equiv': 'refresh', 'content': '5'
}
H.meta(**dct)
H.font(size="50", color="%s" % (fontc), face="arial")(("%s m/s") % (last))
H.p('Current ping to live.sipgate.co.uk - green:good | red:bad')
value = str(H)
html = open("colour.html", "w")
html.write(value)
html.close()