def _id(self, doc):
        """
        _id determines the Voyager id for a document which is used when
        linking to launchpad for a specific item. If the id cannot be
        determined None is returned.

        The id is determined using the availabilityId value. availaibilityId
        usually has a value like "Z6W 13691563", the second part of which is
        the Voyager record id.

        Occasionally the availiabilityId key isn't directly present in the
        document, in which case we fall back to looking for the
        availaibilityId found in the first document in the peerDocuments
        stanza, if one is available.

        Historical note: we initially used the first value in
        ExternalDocumentId but it was not entirely reliable.

        See: https://github.com/gwu-libraries/launchpad/issues/897
        """

        parts = doc.get('availabilityId', '').split(' ')
        if len(parts) == 2:
            return parts[1]
        if 'peerDocuments' in doc and len(doc['peerDocuments']) > 0:
            return self._id(doc['peerDocuments'][0])
        return None
dataset/ETHPy150Open gwu-libraries/launchpad/lp/ui/summon.py/Summon._id/original