當前位置: 首頁>>代碼示例>>Python>>正文


Python sax.parseString方法代碼示例

本文整理匯總了Python中xml.sax.parseString方法的典型用法代碼示例。如果您正苦於以下問題:Python sax.parseString方法的具體用法?Python sax.parseString怎麽用?Python sax.parseString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xml.sax的用法示例。


在下文中一共展示了sax.parseString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import parseString [as 別名]
def main():
    xmlString = "<note>\n<to>Tove</to>\n<from>Jani</from>\n<heading>Reminder</heading>\n<body>Don't forget me this weekend!</body>\n</note>"
    # bad
    xml.sax.parseString(xmlString, ExampleContentHandler())
    xml.sax.parse('notaxmlfilethatexists.xml', ExampleContentHandler())
    sax.parseString(xmlString, ExampleContentHandler())
    sax.parse('notaxmlfilethatexists.xml', ExampleContentHandler)

    # good
    defusedxml.sax.parseString(xmlString, ExampleContentHandler())

    # bad
    xml.sax.make_parser()
    sax.make_parser()
    print('nothing')
    # good
    defusedxml.sax.make_parser() 
開發者ID:PyCQA,項目名稱:bandit,代碼行數:19,代碼來源:xml_sax.py

示例2: parse

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import parseString [as 別名]
def parse(self, desc):
        sax.parseString(desc, self) 
開發者ID:alesnav,項目名稱:p2ptv-pi,代碼行數:4,代碼來源:upnp.py

示例3: fetch_index

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import parseString [as 別名]
def fetch_index():
    """Return an iterable of every project name on PyPI."""

    r = requests.get('https://pypi.python.org/simple/')
    sax_handler = PyPIIndexHandler()
    sax.parseString(r.text, sax_handler)
    return sax_handler.projects 
開發者ID:ourresearch,項目名稱:depsy,代碼行數:9,代碼來源:get_pypi_packages_metadata.py

示例4: __init__

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import parseString [as 別名]
def __init__(self, topologyFile):
		""" Initialize with the topology file reference ready for reading """
		handler = TopologyHandler()
		sax.make_parser()
		sax.parseString(topologyFile.read(), handler)
		self.residues = handler.residues 
開發者ID:MonZop,項目名稱:BioBlender,代碼行數:8,代碼來源:topology.py

示例5: __init__

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import parseString [as 別名]
def __init__(self):
        """
            Create a new Definition Object
        """
        self.map = {}
        self.patches = {}

        handler = DefinitionHandler()
        sax.make_parser()

        for path in [AAPATH, NAPATH]:
            defpath = getDatFile(path)
            if defpath == "":
                raise ValueError, "%s not found!" % path

            file = open(defpath)
            sax.parseString(file.read(), handler)
            file.close()

            self.map.update(handler.map)
    
        # Now handle patches

        defpath = getDatFile(PATCHPATH)
        if defpath == "":
            raise ValueError, "%s not found!" % PATCHPATH
     
        handler.map = {}
        file = open(defpath)
        sax.parseString(file.read(), handler)
        file.close()

        # Apply specific patches to the reference object, allowing users
        #  to specify protonation states in the PDB file
        
        for patch in handler.patches:
            if patch.newname != "":

                # Find all residues matching applyto

                resnames = self.map.keys()
                for name in resnames:
                    regexp = re.compile(patch.applyto).match(name)
                    if not regexp: continue
                    newname = patch.newname.replace("*", name)
                    self.addPatch(patch, name, newname)
                  

            # Either way, make sure the main patch name is available
            
            self.addPatch(patch, patch.applyto, patch.name) 
開發者ID:MonZop,項目名稱:BioBlender,代碼行數:53,代碼來源:definitions.py


注:本文中的xml.sax.parseString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。