本文整理汇总了Python中xmlbuilder.XMLBuilder.value方法的典型用法代码示例。如果您正苦于以下问题:Python XMLBuilder.value方法的具体用法?Python XMLBuilder.value怎么用?Python XMLBuilder.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlbuilder.XMLBuilder
的用法示例。
在下文中一共展示了XMLBuilder.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pipeline_to_xml
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import value [as 别名]
def pipeline_to_xml(p):
""" Convert a Pipeline to XML
:type p: Pipeline
:param p:
:return:
"""
root = XMLBuilder(Constants.WORKFLOW_TEMPLATE_ROOT, id=p.idx)
with getattr(root, Constants.ENTRY_POINTS):
for eid, bid in p.entry_bindings:
_d = {"id": eid, "in": bid}
getattr(root, Constants.ENTRY_POINT)(**_d)
with getattr(root, Constants.BINDINGS):
for bout, bin_ in p.bindings:
_d = {"out": bout, "in": bin_}
getattr(root, Constants.BINDING)(**_d)
# Engine level Options
# for completeness write this element
getattr(root, "options")
# Task Options
with getattr(root, "task-options"):
for key, value in p.task_options.iteritems():
_d = {"id": key}
with getattr(root, 'option')(**_d):
root.value(str(value))
return root
示例2: schema_options_to_xml
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import value [as 别名]
def schema_options_to_xml(option_type_name, schema_options_d):
"""Option type name is the task-option or option"""
x = XMLBuilder(Constants.WORKFLOW_TEMPLATE_PRESET_ROOT)
# Need to do this getattr to get around how the API works
with getattr(x, option_type_name):
for option_id, schema in schema_options_d.iteritems():
default_value = schema["properties"][option_id]["default"]
if default_value is not None:
with x.option(id=option_id):
default_value = schema["properties"][option_id]["default"]
x.value(str(default_value))
return x