コード例 #1
0
 def test_applyMacros(self):
     res = applyMacros('{test=world, blub=!} hello {test}{blub}')
     self.assertEquals(res, 'hello world!')
     res = applyMacros('{\n test = world ,   blub\n=!} hello\n{test}{blub}')
     self.assertEquals(res, 'hello world!')
     res = applyMacros('{test=/muh/blub/nn, blub=!} hello {test}{blub}')
     self.assertEquals(res, 'hello /muh/blub/nn!')
コード例 #2
0
ファイル: test_xml.py プロジェクト: barsch/seishub.core
 def test_applyMacros(self):
     res = applyMacros('{test=world, blub=!} hello {test}{blub}')
     self.assertEquals(res, 'hello world!')
     res = applyMacros('{\n test = world ,   blub\n=!} hello\n{test}{blub}')
     self.assertEquals(res, 'hello world!')
     res = applyMacros('{test=/muh/blub/nn, blub=!} hello {test}{blub}')
     self.assertEquals(res, 'hello /muh/blub/nn!')
コード例 #3
0
ファイル: xmlcatalog.py プロジェクト: personlin/seishub.core
 def query(self, query, full=False):
     """
     Query the catalog via restricted XPath queries.
     
     The values returned depend on the type of query:
     
     Is the location path of a query on resource level, i.e. on rootnode or 
     above (e.g. '/package/resourcetype/*'), ALL indexes known for that 
     resource are requested and returned as a dict.
     
     Does the location path address a node other than the rootnode (e.g.
     '/package/resourcetype/rootnode/node1/node2'), indexed data for that
     node ONLY is returned. 
     Note: The index '/package/resourcetype/rootnode/node1/node2' has to 
     exist, of course. 
     
     The result set is a dict of the form {document_ids : {xpath:value}, 
     ...}. 
     There is an additional key 'ordered' containing an ORDERED list of
     document ids, which is of interest in case there is an order by clause,
     as the dict itself does not preserve order.
     
     For further detail on the restricted XPath query syntax, see 
     L{seishub.xmldb.xpath}
     
     @param query: Restricted XPath query to be executed.
     @type query: basestring
     @param full: If True, picks the resource objects for the results
     @return: Either a list of Resource objects, or a dict
     """
     query = applyMacros(query)
     q = XPathQuery(query)
     results = self.index_catalog.query(q)
     if not full:
         return results
     return [self.xmldb.getResource(document_id=id)
             for id in results['ordered']]