How to use the isbnlib.dev._exceptions.RecordMappingError function in isbnlib

To help you get started, we’ve selected a few isbnlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xlcnd / isbnlib / isbnlib / _wcat.py View on Github external
def _mapper(isbn, records):
    """Map: 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
        LOGGER.debug("RecordMappingError for %s with data %s", isbn, records)
        raise RecordMappingError(isbn)
    # call stdmeta for extra cleanning and validation
    return stdmeta(canonical)
github xlcnd / isbnlib / isbnlib / _isbndb.py View on Github external
# 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)
github xlcnd / isbnlib / isbnlib / _openl.py View on Github external
}, ))
        ]
        canonical['Publisher'] = records.get('publishers', [
            {
                'name': u(''),
            },
        ])[0]['name']
        canonical['Year'] = u('')
        strdate = records.get('publish_date', u(''))
        if strdate:  # pragma: no cover
            match = re.search(r'\d{4}', strdate)
            if match:
                canonical['Year'] = match.group(0)
    except Exception:  # pragma: no cover
        LOGGER.debug('RecordMappingError for %s with data %s', isbn, records)
        raise RecordMappingError(isbn)
    # call stdmeta for extra cleanning and validation
    return stdmeta(canonical)
github xlcnd / isbnlib / isbnlib / _goob.py View on Github external
canonical['ISBN-13'] = u(isbn)
        title = records.get('title', u('')).replace(' :', ':')
        subtitle = records.get('subtitle', u(''))
        title = title + ' - ' + subtitle if subtitle else title
        canonical['Title'] = title
        canonical['Authors'] = records.get('authors', [u('')])
        # see issue #64
        canonical['Publisher'] = records.get('publisher', u('')).strip('"')
        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 Exception:  # pragma: no cover
        LOGGER.debug('RecordMappingError for %s with data %s', isbn, records)
        raise RecordMappingError(isbn)
    # call stdmeta for extra cleanning and validation
    return stdmeta(canonical)
github xlcnd / isbnlib / isbnlib / _goom.py View on Github external
if ident['type'] == 'ISBN_13':
                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 Exception:  # pragma: no cover
        raise RecordMappingError(isbn)
    # call stdmeta for extra cleanning and validation
    return stdmeta(canonical)