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


Python Element.item[-1]方法代码示例

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


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

示例1: to_xml

# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import item[-1] [as 别名]
 def to_xml(self, value, param_name):
     wrapper = Element(param_name)
     for item_value in value:
         xml_item = Element('item')
         wrapper.append(xml_item)
         wrapper.item[-1] = item_value
     return wrapper
开发者ID:grenzi,项目名称:ctakes_exploration,代码行数:9,代码来源:sio.py

示例2: convert

# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import item[-1] [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)
开发者ID:systamonster,项目名称:zato,代码行数:60,代码来源:__init__.py


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