本文整理汇总了Python中yattag.Doc.option方法的典型用法代码示例。如果您正苦于以下问题:Python Doc.option方法的具体用法?Python Doc.option怎么用?Python Doc.option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yattag.Doc
的用法示例。
在下文中一共展示了Doc.option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_select_option
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import option [as 别名]
def test_select_option(self):
doc, tag, text = Doc(
defaults = {'ingredient': ['chocolate', 'coffee']}
).tagtext()
with doc.select(name = 'ingredient', multiple = "multiple"):
for value, description in (
("chocolate", "Dark Chocolate"),
("almonds", "Roasted almonds"),
("honey", "Acacia honey"),
("coffee", "Ethiopian coffee")
):
with doc.option(value = value):
text(description)
root = ET.fromstring(doc.getvalue())
self.assertEqual(root[3].attrib['selected'], 'selected')
示例2: tag
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import option [as 别名]
with tag('body'):
with tag('form', action = ""):
with tag('br'):
text('Default OpenVPN configuration path: ' + OPENVPN_PATH)
with tag('br'):
text('Curent server: ' + current_server)
with tag('br'):
text('')
with tag('label'):
text("Select a VPN server")
with doc.select(name = 'server'):
lst = os.listdir(OPENVPN_PATH)
lst.sort()
for file in lst:
if file.endswith(".conf"):
with doc.option(value = file):
text(file.split(".conf")[0])
doc.stag('input', type = "submit", value = "Set")
if query.has_key('server'):
server = query['server'][0]
info = set_server(server).split("\n")
for openvpn_info in info:
with tag('br'):
text(openvpn_info)
print "Content-type: text/html\n"
result = indent(
doc.getvalue(),
indentation = ' ',