# $Id$ # $URL$ # $Id$ # $URL$ logger = logging.getLogger('meresco.availability') logger.debug("Starting logger") availabilityConfig = configs['availability'] collectionString = availabilityConfig.get('collectionList', section="collections") if collectionString == None: logger.error("No collections found!") collectionString = "NO,COLLECTIONS,FOUND" exceptionString = availabilityConfig.get('exceptionList', section="collections") if exceptionString == None: logger.error("No exceptions found!") exceptionString = "NO,EXCEPTIONS,FOUND" collections = collectionString.split("\n") exceptions = exceptionString.split("\n") #infra.dd('collections', collections) #FIXME: config namespaceMap = { 'mods': 'http://www.loc.gov/mods/v3' } def inDepot(location): global collections global exceptions # logging.debug("location:" + location) for exception in exceptions: # logging.debug("exception: " + exception) if re.match(exception+'\s',location): return False for collection in collections: # logging.debug("collection: " + collection) if re.match(collection+'\s',location): return True return False def getLocator(recordId, mods): # FIXME dit gaat niet goed sid = any.getSid(recordId) locator = any.createOpenURL(mods) return locator + '&sid=' + sid def getAvailabilityByOpenurl(recordId, mods, ID): locator = getLocator(recordId, mods) yield """ """ % {'locator' : locator, 'id' : ID } def getAvailabilityByUitleencode(mods, genre, recordId, ID ): # uitleencodes # a = titel in bestelling # b = beperkt uitleenbaar # c = niet balie, wel IBL # d = wel balie, niet IBL # e = elektronisch beschikbaar # f = niet uitleenbaar, wel fotokopie # g = geblokkeerd # i = niet uitleenbaar, geen fotokopie, wel inzage # o = onbekend # s = speciale toestemming # u = normaal uitleenbaar # z = boek zoek depot = availabilityConfig.get('depot', section="storageList",default='IN DEPOT') library = availabilityConfig.get('library', section="storageList",default='IN LIBRARY') journal = availabilityConfig.get('journal', section="storageList",default='JOURNAL') data = {} documentStorageList = ['locator','depot','library','journal'] for storage in documentStorageList: data[storage] = [] for copyInformation in mods.xpath("//mods:location/mods:holdingSimple/mods:copyInformation", namespaceMap): uitleencode = copyInformation.xpath("mods:note[@type='status']/text()", namespaceMap) ######### Er zijn ook elektronische boeken, hebben geen shelfLocator, maar een electronicLocator ######### met URL. url = "" l = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap) if l: location = l[0] else: u = copyInformation.xpath("mods:electronicLocator/text()", namespaceMap) if u: url = u[0] if uitleencode and location: # niet uitleenbaar if uitleencode[0] == 'i' or uitleencode[0] == 'f': if inDepot(location): # FIXME: config (tucat) data['depot'].append('%(loc)s (not for loan)' %{'loc': location}) # niet in depot: elif genre == 'journal': # FIXME: config (tuts) col = copyInformation.xpath("mods:enumerationAndChronology[@unitType='3']/text()", namespaceMap) data['journal'].append('%(loc)s %(col)s' %{'loc': location, 'col': col[0]}) else: data['library'].append(location) elif uitleencode[0] == 'u' or uitleencode[0] == 'b': data['locator'].append(copyInformation) elif url: yield 'Electronic book' %(url) locator = "" for storage in documentStorageList: if storage == 'locator' and data[storage]: for copyInformation in data['locator']: EPN = copyInformation.xpath("mods:note[@type='epn']/text()", namespaceMap)[0] if EPN: location = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap) location = location and location[0] or '' if location: locator = getLocator(recordId, mods) + "&epn=" + EPN yield """ """ %{'id':ID, 'loc': location, 'inDepot': inDepot(location), 'genre': genre, 'locator': locator} break if locator: break elif storage == 'depot' and data[storage]: yield '' elif storage == 'library' and data[storage]: yield '' elif storage == 'journal' and data[storage]: yield '' def main(index=0, record={}, recordId=''): fulltext = availabilityConfig.get('fulltext', section="storageList",default='DIRECT LINK') # logger.debug(infra.prpt('recordId',recordId)) # logger.debug(infra.prpt('record',record)) db, rid = recordId.split(':', 1) urls = 0 if 'URL(s)' in record: urls = 1 genre = '' if 'Publication type' in record: genre = record['Publication type'] mods = any.getMods(recordId) # logger.debug(infra.prpt('*mods*', mods)) # Note: 'id' is a python builtin # NOTE: 'id' IS A PYTHON BUILTIN!!!!!! ID = 'AvID' + str(index) if urls: yield '' if db == "opc-uvt-nl": if not urls: if (genre == 'series' or genre == 'multivolume monograph') and 'Related Titles' in record: yield record['Related Titles'] #elif genre == 'multivolume monograph': # # FIXME: config # yield '
  • Search the catalogue for availability information
  • ' %record['Title'] else: if mods: yield getAvailabilityByUitleencode(mods, genre, recordId, ID + '-ulc' ) else: # not opc if urls and (genre != 'article'): pass else: yield getAvailabilityByOpenurl(recordId, mods, ID + '-ourl')