當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。