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


Python cElementTree.parse方法代码示例

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


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

示例1: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'softPkg'
        rootClass = softPkg
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:spd.py

示例2: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'devicepkg'
        rootClass = devicepkg
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:dpd.py

示例3: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'deviceconfiguration'
        rootClass = deviceconfiguration
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:dcd.py

示例4: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'domainmanagerconfiguration'
        rootClass = domainmanagerconfiguration
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:dmd.py

示例5: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'profile'
        rootClass = profile
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:profile.py

示例6: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'softwareassembly'
        rootClass = softwareassembly
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:sad.py

示例7: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'softwarecomponent'
        rootClass = softwarecomponent
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:scd.py

示例8: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'properties'
        rootClass = properties
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag,
##         namespacedef_='',
##         pretty_print=True)
    return rootObj 
开发者ID:RedhawkSDR,项目名称:core-framework,代码行数:18,代码来源:prf.py

示例9: _le_xml

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def _le_xml(self, arquivo):
        if arquivo is None:
            return False

        if not isinstance(arquivo, basestring):
            arquivo = etree.tounicode(arquivo)

        if arquivo is not None:
            if isinstance(arquivo, basestring): 
                if NAMESPACE_NFSE in arquivo:
                    arquivo = por_acentos(arquivo)
                if u'<' in arquivo:
                    self._xml = etree.fromstring(tira_abertura(arquivo))
                else:
                    arq = open(arquivo)
                    txt = ''.join(arq.readlines())
                    txt = tira_abertura(txt)
                    arq.close()
                    self._xml = etree.fromstring(txt)
            else:
                self._xml = etree.parse(arquivo)
            return True

        return False 
开发者ID:thiagopena,项目名称:PySIGNFe,代码行数:26,代码来源:base.py

示例10: validar

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def validar(self):
        arquivo_esquema = self.caminho_esquema + self.arquivo_esquema
        
        # Aqui é importante remover a declaração do encoding
        # para evitar erros de conversão unicode para ascii
        xml = tira_abertura(self.xml).encode(u'utf-8')
        
        esquema = etree.XMLSchema(etree.parse(arquivo_esquema))
        
        if not esquema.validate(etree.fromstring(xml)):
            for e in esquema.error_log:
                if e.level == 1:
                    self.alertas.append(e.message.replace('{http://www.portalfiscal.inf.br/nfe}', ''))
                elif e.level == 2:
                    self.erros.append(e.message.replace('{http://www.portalfiscal.inf.br/nfe}', ''))
        
        return esquema.error_log 
开发者ID:thiagopena,项目名称:PySIGNFe,代码行数:19,代码来源:base.py

示例11: process_file

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def process_file(tcxfile, lever):
    """
    Process the whole TCX file.
    """

    tree = etree.parse(tcxfile)
    root = tree.getroot()

    tracks = []

    for element in root.iter():
        if element.tag == '{%s}Track'%ns1:
            tracks.append(element)

    for element in tracks:
        process_track(element, lever)

    new_name = "vpower_" + tcxfile
    tree.write(new_name, encoding='utf-8', xml_declaration=True) 
开发者ID:cast42,项目名称:vpower,代码行数:21,代码来源:vpower.py

示例12: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName, silence=False):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'entry'
        rootClass = entry
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='',
            pretty_print=True)
    return rootObj 
开发者ID:mgalardini,项目名称:pdb2uniprot,代码行数:20,代码来源:parse_sifts.py

示例13: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName, silence=False):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'QueryResultType'
        rootClass = QueryResultType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='',
            pretty_print=True)
    return rootObj 
开发者ID:blackms,项目名称:vCloudDirectorManager,代码行数:20,代码来源:queryRecordViewType.py

示例14: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName, silence=False):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'OrganizationReferenceType'
        rootClass = OrganizationReferenceType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='',
            pretty_print=True)
    return rootObj 
开发者ID:blackms,项目名称:vCloudDirectorManager,代码行数:20,代码来源:vCloudEntities.py

示例15: parse

# 需要导入模块: import cElementTree [as 别名]
# 或者: from cElementTree import parse [as 别名]
def parse(inFileName, silence=False):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'TaskType'
        rootClass = TaskType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='',
            pretty_print=True)
    return rootObj 
开发者ID:blackms,项目名称:vCloudDirectorManager,代码行数:20,代码来源:taskType.py


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