def get_work_title(e, mc): # use first work title we find in source MARC records wt = None for src_type, src in get_marc_src(e, mc): if src_type == 'ia': wt = get_ia_work_title(src) if wt: wt = wt.strip('. ') if wt: break continue assert src_type == 'marc' data = None try: data = get_data(src) except ValueError: print 'bad record source:', src print 'http://openlibrary.org' + e['key'] continue except urllib2.HTTPError, error: print 'HTTP error:', error.code, error.msg print e['key'] if not data: continue is_marc8 = data[9] != 'a' try: line = get_first_tag(data, set(['240'])) except BadDictionary: print 'bad dictionary:', src print 'http://openlibrary.org' + e['key'] continue if line: wt = ' '.join(get_subfield_values(line, ['a'], is_marc8)).strip('. ') break
def get_work_title(e): # use first work title we find in source MARC records wt = None for src_type, src in get_marc_src(e): if src_type == 'ia': wt = get_ia_work_title(src) if wt: break continue assert src_type == 'marc' try: data = get_from_archive(src) except ValueError: print 'bad record source:', src print 'http://openlibrary.org' + e['key'] continue if not data: continue try: line = get_first_tag(data, set(['240'])) except BadDictionary: print 'bad dictionary:', src print 'http://openlibrary.org' + e['key'] continue if line: wt = ' '.join(get_subfield_values(line, ['a'])).strip('. ') break if wt: return wt if not e.get('work_titles', []): return print 'work title in MARC, but not in OL' print 'http://openlibrary.org' + e['key'] return e['work_titles'][0]
def get_work_title(e, mc): # use first work title we find in source MARC records wt = None for src_type, src in get_marc_src(e, mc): if src_type == 'ia': wt = get_ia_work_title(src) if wt: wt = wt.strip('. ') if wt: break continue assert src_type == 'marc' data = None try: data = get_data(src) except ValueError: print 'bad record source:', src print 'http://openlibrary.org' + e['key'] continue except urllib2.HTTPError, error: print 'HTTP error:', error.code, error.msg print e['key'] if not data: continue is_marc8 = data[9] != 'a' try: line = get_first_tag(data, set(['240'])) except BadDictionary: print 'bad dictionary:', src print 'http://openlibrary.org' + e['key'] continue if line: wt = ' '.join(get_subfield_values(line, ['a'], is_marc8)).strip('. ') break
def get_work_title(e): if e['key'] not in marc: assert not e.get('work_titles', []) return # assert e.get('work_titles', []) data = marc[e['key']][1] line = get_first_tag(data, set(['240'])) if not line: assert not e.get('work_titles', []) return return ' '.join(get_subfield_values(line, ['a'])).strip('. ')
def get_work_title(e): if e['key'] not in marc: assert not e.get('work_titles', []) return # assert e.get('work_titles', []) data = marc[e['key']][1] line = get_first_tag(data, set(['240'])) if not line: assert not e.get('work_titles', []) return return ' '.join(get_subfield_values(line, ['a'])).strip('. ')
def get_work_title(e, mc): # use first work title we find in source MARC records wt = None for src_type, src in get_marc_src(e, mc): if src_type == 'ia': wt = get_ia_work_title(src) if wt: wt = wt.strip('. ') if wt: break continue assert src_type == 'marc' data = None try: data = get_data(src) except ValueError: print('bad record source:', src) print('http://openlibrary.org' + e['key']) continue except urllib.error.HTTPError as error: print('HTTP error:', error.code, error.msg) print(e['key']) if not data: continue is_marc8 = data[9] != 'a' try: line = get_first_tag(data, set(['240'])) except BadDictionary: print('bad dictionary:', src) print('http://openlibrary.org' + e['key']) continue if line: wt = ' '.join(get_subfield_values(line, ['a'], is_marc8)).strip('. ') break if wt: return wt for f in 'work_titles', 'work_title': e_wt = e.get(f, []) if e_wt: assert isinstance(e_wt, list) return e_wt[0].strip('. ')
def get_work_title(e, mc): # use first work title we find in source MARC records wt = None for src_type, src in get_marc_src(e, mc): if src_type == 'ia': wt = get_ia_work_title(src) if wt: wt = wt.strip('. ') if wt: break continue assert src_type == 'marc' data = None try: data = get_data(src) except ValueError: print('bad record source:', src) print('http://openlibrary.org' + e['key']) continue except urllib2.HTTPError as error: print('HTTP error:', error.code, error.msg) print(e['key']) if not data: continue is_marc8 = data[9] != 'a' try: line = get_first_tag(data, set(['240'])) except BadDictionary: print('bad dictionary:', src) print('http://openlibrary.org' + e['key']) continue if line: wt = ' '.join(get_subfield_values(line, ['a'], is_marc8)).strip('. ') break if wt: return wt for f in 'work_titles', 'work_title': e_wt = e.get(f, []) if e_wt: assert isinstance(e_wt, list) return e_wt[0].strip('. ')
def get_work_title(e): # use first work title we find in source MARC records wt = None for src_type, src in get_marc_src(e): if src_type == 'ia': wt = get_ia_work_title(src) if wt: break continue assert src_type == 'marc' data = None #print 'get from archive:', src try: data = get_data(src) except ValueError: print('bad record source:', src) print('http://openlibrary.org' + e['key']) continue except urllib2.HTTPError as error: print('HTTP error:', error.code, error.msg) print(e['key']) if not data: continue try: line = get_first_tag(data, set(['240'])) except BadDictionary: print('bad dictionary:', src) print('http://openlibrary.org' + e['key']) continue if line: wt = ' '.join(get_subfield_values(line, ['a'])).strip('. ') break if wt: return wt if not e.get('work_titles', []): return print('work title in MARC, but not in OL') print('http://openlibrary.org' + e['key']) return e['work_titles'][0]