当前位置: 首页>>代码示例>>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;未经允许,请勿转载。