def isbns(self, key, value):
    """Populate the ``isbns`` key."""
    def _get_medium(value):
        def _normalize(medium):
            schema = load_schema('hep')
            valid_media = schema['properties']['isbns']['items']['properties']['medium']['enum']

            medium = medium.lower().replace('-', '').replace(' ', '')
            if medium in valid_media:
                return medium
            elif medium == 'ebook':
                return 'online'
            elif medium == 'paperback':
                return 'softcover'

            return ''

        medium = force_single_element(value.get('b', ''))
        normalized_medium = _normalize(medium)

        return normalized_medium

    def _get_isbn(value):
        a_value = force_single_element(value.get('a', ''))
        normalized_a_value = a_value.replace('.', '')
        if normalized_a_value:
            return normalize_isbn(normalized_a_value)

    return {
        'medium': _get_medium(value),
        'value': _get_isbn(value),
    }
def isbns ( self , key , value ) : def _get_medium ( value ) : def _normalize ( medium ) : schema = load_schema ( 'hep' ) valid_media = schema [ 'properties' ] [ 'isbns' ] [ 'items' ] [ 'properties' ] [ 'medium' ] [ 'enum' ] medium = medium . lower ( ) . replace ( '-' , '' ) . replace ( ' ' , '' ) if medium in valid_media : return medium elif medium == 'ebook' : return 'online' elif medium == 'paperback' : return 'softcover' return '' medium = force_single_element ( value . get ( 'b' , '' ) ) normalized_medium = _normalize ( medium ) return normalized_medium def _get_isbn ( value ) : a_value = force_single_element ( value . get ( 'a' , '' ) ) normalized_a_value = a_value . replace ( '.' , '' ) if normalized_a_value : return normalize_isbn ( normalized_a_value ) return { 'medium' : _get_medium ( value ) , 'value' : _get_isbn ( value ) , }
Populate the ``isbns`` key.