convert volume metadata from es to archivant format

           This function makes side effect on input volume

           output example::

            {
                'id': 'AU0paPZOMZchuDv1iDv8',
                'type': 'volume',
                'metadata': {'_language': 'en',
                            'key1': 'value1',
                            'key2': 'value2',
                            'key3': 'value3'},
                'attachments': [{'id': 'a910e1kjdo2d192d1dko1p2kd1209d',
                                'type' : 'attachment',
                                'url': 'fsdb:///624bffa8a6f90813b7982d0e5b4c1475ebec40e3',
                                'metadata': {'download_count': 0,
                                            'mime': 'application/json',
                                            'name': 'tmp9fyat_',
                                            'notes': 'this file is awsome',
                                            'sha1': '624bffa8a6f90813b7982d0e5b4c1475ebec40e3',
                                            'size': 10}
                            }]
            }

def normalize_volume(volume):
        '''convert volume metadata from es to archivant format

           This function makes side effect on input volume

           output example::

            {
                'id': 'AU0paPZOMZchuDv1iDv8',
                'type': 'volume',
                'metadata': {'_language': 'en',
                            'key1': 'value1',
                            'key2': 'value2',
                            'key3': 'value3'},
                'attachments': [{'id': 'a910e1kjdo2d192d1dko1p2kd1209d',
                                'type' : 'attachment',
                                'url': 'fsdb:///624bffa8a6f90813b7982d0e5b4c1475ebec40e3',
                                'metadata': {'download_count': 0,
                                            'mime': 'application/json',
                                            'name': 'tmp9fyat_',
                                            'notes': 'this file is awsome',
                                            'sha1': '624bffa8a6f90813b7982d0e5b4c1475ebec40e3',
                                            'size': 10}
                            }]
            }

        '''
        res = dict()
        res['type'] = 'volume'
        res['id'] = volume['_id']
        if '_score' in volume:
            res['score'] = volume['_score']

        source = volume['_source']
        attachments = source['_attachments']
        del(source['_attachments'])
        del(source['_text_' + source['_language']])
        res['metadata'] = source

        atts = list()
        for attachment in attachments:
            atts.append(Archivant.normalize_attachment(attachment))
        res['attachments'] = atts

        return res