Changeset 4483
- Timestamp:
- 24/11/08 09:53:38 (12 years ago)
- Location:
- exist/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
exist/trunk/python/ndgUtils/eXistInterface.py
r4430 r4483 113 113 114 114 logging.info("Executing xquery search") 115 logging.debug(" - query: '%s'" %xquery) 115 116 r=self.executeChunkedQuery(str(xquery),start,howmany) 116 117 logging.info("Search complete - processing results") -
exist/trunk/python/ndgUtils/models/existdbclient.py
r4433 r4483 310 310 colData = {} 311 311 for member in et: 312 col = member.findtext('{http://www.w3.org/2005/Atom}fileName')313 key = data.split('/')[-1]314 key = key.split('.')[0]315 val = '/'.join(data.split('/')[0:-1])316 colData[ key] = val312 collection = member.findtext('{http://www.w3.org/2005/Atom}fileName') 313 fileName = collection.split('/')[-1] 314 fileName = fileName.split('.')[0] 315 dir = '/'.join(collection.split('/')[0:-1]) 316 colData[fileName] = dir 317 317 318 318 logging.debug("Finished looking up atom paths") -
exist/trunk/python/ndgUtils/ndgObject.py
r4430 r4483 106 106 107 107 # set default return format - if not set, just return in original format 108 fmt='' 109 if self.config.has_option('DISCOVERY','formatDefault'): 110 fmt=self.config.get('DISCOVERY','formatDefault') 108 fmt = self.config.get('DISCOVERY','formatDefault') 109 if fmt: 111 110 logging.info("Default discovery format set to: %s" %fmt) 112 111 … … 120 119 # config file should have details on the service to use for the repository 121 120 # - if not, default to 'unknown' 122 servicehost = 'unknown'123 if self.config.has_option('NDG_B_SERVICE',self.repository):124 servicehost =self.config.get('NDG_B_SERVICE',self.repository)121 servicehost = self.config.get('NDG_B_SERVICE',self.repository) 122 if not servicehost: 123 servicehost = 'unknown' 125 124 126 125 # If this record is itself a discovery record, then we don't have much more to do … … 130 129 self.printableURL=self.__buildURL(discoveryBASE,[qs,('format','xml')]) 131 130 self.URL=self.discoveryURL 132 if servicehost!='unknown':self.gettable=1 131 if servicehost != 'unknown': 132 self.gettable=1 133 133 elif self.schema in self.BROWSE_SCHEMES: 134 134 # One day we'll use a service binding to get this … … 141 141 self.xmlURL=url.replace('/view/','/retrieve/')+'?format=raw' 142 142 self.printableURL=url+'?format=xml' 143 if servicehost!='unknown': self.gettable=0 143 if servicehost !='unknown': 144 self.gettable=0 144 145 self.useDiscoveryService = 0 145 146 else: -
exist/trunk/python/ndgUtils/ndgXqueries.py
r3840 r4483 2 2 import re 3 3 class ndgXqueries(object): 4 ''' Holds a set of ndg xqueries after having read them from disk (which is 4 ''' 5 Holds a set of ndg xqueries after having read them from disk (which is 5 6 done in order to share the xqueries amongst different applications and 6 programming languages). ''' 7 programming languages). 8 ''' 9 ATOM_MOLES_SCHEMA = "molesAtom1.0" 7 10 def __init__(self,directory='xquery'): 8 11 ''' Loads up xqueries from the internal package directory ''' … … 10 13 # this next bit to get rid of .svn and anything else in testing 11 14 xq=[] 15 xsd = [] 12 16 for f in files: 13 if f.find('.xq')!=-1: xq.append(f) 17 if f.find('.xq') != -1: 18 xq.append(f) 19 elif f.find('.xsd') != -1: 20 xsd.append(f) 21 14 22 #remember that .rstrip doesn't quite do what you think it does :-) 15 self.xq=dict([(re.sub('.xq\Z','',f),pkg_resources.resource_string('ndgUtils','%s/%s'%(directory,f))) for f in xq]) 23 self.xq = dict([(re.sub('.xq\Z','',f),\ 24 pkg_resources.resource_string('ndgUtils','%s/%s'%(directory,f))) for f in xq]) 25 self.xsd = dict([(re.sub('.xsd\Z','',f),\ 26 pkg_resources.resource_string('ndgUtils',\ 27 '%s/%s'%(directory, f))) for f in xsd]) 16 28 17 29 # add the various xquery libraries, too … … 24 36 continue 25 37 26 #re.sub('.xquery\Z','',f)] = \27 38 self.xqlib[f] = pkg_resources.resource_string('ndgUtils','%s/%s'%(dir,f)) 28 39 29 40 def __setitem__(self,key,value): 30 41 ''' Add a new xquery to the xquery database dynamically''' … … 33 44 ''' Given a key, return an xquery ''' 34 45 return self.xq[key] 46 47 def getSchema(self, schemaName): 48 ''' 49 Return the specified schema 50 @param schemaName: Name of schema to retrieve - NB, use the class constants to specify the schemaName 51 - e.g. self.ATOM_MOLES_SCHEMA 52 @return: schema in string format 53 ''' 54 schema = self.xsd.get(schemaName) 55 if not schema: 56 raise ValueError("Unrecognised schema, '%s'" %schemaName) 57 58 return schema 59 60 35 61 def keys(self): 36 62 ''' Return a list of all the xqueries loaded into this instance ''' -
exist/trunk/xquery/moles2.0.xsd
r4426 r4483 4 4 xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta" 5 5 xmlns:atom="http://www.w3.org/2005/Atom" > 6 <xs:import namespace="http://www.w3.org/2005/Atom" schemaLocation=" file:///home/cbyrom/eclipseWorkspace/ndgUtils-trunk/xquery/atom1.0.xsd" />6 <xs:import namespace="http://www.w3.org/2005/Atom" schemaLocation="atom1.0.xsd" /> 7 7 <xs:annotation> 8 8 <xs:documentation>
Note: See TracChangeset
for help on using the changeset viewer.