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


Python NonvalidatingReader.parseUri方法代码示例

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


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

示例1: read_file

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
    def read_file(my, file_path, cache=True):
        #my.reader = PyExpat.Reader()
        #my.doc = my.reader.fromUri(file_path)
        # the xml library does not like windows style separators
        try:
            file_path = file_path.replace("\\", "/")

            if not cache:
                my.doc = NonvalidatingReader.parseUri("file://%s" % file_path, my.uri)
            else:
                cur_mtime = os.path.getmtime(file_path)
                cache_mtime = my.XML_FILE_MTIME.get(file_path)

                if cur_mtime == cache_mtime:
                    my.doc = my.XML_FILE_CACHE.get(file_path)
                else:

                    my.doc = NonvalidatingReader.parseUri("file://%s" % file_path, my.uri)
                    my.cache_xml(file_path, my.doc, cur_mtime)



        except Exception, e:
            #print "Error in xml file: ", file_path
            raise XmlException(e)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:27,代码来源:xml_wrapper.py

示例2: __init__

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
 def __init__(self, uri=None, xmlString=None):
   global doc
   if uri is not None:
     doc = NonvalidatingReader.parseUri(uri)
   elif xmlString is not None:
     uri = 'file:bogusFile.txt' # Required by Domlette or it issues a warning.
     doc = NonvalidatingReader.parseString(xmlString, uri)
开发者ID:djw1149,项目名称:cougaar-awb,代码行数:9,代码来源:society_factory2.py

示例3: parseFile

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
 def parseFile(file):
     """File can be an open handle or filesystem path"""
     from Ft.Xml.Domlette import NonvalidatingReader
     if isinstance(file, basestring):
         dom = NonvalidatingReader.parseUri("file:%s" % self._file)
     else:
         dom = NonvalidatingReader.parseStream(file, **kwargs)
     return McmLogFile(dom)
开发者ID:bsmithers,项目名称:hpf,代码行数:10,代码来源:_xml.py

示例4: getConfig

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
	def getConfig(self, configDatastore):
		#xmlFile = open(C.YENCAP_HOME + '/Modules/VERMONT_Module/running.xml')
		#doc = parse(xmlFile)
		
		dataFile = C.YENCAP_HOME + '/Modules/VERMONT_Module/' + configDatastore + '.xml'
		doc = NonvalidatingReader.parseUri("file:" + dataFile)
		
		modulereply = ModuleReply(replynode=doc.documentElement)
		return modulereply
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:11,代码来源:VERMONT_Module.py

示例5: __init__

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
	def __init__(self):
		"""
			Creating new modules for Netconf
			This somewhat define the set of capabilities
			Building the Module Register Table (MRT)
		"""

		self.logFile = C.YENCAP_HOME + "/Modules/LogModule/log.xml"
		self.doc = NonvalidatingReader.parseUri("file:"+self.logFile)
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:11,代码来源:logger.py

示例6: __init__

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
	def __init__(self, uri=None, xmlString=None):
		global doc
		self.hierarchy = {}
		self.levelMap = LevelMap()
		if uri is not None:
			doc = NonvalidatingReader.parseUri(uri)
			self.parse()
		self.highestLevel = 0
		self.createLevelMap()
		print "levelMap:", self.levelMap
开发者ID:djw1149,项目名称:cougaar-awb,代码行数:12,代码来源:organisations.py

示例7: test15CmpZSIc14n

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
 def test15CmpZSIc14n(self):
     ftDoc=NonvalidatingReader.parseUri('file://'+mkPath('windows-ac.xml'))        
     ftOut = StringIO()
     CanonicalPrint(ftDoc, ftOut)
     ftC14n = ftOut.getvalue()
     
     reader = PyExpat.Reader()
     dom = reader.fromStream(open('./windows-ac.xml'))
     
     zsiC14n = Canonicalize(dom)
     self.failUnless(ftC14n == zsiC14n, "ZSI C14N output differs")
开发者ID:philipkershaw,项目名称:ndg-security,代码行数:13,代码来源:test_c14n.py

示例8: test19ExclC14nWithXPathAndInclusiveNSPfx

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
    def test19ExclC14nWithXPathAndInclusiveNSPfx(self):
        # Exclusive C14N applied to portions of a SOAP message by extracting
        # using XPath
        inputFile = mkPath('soapGetAttCertResponse.xml')
        
        from xml.xpath.Context import Context
        from xml import xpath
        from xml.dom.ext.reader import PyExpat
        reader = PyExpat.Reader()
        dom = reader.fromStream(open(inputFile))
        processorNss = \
        {
            'wsu': ("http://docs.oasis-open.org/wss/2004/01/"
                    "oasis-200401-wss-wssecurity-utility-1.0.xsd"),
        }
    
        ctxt = Context(dom, processorNss=processorNss)
        zsiRefNodes = xpath.Evaluate('//*[@wsu:Id]', 
                                  contextNode=dom, 
                                  context=ctxt)

        # 4Suite
        ftDoc=NonvalidatingReader.parseUri('file://'+inputFile)        
        ftOut = StringIO()
        
        # Extract nodes for signing
        xpathExpression = XPath.Compile('//*[@wsu:Id]')
        ctx = XPath.Context.Context(ftDoc, processorNss=processorNss)
        ftRefNodes = xpathExpression.evaluate(ctx)
        
        nsPfx = ['SOAP-ENV', 'ds']
        for zsiRefNode, ftRefNode in zip(zsiRefNodes, ftRefNodes):
            # Get ref node and all it's children
            refSubsetList = getChildNodes(zsiRefNode)
            zsiRefC14n = Canonicalize(dom, None, subset=refSubsetList,
                                      unsuppressedPrefixes=nsPfx)

            print("_"*80)
            print("4Suite C14N with Prefixes %s:\n", zsiRefNode.nodeName)
            print(zsiRefC14n)
        
            # 4Suite equivalent     
            ftOut = StringIO()
            CanonicalPrint(ftRefNode, stream=ftOut, exclusive=True,
                           inclusivePrefixes=nsPfx)
            ftRefC14n = ftOut.getvalue()        
            
            print("_"*80)
            print("4Suite Exclusive C14N %s:\n", ftRefNode.nodeName)
            print(ftRefC14n)

            self.assertEqual(zsiRefC14n, ftRefC14n)
开发者ID:philipkershaw,项目名称:ndg-security,代码行数:54,代码来源:test_c14n.py

示例9: __init__

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
    def __init__ (self, sheet='/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl' ):
        """
        By default i use docbook stylesheet.
        I want to create processor and feed stylesheet before client
        connection, so i can save response time
        """
        #instantiate processor
        self.processor=Processor.Processor()

        # configure stylesheet (like domlette object)
        sheet_uri = Uri.OsPathToUri(sheet,1)
        transform = NonvalidatingReader.parseUri(sheet_uri)
        self.processor.appendStylesheetNode(transform, sheet_uri)
开发者ID:ilusion-linux,项目名称:LuCAS,代码行数:15,代码来源:tldpDoc.py

示例10: get

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
	def get(self, configName):

		if self.files.has_key(configName):
			doc = NonvalidatingReader.parseUri("file:" + self.files[configName])
			moduleReply = ModuleReply(replynode=doc.documentElement)
		else:
			moduleReply = ModuleReply(
			error_type=ModuleReply.APPLICATION,
			error_tag=ModuleReply.OPERATION_FAILED,
			error_severity=ModuleReply.ERROR,
			error_message="Unknown source: " + configName)
			
		return moduleReply
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:15,代码来源:easyModule.py

示例11: tostatic

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
 def tostatic(self, file=None):        
     self._exports = {}
     if file: self._doc = nr.parseUri(file)
     stripws(self._doc)
     names = [getname(i) for i in tags(self._doc, psins, rsrc)]
     classes = [getclass(i) for i in tags(self._doc, psins, rsrc)]
     self._unexpanded = [i for i in tags(self._doc, psins, rsrc)
                         if getclass(i) in names]
     self._templates = [i for i in tags(self._doc, psins, rsrc)
                        if getname(i) in classes]
     self._expandTemplates()
     self._expandResources()
     self._exportResources()
开发者ID:lcrees,项目名称:psilib,代码行数:15,代码来源:processor.py

示例12: test16Cmplxmlc14n

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
 def test16Cmplxmlc14n(self):
     ftDoc=NonvalidatingReader.parseUri('file://'+mkPath('windows-ac.xml'))        
     ftOut = StringIO()
     CanonicalPrint(ftDoc, ftOut)
     ftC14n = ftOut.getvalue()        
     
     from lxml import etree as lxmlET
     
     lxmlElem = lxmlET.parse('./windows-ac.xml')
     lxmlETf = StringIO()
     lxmlElem.write_c14n(lxmlETf)
     lxmlETC14n = lxmlETf.getvalue()
     
     self.failUnless(ftC14n == lxmlETC14n, "lxml C14N output differs")
开发者ID:philipkershaw,项目名称:ndg-security,代码行数:16,代码来源:test_c14n.py

示例13: exchangeCapabilities

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
	def exchangeCapabilities(self, clientsock):
		"""
		Exchange the capabilities with the manager.
		First sends the agent capabilities.
		Then waits for the remote manager capabilities.
		Creates a Netconf session and returns it.
		
		@type  clientsock: socket
		@param clientsock: The socket for the current client
		@rtype: session
		@return: The session created by the SessionManager.
		"""

		# Loading hello element along with static capabilities from hello.xml file
		helloRoot = NonvalidatingReader.parseUri(C.HELLO_URI)
		helloNode = helloRoot.documentElement

		# Finding a unique session-id for that session
		self.session = sessionManager.getInstance().createSession(clientsock, self.username)
		sessionId = self.session.getSessionId()
		LogManager.getInstance().logInfo("opening Netconf session: (sessionId=%s)" % (self.session.getSessionId()))
		
		# Setup the session-id value within session-id node
		sessionIdNode = helloRoot.createElementNS(C.NETCONF_XMLNS, C.SESSION_ID)
		helloNode.appendChild(sessionIdNode)
		sessionIdNode.appendChild(helloRoot.createTextNode(str(sessionId)))
		
		# Get the unique instance of the singleton ModuleManager:
		moduleManager = ModuleManager.getInstance()
		# Add the capabilities related to the modules to the hello message:
		for node in helloNode.childNodes:
			if (node.nodeType== Node.ELEMENT_NODE and node.tagName == C.CAPABILITIES):
				for module in moduleManager.getModules():
					capabNode = helloRoot.createElementNS(C.NETCONF_XMLNS, C.CAPABILITY)
					capabText = helloRoot.createTextNode(module.namespace)
					capabNode.appendChild(capabText)
					node.appendChild(capabNode)

		# Convert the hello element to String before sending
		hellostr = util.convertNodeToString(helloNode)

		# Sending capabilities along with a new session-id
		self.send(hellostr)

		# Receiving capabilities of the manager
		data = self.receive()

		# Printing Manager capabilities
		LogManager.getInstance().logInfo("Manager capabilities received: (sessionId=%s)" % (self.session.getSessionId()))
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:51,代码来源:NetconfService.py

示例14: refreshData

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
	def refreshData(self, sourceName):
		"""
			This method must be called when the RBAC data has been modified
			using Netconf for instance. It parses the rbac.xml file and build a DOM document
		"""

		self.users = []
		self.roles = []
		self.permissions = []

		sourcefilePath = "%s/%s-%s.xml" % (C.YENCAP_CONF_HOME, "RBAC", sourceName)
		destfilePath = "%s/%s-%s.xml" % (C.YENCAP_CONF_HOME, "RBAC", C.RUNNING)
		os.system("cp %s %s" % (sourcefilePath, destfilePath))

		self.rbacdoc = NonvalidatingReader.parseUri("file:"+sourcefilePath).documentElement
		self.buildRbac()
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:18,代码来源:rbacManager.py

示例15: __init__

# 需要导入模块: from Ft.Xml.Domlette import NonvalidatingReader [as 别名]
# 或者: from Ft.Xml.Domlette.NonvalidatingReader import parseUri [as 别名]
    def __init__(self, in_root, options):

        #--
        # Parse the project definition
        #--
        self.options = options
        self.in_root = in_root.rstrip('/\\')
        self.out_root = os.path.join(self.in_root, 'out')
        self.index = '/index.pip'
        self.stylesheet_fname = '/pipp.xsl'
        self.state_xml = os.path.join(in_root, 'pipp.xml')
        self.changed_exports = []
        self.new_project = not os.path.exists(self.state_xml)
        if self.new_project:
            open(self.state_xml, 'w').write('<page src="%s"><exports><link>%s</link></exports></page>'
                    % (self.index, re.sub('.pip$', '.html', self.index)))
        self.state_doc = NonvalidatingReader.parseUri(OsPathToUri(self.state_xml))
        self._processor = None
开发者ID:TheProjecter,项目名称:pipp,代码行数:20,代码来源:pipp.py


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