Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _mapper(isbn, records):
"""Mapp: canonical <- records."""
# canonical: ISBN-13, Title, Authors, Publisher, Year, Language
try:
canonical = {}
canonical['ISBN-13'] = u(isbn)
canonical['Title'] = records.get('title', u('')).replace(' :', ':')
buf = records.get('author', u(''))
canonical['Authors'] = [x.strip('. ') for x in buf.split(';')]
canonical['Publisher'] = records.get('publisher', u(''))
canonical['Year'] = records.get('year', u(''))
canonical['Language'] = records.get('lang', u(''))
except: # pragma: no cover
raise RecordMappingError(isbn)
# call stdmeta for extra cleanning and validation
return stdmeta(canonical)
def _mapper(isbn, records):
"""Map canonical <- records."""
# canonical:
# -> ISBN-13, Title, Authors, Publisher, Year, Language
try:
# mapping: canonical <- records
canonical = {}
canonical['ISBN-13'] = u(isbn)
canonical['Title'] = records.get('title', u('')).replace(' :', ':')
canonical['Authors'] = [a['name'] for a in
records.get('authors', ({'name': u('')},))]
canonical['Publisher'] = records.get('publishers',
[{'name': u('')}, ])[0]['name']
canonical['Year'] = records.get('publish_date', u(',')).split(',')[1]
except: # pragma: no cover
raise RecordMappingError(isbn)
# call stdmeta for extra cleanning and validation
return stdmeta(canonical)
"""Mapp: canonical <- records."""
# canonical: ISBN-13, Title, Authors, Publisher, Year, Language
try:
canonical = {}
canonical['ISBN-13'] = u(isbn)
canonical['Title'] = records.get('title', u('')).replace(' :', ':')
canonical['Authors'] = records.get('authors', [u('')])
canonical['Publisher'] = records.get('publisher', u(''))
if 'publishedDate' in records \
and len(records['publishedDate']) >= 4:
canonical['Year'] = records['publishedDate'][0:4]
else: # pragma: no cover
canonical['Year'] = u('')
canonical['Language'] = records.get('language', u(''))
except: # pragma: no cover
raise RecordMappingError(isbn)
# call stdmeta for extra cleanning and validation
return stdmeta(canonical)
isbn = ident['identifier']
break
if not isbn: # pragma: no cover
return
canonical['ISBN-13'] = isbn
canonical['Title'] = record.get('title', u('')).replace(' :', ':')
canonical['Authors'] = record.get('authors', [])
canonical['Publisher'] = record.get('publisher', u(''))
if 'publishedDate' in record \
and len(record['publishedDate']) >= 4:
canonical['Year'] = record['publishedDate'][0:4]
else: # pragma: no cover
canonical['Year'] = u('')
canonical['Language'] = record.get('language', u(''))
except: # pragma: no cover
raise RecordMappingError(isbn)
# call stdmeta for extra cleanning and validation
return stdmeta(canonical)
# mapping: canonical <- records
canonical = {}
canonical['ISBN-13'] = u(isbn)
# assert isbn == records['isbn13'], "isbn was mungled!"
canonical['Title'] = records.get('title', u(''))
authors = [a['name'] for a in records['author_data']]
canonical['Authors'] = authors
canonical['Publisher'] = records.get('publisher_name', u(''))
canonical['Year'] = u('')
if 'edition_info' in records:
match = re.search(PATT_YEAR, records['edition_info'])
if match:
canonical['Year'] = str(match.group(0))
canonical['Language'] = records.get('language', u(''))
except:
raise RecordMappingError(isbn)
# call stdmeta for extra cleanning and validation
return stdmeta(canonical)