Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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())
@_m.method(return_type=unicode)
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)
def to_html(obj):
h = html.HTML()
if isinstance(obj, list):
return list_to_html(obj)
elif isinstance(obj, dict):
return dict_to_html(obj)
else:
p = h.p('')
p.text(str(obj))
return h
def estructural(element, h=HTML()):
h = h.__getattr__(element.tag)(element.content,
id=element.id,
style=element.style,
klass=element.klass)
return h
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 +\
def table_to_html (table, enclose=False):
""" Recibe una lista de listas y crea una tabla en html
El sentido es filas-columnas
El código devuelto no está encerrado en los tags <table></table> salvo que
enclose sea True
"""
h = html.HTML()
table_tag = enclose and h.table or h
for row in table:
tr = table_tag.tr
for col in row:
td = tr.td
td.raw_text(to_html(col))
return h
def dict_to_html(dictionary):
'''
Recibe un OrderedDict cuyas claves son la etiqueta a aplicar al valor.
Por ejemplo
from OrderedDict import OrderedDict
d = OrderedDict()
d['h1'] = 'Hola'
d['p'] = 'mundo'
str(dict_to_html(d)) # <h1>hola</h1>\n<p>mundo</p>
En caso de recibir un diccionario común, no se puede asegurar el orden
en el que serán impresos los valores
'''
h = html.HTML()
for k, v in dictionary.iteritems():
e = h.__getattr__(k)
e.raw_text(str(v))
return h
def writeHTMLPlane(filename, numImages=10):
from html import HTML
#0.227 0.194 0.163 0.157 0.100
#0.196 0.150 0.143 0.488 0.082
h = HTML('html')
h.p('Results')
h.br()
path = ''
folders = ['PlaneNet_hybrid', 'PlaneNet', 'GT_RANSAC', 'pixelwise_RANSAC']
for index in xrange(numImages):
firstFolder = path + folders[0]
t = h.table(border='1')
r_inp = t.tr()
r_inp.td('input')
r_inp.td().img(src=firstFolder + '/' + str(index) + '_image.png')
r_inp.td().img(src=firstFolder + '/' + str(index) + '_depth.png')
# r = t.tr()
# r.td('PlaneNet prediction')
# r.td().img(src=firstFolder + '/' + str(index) + '_segmentation_pred.png')
# r.td().img(src=firstFolder + '/' + str(index) + '_depth_pred.png')
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):