本文整理汇总了Python中cElementTree.iselement方法的典型用法代码示例。如果您正苦于以下问题:Python cElementTree.iselement方法的具体用法?Python cElementTree.iselement怎么用?Python cElementTree.iselement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cElementTree
的用法示例。
在下文中一共展示了cElementTree.iselement方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetXmlBlob
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def SetXmlBlob(self, blob):
"""Sets the contents of the extendedProperty to XML as a child node.
Since the extendedProperty is only allowed one child element as an XML
blob, setting the XML blob will erase any preexisting extension elements
in this object.
Args:
blob: str, ElementTree Element or atom.ExtensionElement representing
the XML blob stored in the extendedProperty.
"""
# Erase any existing extension_elements, clears the child nodes from the
# extendedProperty.
self.extension_elements = []
if isinstance(blob, atom.ExtensionElement):
self.extension_elements.append(blob)
elif ElementTree.iselement(blob):
self.extension_elements.append(atom._ExtensionElementFromElementTree(
blob))
else:
self.extension_elements.append(atom.ExtensionElementFromString(blob))
示例2: __SendDataPart
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def __SendDataPart(data, connection):
"""This method is deprecated, use atom.http._send_data_part"""
deprecated('call to deprecated function __SendDataPart')
if isinstance(data, str):
#TODO add handling for unicode.
connection.send(data)
return
elif ElementTree.iselement(data):
connection.send(ElementTree.tostring(data))
return
# Check to see if data is a file-like object that has a read method.
elif hasattr(data, 'read'):
# Read the file and send it a chunk at a time.
while 1:
binarydata = data.read(100000)
if binarydata == '': break
connection.send(binarydata)
return
else:
# The data object was not a file.
# Try to convert to a string and send the data.
connection.send(str(data))
return
示例3: CalculateDataLength
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def CalculateDataLength(data):
"""Attempts to determine the length of the data to send.
This method will respond with a length only if the data is a string or
and ElementTree element.
Args:
data: object If this is not a string or ElementTree element this funtion
will return None.
"""
if isinstance(data, str):
return len(data)
elif isinstance(data, list):
return None
elif ElementTree.iselement(data):
return len(ElementTree.tostring(data))
elif hasattr(data, 'read'):
# If this is a file-like object, don't try to guess the length.
return None
else:
return len(str(data))
示例4: from_xml
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def from_xml(self, elem, handle=None):
"""This method creates the object from the xml representation
of the Method object."""
self._handle = handle
if elem.attrib:
for attr_name, attr_value in imcgenutils.iteritems(elem.attrib):
self.attr_set(imcgenutils.convert_to_python_var_name(attr_name),
str(attr_value))
child_elems = elem.getchildren()
if child_elems:
for child_elem in child_elems:
if not Et.iselement(child_elem):
continue
cln = imcgenutils.word_u(child_elem.tag)
child = imccoreutils.get_imc_obj(cln, child_elem)
self._child.append(child)
child.from_xml(child_elem, handle)
示例5: from_xml
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def from_xml(self, elem, handle=None):
"""This method creates the object from the xml representation
of the Method object."""
self._handle = handle
if elem.attrib:
for attr_name, attr_value in ucscgenutils.iteritems(elem.attrib):
self.attr_set(
ucscgenutils.convert_to_python_var_name(attr_name),
str(attr_value))
child_elems = elem.getchildren()
if child_elems:
for child_elem in child_elems:
if not ET.iselement(child_elem):
continue
cln = ucscgenutils.word_u(child_elem.tag)
child = ucsccoreutils.get_ucsc_obj(cln, child_elem)
self._child.append(child)
child.from_xml(child_elem, handle)
示例6: set_prefixes
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def set_prefixes(self, elem, prefix_map):
# check if this is a tree wrapper
if not ElementTree.iselement(elem):
elem = elem.getroot()
# build uri map and add to root element
uri_map = {}
for prefix, uri in prefix_map.items():
uri_map[uri] = prefix
elem.set("xmlns:" + prefix, uri)
# fixup all elements in the tree
memo = {}
for elem in elem.getiterator():
self.fixup_element_prefixes(elem, uri_map, memo)
示例7: from_xml
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def from_xml(self, elem, handle=None):
"""Method updates/fills the object from the xml representation
of the external method object. """
self._handle = handle
if elem.attrib:
for attr_name, attr_value in imcgenutils.iteritems(elem.attrib):
if attr_name in self.__property_map:
attr = self.__property_map[attr_name]
method_prop_meta = self.__property_meta[attr]
if method_prop_meta.inp_out == "Input" or (
method_prop_meta.is_complex_type):
continue
self.set_attr(attr, str(attr_value))
elif attr_name in ExternalMethod._external_method_attrs:
self.set_attr(
ExternalMethod._external_method_attrs[attr_name],
str(attr_value))
child_elems = elem.getchildren()
if child_elems:
for child_elem in child_elems:
if not ET.iselement(child_elem):
continue
child_name = child_elem.tag
if child_name in self.__property_map:
child_name = self.__property_map[child_name]
method_prop_meta = self.__property_meta[
child_name]
if method_prop_meta.inp_out == "Output" and \
(method_prop_meta.is_complex_type):
child_obj = imccoreutils.get_imc_obj(
method_prop_meta.field_type,
child_elem)
if child_obj:
self.set_attr(child_name,
child_obj)
# print child_method_obj.__dict__
child_obj.from_xml(child_elem, handle)
示例8: from_xml
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def from_xml(self, elem, handle=None):
"""Method updates/fills the object from the xml representation
of the external method object. """
self._handle = handle
if elem.attrib:
for attr_name, attr_value in ucscgenutils.iteritems(
elem.attrib):
if attr_name in self.__property_map:
attr = self.__property_map[attr_name]
method_prop_meta = self.__property_meta[attr]
if method_prop_meta.inp_out == "Input" or (
method_prop_meta.is_complex_type):
continue
self.set_attr(attr, str(attr_value))
elif attr_name in ExternalMethod._external_method_attrs:
self.set_attr(
ExternalMethod._external_method_attrs[attr_name],
str(attr_value))
child_elems = elem.getchildren()
if child_elems:
for child_elem in child_elems:
if not ET.iselement(child_elem):
continue
child_name = child_elem.tag
if child_name in self.__property_map:
child_name = self.__property_map[child_name]
method_prop_meta = self.__property_meta[
child_name]
if method_prop_meta.inp_out == "Output" and \
(method_prop_meta.is_complex_type):
child_obj = ucsccoreutils.get_ucsc_obj(
method_prop_meta.field_type,
child_elem)
if child_obj is not None:
self.set_attr(child_name,
child_obj)
child_obj.from_xml(child_elem, handle)
示例9: from_xml
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def from_xml(self, elem, handle=None):
"""
Method updates the object from the xml representation of the managed
object.
"""
self._handle = handle
if elem.attrib:
if self.__class__.__name__ != "ManagedObject":
for attr_name, attr_value in imcgenutils.iteritems(elem.attrib):
if imccoreutils.property_exists_in_prop_map(self,
attr_name):
attr_name = \
imccoreutils.get_property_from_prop_map(self,
attr_name)
else:
self.__xtra_props[attr_name] = _GenericProp(
attr_name,
attr_value,
False)
object.__setattr__(self, attr_name, attr_value)
else:
for attr_name, attr_value in imcgenutils.iteritems(elem.attrib):
object.__setattr__(self, attr_name, attr_value)
if hasattr(self, 'rn') and not hasattr(self, 'dn'):
self._dn_set()
elif not hasattr(self, 'rn') and hasattr(self, 'dn'):
self.__set_prop("rn", os.path.basename(self.dn), forced=True)
self.mark_clean()
child_elems = elem.getchildren()
if child_elems:
for child_elem in child_elems:
if not ET.iselement(child_elem):
continue
if self.__class__.__name__ != "ManagedObject":
mo_meta = imccoreutils.get_mo_meta(self)
field_names = mo_meta.field_names
if field_names and child_elem.tag in field_names:
pass
class_id = imcgenutils.word_u(child_elem.tag)
child_obj = imccoreutils.get_imc_obj(class_id, child_elem,
self)
self.child_add(child_obj)
child_obj.from_xml(child_elem, handle)
示例10: from_xml
# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import iselement [as 别名]
def from_xml(self, elem, handle=None):
"""
Method updates the object from the xml representation of the managed
object.
"""
self._handle = handle
if elem.attrib:
if self.__class__.__name__ != "ManagedObject":
for attr_name, attr_value in ucscgenutils.iteritems(
elem.attrib):
if attr_name in self.prop_map:
attr_name = self.prop_map[attr_name]
else:
self.__xtra_props[attr_name] = _GenericProp(
attr_name,
attr_value,
False)
object.__setattr__(self, attr_name, attr_value)
else:
for attr_name, attr_value in ucscgenutils.iteritems(
elem.attrib):
object.__setattr__(self, attr_name, attr_value)
if hasattr(self, 'rn') and not hasattr(self, 'dn'):
self._dn_set()
elif not hasattr(self, 'rn') and hasattr(self, 'dn'):
self.__set_prop("rn", os.path.basename(self.dn), forced=True)
self.mark_clean()
child_elems = elem.getchildren()
if child_elems:
for child_elem in child_elems:
if not ET.iselement(child_elem):
continue
if self.__class__.__name__ != "ManagedObject" and (
child_elem.tag in self.mo_meta.field_names):
pass
class_id = ucscgenutils.word_u(child_elem.tag)
child_obj = ucsccoreutils.get_ucsc_obj(class_id,
child_elem,
self)
self.child_add(child_obj)
child_obj.from_xml(child_elem, handle)