本文整理汇总了Python中lxml.objectify.Element.append方法的典型用法代码示例。如果您正苦于以下问题:Python Element.append方法的具体用法?Python Element.append怎么用?Python Element.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lxml.objectify.Element
的用法示例。
在下文中一共展示了Element.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_xml
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def to_xml(self, value, param_name):
wrapper = Element(param_name)
for _dict in value:
wrapper.append(self.get_xml_dict(_dict, 'dict'))
return wrapper
示例2: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
definition_list = Element('definition_list')
definitions = job_list(session, params['cluster_id'])
for definition in definitions:
definition_elem = Element('definition')
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.is_active = definition.is_active
definition_elem.job_type = definition.job_type
definition_elem.start_date = definition.start_date
definition_elem.extra = definition.extra.decode('utf-8')
definition_elem.service_id = definition.service_id
definition_elem.service_name = definition.service_name.decode('utf-8')
definition_elem.weeks = definition.weeks if definition.weeks else ''
definition_elem.days = definition.days if definition.days else ''
definition_elem.hours = definition.hours if definition.hours else ''
definition_elem.minutes = definition.minutes if definition.minutes else ''
definition_elem.seconds = definition.seconds if definition.seconds else ''
definition_elem.repeats = definition.repeats if definition.repeats else ''
definition_elem.cron_definition = (definition.cron_definition.decode('utf-8') if
definition.cron_definition else '')
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例3: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
definition_list = Element('definition_list')
definitions = def_jms_wmq_list(session, params['cluster_id'])
for definition in definitions:
definition_elem = Element('definition')
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.host = definition.host
definition_elem.port = definition.port
definition_elem.queue_manager = definition.queue_manager
definition_elem.channel = definition.channel
definition_elem.cache_open_send_queues = definition.cache_open_send_queues
definition_elem.cache_open_receive_queues = definition.cache_open_receive_queues
definition_elem.use_shared_connections = definition.use_shared_connections
definition_elem.ssl = definition.ssl
definition_elem.ssl_cipher_spec = definition.ssl_cipher_spec
definition_elem.ssl_key_repository = definition.ssl_key_repository
definition_elem.needs_mcd = definition.needs_mcd
definition_elem.max_chars_printed = definition.max_chars_printed
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例4: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id', 'connection', 'transport'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = http_soap_list(session, params['cluster_id'], params['connection'], params['transport'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.is_internal = db_item.is_internal
item.url_path = db_item.url_path
item.method = db_item.method
item.soap_action = db_item.soap_action
item.soap_version = db_item.soap_version
item.service_id = db_item.service_id
item.service_name = db_item.service_name
item.security_id = db_item.security_id
item.security_name = db_item.security_name
item.security_def_type = db_item.security_def_type
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)
示例5: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = out_amqp_list(session, params['cluster_id'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.delivery_mode = db_item.delivery_mode
item.priority = db_item.priority
item.content_type = db_item.content_type
item.content_encoding = db_item.content_encoding
item.expiration = db_item.expiration
item.user_id = db_item.user_id
item.app_id = db_item.app_id
item.def_name = db_item.def_name
item.def_id = db_item.def_id
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)
示例6: convert
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def convert(self, param, param_name, value, has_simple_io_config, is_xml, date_time_format=None):
try:
if any(param_name.startswith(prefix) for prefix in self.bool_parameter_prefixes) or isinstance(param, Boolean):
value = asbool(value or None) # value can be an empty string and asbool chokes on that
if value and value is not None: # Can be a 0
if isinstance(param, Boolean):
value = asbool(value)
elif isinstance(param, CSV):
value = value.split(',')
elif isinstance(param, List):
if is_xml:
# We are parsing XML to create a SIO request
if isinstance(value, EtreeElement):
return [elem.text for elem in value.getchildren()]
# We are producing XML out of an SIO response
else:
wrapper = Element(param_name)
for item_value in value:
xml_item = Element('item')
wrapper.append(xml_item)
wrapper.item[-1] = item_value
return wrapper
# This is a JSON list
return value
elif isinstance(param, Integer):
value = int(value)
elif isinstance(param, Unicode):
value = unicode(value)
elif isinstance(param, UTC):
value = value.replace('+00:00', '')
else:
if value and value != ZATO_NONE and has_simple_io_config:
if any(param_name==elem for elem in self.int_parameters) or \
any(param_name.endswith(suffix) for suffix in self.int_parameter_suffixes):
value = int(value)
if date_time_format and isinstance(value, datetime):
value = value.strftime(date_time_format)
if isinstance(param, CSV) and not value:
value = []
return value
except Exception, e:
msg = 'Conversion error, param:[{}], param_name:[{}], repr(value):[{}], e:[{}]'.format(
param, param_name, repr(value), format_exc(e))
logger.error(msg)
raise ZatoException(msg=msg)
示例7: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
definition_list = Element("definition_list")
params = _get_params(kwargs.get("payload"), ["cluster_id"], "data.")
definitions = tech_acc_list(session, params["cluster_id"])
for definition in definitions:
definition_elem = Element("definition")
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.is_active = definition.is_active
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例8: get_xml_dict
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def get_xml_dict(self, _dict, name):
xml_dict = Element(name)
for k, v in _dict.items():
xml_item = Element('item')
key = Element('key')
value = Element('value')
xml_item.key = key
xml_item.value = value
xml_item.key[-1] = k
xml_item.value[-1] = v
xml_dict.append(xml_item)
return xml_dict
示例9: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
definition_list = Element('definition_list')
definitions = basic_auth_list(session, params['cluster_id'])
for definition in definitions:
definition_elem = Element('definition')
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.is_active = definition.is_active
definition_elem.username = definition.username
definition_elem.domain = definition.domain
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例10: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = out_s3_list(session, params['cluster_id'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.prefix_ = db_item.prefix
item.separator = db_item.separator
item.key_sync_timeout = db_item.key_sync_timeout
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)
示例11: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = service_list(session, params['cluster_id'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.impl_name = db_item.impl_name
item.is_internal = db_item.is_internal
item.usage_count = 'TODO getlist'
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)
示例12: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = channel_zmq_list(session, params['cluster_id'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.address = db_item.address
item.socket_type = db_item.socket_type
item.sub_key = db_item.sub_key
item.service_name = db_item.service_name
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)
示例13: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
definition_list = Element('definition_list')
definitions = wss_list(session, params['cluster_id'])
for definition in definitions:
definition_elem = Element('definition')
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.is_active = definition.is_active
definition_elem.password_type = definition.password_type
definition_elem.username = definition.username
definition_elem.reject_empty_nonce_ts = definition.reject_empty_nonce_ts
definition_elem.reject_stale_username = definition.reject_stale_username
definition_elem.expiry_limit = definition.expiry_limit
definition_elem.nonce_freshness = definition.nonce_freshness
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例14: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
definition_list = Element('definition_list')
pairs = (('basic_auth', basic_auth_list),
('tech_acc', tech_acc_list),
('wss_username_password', wss_list))
for def_type, meth in pairs:
definitions = meth(session, params['cluster_id'])
for definition in definitions:
definition_elem = Element('definition')
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.def_type = def_type
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例15: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import append [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = out_ftp_list(session, params['cluster_id'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.host = db_item.host
item.port = db_item.port
item.user = db_item.user
item.acct = db_item.acct
item.timeout = db_item.timeout
item.dircache = db_item.dircache
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)