source: exist/trunk/python/ndgeXist/ndgXqueries.py @ 3111

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/python/ndgeXist/ndgXqueries.py@3111
Revision 3111, 928 bytes checked in by lawrence, 12 years ago (diff)

eggification of xqueries proceeds ...

Line 
1import pkg_resources
2class ndgXqueries(object):
3    ''' Holds a set of ndg xqueries after having read them from disk (which is
4    done in order to share the xqueries amongst different applications and
5    programming languages). '''
6    def __init__(self,directory='xquery'):
7        ''' Loads up xqueries from the internal package directory '''
8        files=pkg_resources.resource_listdir('ndgeXist',directory)
9        # this next bit to get rid of .svn and anything else in testing
10        xq=[]
11        for f in files:
12            if f.find('.xq')!=-1: xq.append(f)
13        self.xq=dict([(f.strip('.xq'),pkg_resources.resource_string('ndgeXist','%s/%s'%(directory,f))) for f in xq])
14    def __setitem__(self,key,value):
15        ''' Add a new xquery to the xquery database dynamically'''
16        self.xq[key]=value
17    def __getitem__(self,key):
18        return self.xq[key]
19    def keys(self):
20        return self.xq.keys()
Note: See TracBrowser for help on using the repository browser.