MCPcopy Create free account
hub / github.com/NVIDIA/pix2pixHD / HTML

Class HTML

util/html.py:6–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class HTML:
7 def __init__(self, web_dir, title, refresh=0):
8 self.title = title
9 self.web_dir = web_dir
10 self.img_dir = os.path.join(self.web_dir, 'images')
11 if not os.path.exists(self.web_dir):
12 os.makedirs(self.web_dir)
13 if not os.path.exists(self.img_dir):
14 os.makedirs(self.img_dir)
15
16 self.doc = dominate.document(title=title)
17 if refresh > 0:
18 with self.doc.head:
19 meta(http_equiv="refresh", content=str(refresh))
20
21 def get_image_dir(self):
22 return self.img_dir
23
24 def add_header(self, str):
25 with self.doc:
26 h3(str)
27
28 def add_table(self, border=1):
29 self.t = table(border=border, style="table-layout: fixed;")
30 self.doc.add(self.t)
31
32 def add_images(self, ims, txts, links, width=512):
33 self.add_table()
34 with self.t:
35 with tr():
36 for im, txt, link in zip(ims, txts, links):
37 with td(style="word-wrap: break-word;", halign="center", valign="top"):
38 with p():
39 with a(href=os.path.join('images', link)):
40 img(style="width:%dpx" % (width), src=os.path.join('images', im))
41 br()
42 p(txt)
43
44 def save(self):
45 html_file = '%s/index.html' % self.web_dir
46 f = open(html_file, 'wt')
47 f.write(self.doc.render())
48 f.close()
49
50
51if __name__ == '__main__':

Callers 1

html.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected