# $Id$ # $URL$ logger = logging.getLogger('meresco.availability') logger.debug("Starting logger") #FIXME: config namespaceMap = { 'mods': 'http://www.loc.gov/mods/v3' } def inDepot(location): # FIXME: config # Moet overeenkomen met openurl.js if location.split()[0] in ['CBM', 'CBC', 'KHS', 'KOD', 'TRE', 'SOC']: return 1 if len(location.split()) > 1: collection = location.split()[0] + " " + location.split()[1] if collection in ['TF PRE', 'TF HS', 'TF INC', 'TFK E', 'KTFK HS', 'KTFK INC']: return 1 else: return 0 else: return 0 def getLocator(recordId, mods): sid = any.getSid(recordId) locator = any.createOpenURL(mods) # TP: use the following for testing with locator @ bzv.uvt.nl # locator = "/availability/?" + any.createOpenURL(mods).split('?')[1] return locator + '&sid=' + sid def getAvailabilityByOpenurl(recordId, mods, ID): locator = getLocator(recordId, mods) yield """ """ % {'locator' : locator, 'id' : ID } def getAvailabilityByUitleencode(mods, genre ): # uitleencodes # a = titel in bestelling # c = niet balie, wel IBL # d = wel balie, niet IBL # e = elektronisch beschikbaar # g = geblokkeerd # o = onbekend # s = speciale toestemming # z = boek zoek # f = niet uitleenbaar, wel fotokopie # i = niet uitleenbaar, geen fotokopie, wel inzage # u = normaal uitleenbaar # b = beperkt uitleenbaar askServer = [] for copyInformation in mods.xpath("//mods:location/mods:holdingSimple/mods:copyInformation", namespaceMap): uitleencode = copyInformation.xpath("mods:note[@type='status']/text()", namespaceMap) if not uitleencode: pass elif uitleencode[0] == 'i' or uitleencode[0] == 'f': location = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap)[0] if inDepot(location): # FIXME: config yield '
  • Available for perusal in depot: request %(loc)s from depot
  • ' %{'loc': location} else: if genre == 'journal': # FIXME: config yield '
  • Availability information about %(loc)s
  • ' %{'loc': location} else: yield '
  • Available for perusal: %s
  • ' %location elif uitleencode[0] == 'u' or uitleencode[0] == 'b': askServer.append(copyInformation) if askServer: for copyInformation in askServer: 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: depot = inDepot(location) locator = getLocator(recordId, mods) + "&epn=" + EPN yield """ """ %{'id':id, 'loc': location, 'inDepot': depot, 'genre': genre, 'locator': locator} def main(index=0, record={}, recordId=''): 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) # Note: 'id' is a python builtin ID = 'openUrl' + str(index) yield ''