except ValueError: return None if not os.path.exists(marc_path + filename): return None f = open(marc_path + filename) f.seek(int(p)) buf = f.read(int(l)) f.close() return buf def edition_marc(key): mc = list(set(v.machine_comment for v in site.versions({'key': key }))) return [loc for loc in mc if loc] key_start = len('/scan_record') for key in site.things({'type': '/type/scan_record'}): assert key.startswith('/scan_record/b/') edition_key = key[key_start:] for loc in edition_marc(edition_key): data = get_data(loc) if not data or data.find('icrof') == -1: continue print "http://openlibrary.org" + edition_key print "http://openlibrary.org/show-marc/" + loc for tag, tag_line in get_all_tag_lines(data): if tag_line.find('icrof') == -1: continue print tag + ":", tag_line[2:-1].replace('\x1f', ' $') print
return None if not os.path.exists(marc_path + filename): return None f = open(marc_path + filename) f.seek(int(p)) buf = f.read(int(l)) f.close() return buf def edition_marc(key): mc = list(set(v.machine_comment for v in site.versions({'key': key}))) return [loc for loc in mc if loc] key_start = len('/scan_record') for key in site.things({'type': '/type/scan_record'}): assert key.startswith('/scan_record/b/') edition_key = key[key_start:] for loc in edition_marc(edition_key): data = get_data(loc) if not data or data.find('icrof') == -1: continue print "http://openlibrary.org" + edition_key print "http://openlibrary.org/show-marc/" + loc for tag, tag_line in get_all_tag_lines(data): if tag_line.find('icrof') == -1: continue print tag + ":", tag_line[2:-1].replace('\x1f', ' $') print
def as_html(data): return '<br>\n'.join(html_line(t, l) for t, l in get_all_tag_lines(data))