def _convert(self, doc):
        i = {}

        # must have an id and a type
        id = self._id(doc)
        if id is None or 'ContentType' not in doc:
            return None

        i['wrlc'] = id
        i['@id'] = '/item/' + id
        i['@type'] = self._get_type(doc)

        if doc.get('Title'):
            i['name'] = doc['Title'][0]
            if doc.get('Subtitle'):
                i['name'] += " : " + doc['Subtitle'][0]

        if 'Author_xml' in doc:
            i['author'] = []
            for name in doc.get('Author_xml', []):
                if 'fullname' in name:
                    q = ('Author:"%s"' % name['fullname']).encode('utf8')
                    i['author'].append({
                        'name': name['fullname'],
                        'url': reverse('search') + '?' + urlencode({'q': q})
                    })
            for alt_name in doc.get('Author_FL_xml', []):
                if 'fullname' in alt_name:
                    p = 1 - int(alt_name['sequence'])
                    if p < len(i['author']):
                        i['author'][p]['alternateName'] = alt_name['fullname']

        if 'SubjectTermsDisplay' in doc:
            i['about'] = []
            for subject in doc.get('SubjectTermsDisplay', []):
                subject = subject.strip('.')
                q = ('SubjectTerms:"%s"' % subject).encode('utf8')
                i['about'].append({
                    'name': subject,
                    'url': reverse('search') + '?' + urlencode({'q': q})
                })
                # i['about'] = sorted(i['about'])

        if doc.get('PublicationYear'):
            i['datePublished'] = doc['PublicationYear'][0]

        if doc.get('Publisher'):
            i['publisher'] = {'name': doc['Publisher'][0]}
            if 'PublicationPlace' in doc:
                i['publisher']['address'] = doc['PublicationPlace'][0]

        if doc.get('thumbnail_m', []):
            i['thumbnailUrl'] = doc['thumbnail_m'][0]

        if doc.get('ISBN'):
            i['isbn'] = doc['ISBN']

        if doc.get('ISSN'):
            i['issn'] = doc['ISSN']

        if doc.get('Edition'):
            i['bookEdition'] = doc['Edition'][0].strip('.')

        if doc.get('DocumentTitle_FL'):
            i['alternateName'] = doc.get('DocumentTitle_FL')[0]

        i['offers'] = []
        offer = self._get_offer(doc)
        if offer:
            i['offers'].append(offer)
        for peer_doc in doc.get('peerDocuments', []):
            offer = self._get_offer(peer_doc)
            if offer:
                i['offers'].append(offer)
        i = self._rewrite_ids(i)

        return i
dataset/ETHPy150Open gwu-libraries/launchpad/lp/ui/summon.py/Summon._convert/swapped operands of `-`