# $Id$ # $URL$ logger = logging.getLogger('meresco.availability') logger.debug("Starting logger") namespaceMap = { 'mods': 'http://www.loc.gov/mods/v3' } def inDepot(location): if location.split()[0] in ['CBM', 'CBC', 'KHS', 'KOD', 'TRE']: 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 main(index=0, record={}, recordId=''): db, rid = recordId.split(':', 1) opc = 0 if db == "opc-uvt-nl": opc = 1 urls = 0 if 'URL(s)' in record: urls = 1 genre = '' if 'Publication type' in record: genre = record['Publication type'] mods = any.getMods(recordId) id = 'td' + str(index) yield '' % {'id' : id} if urls: for url in record['URL(s)']: yield '* full text
' %(url) if opc: if not urls: askServer = [] if genre == 'series' and 'Related Titles' in record: yield record['Related Titles'] elif genre == 'multivolume monograph': yield 'Search the catalogue for availability information' %record['Title'] else: 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': ####################### f = niet uitleenbaar, wel fotokopie ####################### i = niet uitleenbaar, geen fotokopie, wel inzage location = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap)[0] if inDepot(location): yield 'Available for perusal in depot: request %(loc)s from depot' %{'loc': location} else: if genre == 'journal': yield 'Availability information about %(loc)s' %{'loc': location} else: yield 'Available for perusal: %s' %location yield '
' # 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 elif uitleencode[0] == 'u' or uitleencode[0] == 'b': ####################### u = normaal uitleenbaar ####################### b = beperkt uitleenbaar askServer.append(copyInformation) yield '' 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 = any.createOpenURL(mods) yield """ """ %{'id':id, 'EPN':EPN, 'loc': location, 'inDepot': depot, 'genre': genre, 'locator': locator} else: yield '' else: # not opc if urls and db == 'scr-uvt-nl': pass else: locator = any.createOpenURL(mods) yield """ """ % {'locator' : locator, 'id' : id } yield ''