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


Python ElementTree.Element方法代码示例

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


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

示例1: getsummary

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def getsummary(description):

    description = flatten(description)

    # extract the first sentence from the description
    m = re.search("(?s)(.+?\.)\s", description + " ")
    if m:
        return m.group(1)

    return description # sorry

##
# (Helper) Parses HTML descriptor text into an XHTML structure.
#
# @param parser Parser instance (provides a warning method).
# @param text Text fragment.
# @return An element tree containing XHTML data.
# @defreturn Element. 
开发者ID:alexfeng,项目名称:InternationalizationScript-iOS,代码行数:20,代码来源:pythondoc.py

示例2: skip_subject_body

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def skip_subject_body(self, type, token, start, end, line):
        # for now, just hand control back to the pythondoc scanner,
        # and let it skip over the subject body while looking for the
        # next marker.
        return self.look_for_pythondoc(type, token, start, end, line)

##
# Parses a module.
# <p>
# This function creates a {@link #ModuleParser} instance, and uses it
# to parse the given file.  For details, see {@linkplain #ModuleParser
# the <b>ModuleParser</b> documentation}.
#
# @param file Name of the module source file, or a file object.
# @param prefix Optional name prefix.
# @keyparam docstring If true, look for markup in docstrings.
# @return An element tree containing the module description.
# @defreturn Element.
# @exception IOError If the file could not be found, or could not
#    be opened for reading. 
开发者ID:alexfeng,项目名称:InternationalizationScript-iOS,代码行数:22,代码来源:pythondoc.py

示例3: to_xml_str

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def to_xml_str(self, pretty_print=False):

        attr = {}

        if self.version:
            attr[SDX_SUNSPEC_DATA_VERSION] = self.version

        self.root = ET.Element(SDX_SUNSPEC_DATA, attrib=attr)
        for d in self.device_data:
            d.to_xml(self.root)

        if pretty_print:
            util.indent(self.root)

        out = ET.tostring(self.root)
        if sys.version_info > (3,):
            temp = ""
            for i in out:
                temp += chr(i)
            out = temp

        return out 
开发者ID:sunspec,项目名称:pysunspec,代码行数:24,代码来源:data.py

示例4: to_pics

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def to_pics(self, parent, single_repeating=True):
        """Adds the device and all elements within the device to the parent
        element. If *single_repeating* is True, only the first repeating block
        for each model is added to the document.

        Parameters:

            parent :
                Element Tree element on which to place the device element.

            single_repeating :
                Flag to indicate whether to include a single or all repeating
                blocks within each model in the PICS document.
        """

        attr = {pics.PICS_ATTR_VERSION: str(pics.PICS_VERSION)}

        e = ET.SubElement(parent, pics.PICS_DEVICE, attrib=attr)

        for model in self.models_list:
            model.to_pics(e, single_repeating=single_repeating) 
开发者ID:sunspec,项目名称:pysunspec,代码行数:23,代码来源:device.py

示例5: from_pics

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def from_pics(self, element):
        """Sets the block contents based on an element tree model type element
        contained in a SunSpec PICS document.

        Parameters:

            element :
                Element Tree model element.
        """

        for p in element.findall('*'):
            if p.tag != pics.PICS_POINT:
                raise SunSpecError("Unexpected '{}' element in '{}' element".format(p.tag, element.tag))
            pid = p.attrib.get(pics.PICS_ATTR_ID)
            point = self.points.get(pid)
            if point is None:
                point = self.points_sf.get(pid)
            if point is not None:
                point.from_pics(p)

        # resolve scale factor values in points, must be done after all points in block are read
        for point in self.points_list:
            if point.sf_point is not None:
                point.value_sf = point.sf_point.value_base 
开发者ID:sunspec,项目名称:pysunspec,代码行数:26,代码来源:device.py

示例6: Element

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def Element(tag, attrib=None, nsmap=None, nsdict=CNSD):
    if attrib is None:
        attrib = {}
    tag, attrib = fix_ns(tag, attrib, nsdict)
    if WhichElementTree == 'lxml':
        el = etree.Element(tag, attrib, nsmap=nsmap)
    else:
        el = _ElementInterfaceWrapper(tag, attrib)
    return el 
开发者ID:skarlekar,项目名称:faces,代码行数:11,代码来源:__init__.py

示例7: create_manifest

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def create_manifest(self):
        if WhichElementTree == 'lxml':
            root = Element('manifest:manifest',
                nsmap=MANIFEST_NAMESPACE_DICT,
                nsdict=MANIFEST_NAMESPACE_DICT,
                )
        else:
            root = Element('manifest:manifest',
                attrib=MANIFEST_NAMESPACE_ATTRIB,
                nsdict=MANIFEST_NAMESPACE_DICT,
                )
        doc = etree.ElementTree(root)
        SubElement(root, 'manifest:file-entry', attrib={
            'manifest:media-type': self.MIME_TYPE,
            'manifest:full-path': '/',
            }, nsdict=MANNSD)
        SubElement(root, 'manifest:file-entry', attrib={
            'manifest:media-type': 'text/xml',
            'manifest:full-path': 'content.xml',
            }, nsdict=MANNSD)
        SubElement(root, 'manifest:file-entry', attrib={
            'manifest:media-type': 'text/xml',
            'manifest:full-path': 'styles.xml',
            }, nsdict=MANNSD)
        SubElement(root, 'manifest:file-entry', attrib={
            'manifest:media-type': 'text/xml',
            'manifest:full-path': 'settings.xml',
            }, nsdict=MANNSD)
        SubElement(root, 'manifest:file-entry', attrib={
            'manifest:media-type': 'text/xml',
            'manifest:full-path': 'meta.xml',
            }, nsdict=MANNSD)
        s1 = ToString(doc)
        doc = minidom.parseString(s1)
        s1 = doc.toprettyxml('  ')
        return s1 
开发者ID:skarlekar,项目名称:faces,代码行数:38,代码来源:__init__.py

示例8: add_doc_title

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def add_doc_title(self):
        text = self.settings.title
        if text:
            self.title = text
            if not self.found_doc_title:
                el = Element('text:p', attrib = {
                    'text:style-name': self.rststyle('title'),
                    })
                el.text = text
                self.body_text_element.insert(0, el)
        el = self.find_first_text_p(self.body_text_element)
        if el is not None:
            self.attach_page_style(el) 
开发者ID:skarlekar,项目名称:faces,代码行数:15,代码来源:__init__.py

示例9: handle_basic_atts

# 需要导入模块: from elementtree import ElementTree [as 别名]
# 或者: from elementtree.ElementTree import Element [as 别名]
def handle_basic_atts(self, node):
        if isinstance(node, nodes.Element) and node['ids']:
            self.pending_ids += node['ids'] 
开发者ID:skarlekar,项目名称:faces,代码行数:5,代码来源:__init__.py


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