def get_records_from_marc(isbn): if isbn not in db: return # for loc in db[isbn].split(' '): # data = get_data(loc) # print loc # want = ['100', '110', '111', '240', '245', '260'] + [str(i) for i in range(500,600) if i not in (505, 520)] # for tag, line in get_tag_lines(data, set(want)): # sub = list(get_all_subfields(line)) # if tag.startswith('5'): # assert len(sub) == 1 and sub[0][0] == 'a' # note = sub[0][1] # if note.find('ublish') != -1 or note.find('riginal') != -1: # print ' note:', note # continue # print ' ', tag, sub # print recs = [(loc, build_record(get_data(loc))) for loc in db[isbn].split(' ')] keys = set() print for loc, rec in recs: print ' ', loc # keys.update([k for k in rec.keys() if k.find('title') != -1 or k in ('authors', 'title', 'contributions', 'work_title')]) keys.update(rec.keys()) print for k in keys: print k for loc, rec in recs: print " ", rec.get(k, '###') print print
def get_records_from_marc(isbn): if isbn not in db: return # for loc in db[isbn].split(' '): # data = get_data(loc) # print loc # want = ['100', '110', '111', '240', '245', '260'] + [str(i) for i in range(500,600) if i not in (505, 520)] # for tag, line in get_tag_lines(data, set(want)): # sub = list(get_all_subfields(line)) # if tag.startswith('5'): # assert len(sub) == 1 and sub[0][0] == 'a' # note = sub[0][1] # if note.find('ublish') != -1 or note.find('riginal') != -1: # print ' note:', note # continue # print ' ', tag, sub # print recs = [(loc, build_record(get_data(loc))) for loc in db[isbn].split(' ')] keys = set() print for loc, rec in recs: print ' ', loc # keys.update([k for k in rec.keys() if k.find('title') != -1 or k in ('authors', 'title', 'contributions', 'work_title')]) keys.update(rec.keys()) print for k in keys: print k for loc, rec in recs: print " ", rec.get(k, '###') print print
def marc_data(loc): if loc not in data_cache: data_cache[loc] = get_data(loc) return data_cache[loc]
locs = set() for ek in edition_keys: e = site.withKey(ek) for i in e.isbn_10 if e.isbn_10 else []: locs.update(search_query('isbn', i)) for i in e.lccn if e.lccn else []: locs.update(search_query('lccn', i)) for i in e.oclc_numbers if e.oclc_numbers else []: locs.update(search_query('oclc', i)) print len(locs), 'MARC records found' def ldv(line): for s in ('1452', '1519', 'eonard', 'inci'): if line.find(s) != -1: return True return False for loc in locs: # print loc data = get_data(loc) if not data: print "couldn't get" continue line = get_first_tag(data, set(['100', '110', '111'])) if line and ldv(line): print list(get_all_subfields(line)) line = get_first_tag(data, set(['700', '710', '711'])) if line and ldv(line): print list(get_all_subfields(line))
locs = set() for ek in edition_keys: e = site.withKey(ek) for i in e.isbn_10 if e.isbn_10 else []: locs.update(search_query('isbn', i)) for i in e.lccn if e.lccn else []: locs.update(search_query('lccn', i)) for i in e.oclc_numbers if e.oclc_numbers else []: locs.update(search_query('oclc', i)) print len(locs), 'MARC records found' def ldv(line): for s in ('1452', '1519', 'eonard', 'inci'): if line.find(s) != -1: return True return False for loc in locs: # print loc data = get_data(loc) if not data: print "couldn't get" continue line = get_first_tag(data, set(['100', '110', '111'])) if line and ldv(line): print list(get_all_subfields(line)) line = get_first_tag(data, set(['700', '710', '711'])) if line and ldv(line): print list(get_all_subfields(line))
def marc_data(loc): if loc not in data_cache: data_cache[loc] = get_data(loc) return data_cache[loc]