当前位置: 首页>>代码示例>>Python>>正文


Python Doc.select方法代码示例

本文整理汇总了Python中yattag.Doc.select方法的典型用法代码示例。如果您正苦于以下问题:Python Doc.select方法的具体用法?Python Doc.select怎么用?Python Doc.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yattag.Doc的用法示例。


在下文中一共展示了Doc.select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_select_option

# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import select [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')
开发者ID:leforestier,项目名称:yattag,代码行数:17,代码来源:tests_doc.py

示例2: tag

# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import select [as 别名]
    ).tagtext()

doc.asis('<!DOCTYPE html>')

with tag('html'):
    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)
开发者ID:nenadilic84,项目名称:OpenVPNChanger,代码行数:32,代码来源:index.py


注:本文中的yattag.Doc.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。