本文整理汇总了Python中etgen.html.E.th方法的典型用法代码示例。如果您正苦于以下问题:Python E.th方法的具体用法?Python E.th怎么用?Python E.th使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类etgen.html.E
的用法示例。
在下文中一共展示了E.th方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_html
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import th [as 别名]
def to_html(self, ar):
self.analyze_view()
get_rnd = rt.models.cal.EventGenerator.get_cal_entry_renderer
if self.mode == TABLE_MODE:
sep = ' '
fmt = get_rnd(day_and_weekday)
elif self.mode == UL_MODE:
sep = ' '
fmt = get_rnd(day_and_weekday)
elif self.mode == PLAIN_MODE:
sep = ', '
fmt = get_rnd(dd.fds)
def xxx(list_of_entries):
elems = []
for e in list_of_entries:
if len(elems):
elems.append(sep)
elems.extend(fmt(e, ar))
return elems
if self.mode == TABLE_MODE:
rows = []
cells = [E.th("")] + [E.th(monthname(m+1)) for m in range(12)]
# print(''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
for y in self.years.values():
cells = [E.td(str(y.year), width="4%")]
for m in y.months:
# every m is a list of etree elems
cells.append(E.td(*xxx(m), width="8%", **ar.renderer.cellattrs))
# print(str(y.year) +":" + ''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
return E.table(*rows, **ar.renderer.tableattrs)
if self.mode == UL_MODE:
items = []
for y in self.years.values():
for m, lst in enumerate(y.months):
if len(lst):
items.append(E.li(
monthname(m+1), " ", str(y.year), ": ", *xxx(lst)))
return E.ul(*items)
if self.mode == PLAIN_MODE:
elems = []
for y in self.years.values():
for lst in y.months:
if len(lst):
if len(elems):
elems.append(sep)
elems.extend(xxx(lst))
return E.p(*elems)
raise Exception("20180720")
示例2: to_html
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import th [as 别名]
def to_html(self, ar):
self.analyze_view()
if self.mode == TABLE_MODE:
sep = ' '
fmt = day_and_weekday
elif self.mode == UL_MODE:
sep = ' '
fmt = day_and_weekday
elif self.mode == PLAIN_MODE:
sep = ', '
fmt = dd.fds
def rnd(obj, ar):
if self.model is rt.models.cal.Guest:
d = obj.event.start_date
evt = obj.event
else:
d = obj.start_date
evt = obj
# if show_auto_num and evt.auto_type:
# yield str(evt.auto_type)+":"
yield ar.obj2html(evt, fmt(d))
if obj.state.button_text:
yield str(obj.state.button_text)
# return (fdmy(d) + ": ", ar.obj2html(evt, lbl))
def xxx(list_of_entries):
elems = []
# for e in reversed(list_of_entries):
for e in list_of_entries:
if len(elems):
elems.append(sep)
elems.extend(rnd(e, ar))
return elems
if self.mode == TABLE_MODE:
rows = []
cells = [E.th("")] + [E.th(monthname(m+1)) for m in range(12)]
# print(''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
for y in self.years.values():
cells = [E.td(str(y.year), width="4%")]
for m in y.months:
# every m is a list of etree elems
cells.append(E.td(*xxx(m), width="8%", **ar.renderer.cellattrs))
# print(str(y.year) +":" + ''.join([tostring(c) for c in cells]))
rows.append(E.tr(*cells))
return E.table(*rows, **ar.renderer.tableattrs)
if self.mode == UL_MODE:
items = []
for y in self.years.values():
for m, lst in enumerate(reversed(y.months)):
# January is [11], Dec is [0]
if len(lst):
items.append(E.li(
monthname(12-m), " ", str(y.year), ": ", *xxx(lst)))
return E.ul(*items)
if self.mode == PLAIN_MODE:
elems = []
for y in self.years.values():
for lst in y.months:
if len(lst):
if len(elems):
elems.append(sep)
elems.extend(xxx(lst))
return E.p(*elems)
raise Exception("20180720")