fulltext/services/legacy/legacy.py
def retrieve(self, identifier: str, sleep: int = 5) -> IO[bytes]:
        """
        Retrieve PDFs of published papers from the core arXiv document store.

        Parameters
        ----------
        identifier : str
            arXiv identifier for which a PDF is required.

        Returns
        -------
        str
            Path to (temporary) PDF.

        Raises
        ------
        ValueError
            If a disallowed or otherwise invalid URL is passed.
        IOError
            When there is a problem retrieving the resource at ``target``.

        """
        target = self._path(f'/pdf/{identifier}')
        pdf_response = self._session.get(target)
        if pdf_response.status_code == status.NOT_FOUND:
            logger.info('Could not retrieve PDF for %s', identifier)
            raise DoesNotExist('No such resource')
        if pdf_response.status_code != status.OK:
            raise IOError('%s: unexpected status for PDF: %i' %
                          (identifier, pdf_response.status_code))

        # Classic PDF route will return 200 even if PDF is not yet generated.
        # But at least it will be honest about the Content-Type. If we don't
        # get a PDF back, we should wait and try again.
        if pdf_response.headers['Content-Type'] != 'application/pdf':
            retries = 5
            while pdf_response.headers['Content-Type'] != 'application/pdf':
                if retries < 1:
                    raise IOError('Could not retrieve PDF; giving up')
                logger.info('Got HTML instead of PDF; retrying (%i remaining)',
                            retries)
                time.sleep(sleep)
                retries -= 1
                pdf_response = self._session.get(target)
                if pdf_response.status_code != status.OK:
                    raise IOError('%s: unexpected status for PDF: %i' %
                                  (identifier, pdf_response.status_code))

        return ReadWrapper(pdf_response.iter_content)

        Retrieve PDFs of published papers from the core arXiv document store.

        Parameters
        ----------
        identifier : str
            arXiv identifier for which a PDF is required.

        Returns
        -------
        str
            Path to (temporary) PDF.

        Raises
        ------
        ValueError
            If a disallowed or otherwise invalid URL is passed.
        IOError
            When there is a problem retrieving the resource at ``target``.

        
Retrieve PDFs of published papers from the core arXiv document store.
Parameters

identifier : str
arXiv identifier for which a PDF is required.

Returns

str
Path to (temporary) PDF.

Raises

ValueError
If a disallowed or otherwise invalid URL is passed.
IOError
When there is a problem retrieving the resource at ``target``.
Retrieve PDFs of published papers from the core arXiv document store . Parameters identifier : str arXiv identifier for which a PDF is required . Returns str Path to ( temporary ) PDF . Raises ValueError If a disallowed or otherwise invalid URL is passed . IOError When there is a problem retrieving the resource at ` ` target ` ` .
def retrieve(self, identifier: str, sleep: int = 5) -> IO[bytes]:
        target = self._path(f'/pdf/{identifier}')
        pdf_response = self._session.get(target)
        if pdf_response.status_code == status.NOT_FOUND:
            logger.info('Could not retrieve PDF for %s', identifier)
            raise DoesNotExist('No such resource')
        if pdf_response.status_code != status.OK:
            raise IOError('%s: unexpected status for PDF: %i' %
                          (identifier, pdf_response.status_code))
        if pdf_response.headers['Content-Type'] != 'application/pdf':
            retries = 5
            while pdf_response.headers['Content-Type'] != 'application/pdf':
                if retries < 1:
                    raise IOError('Could not retrieve PDF; giving up')
                logger.info('Got HTML instead of PDF; retrying (%i remaining)',
                            retries)
                time.sleep(sleep)
                retries -= 1
                pdf_response = self._session.get(target)
                if pdf_response.status_code != status.OK:
                    raise IOError('%s: unexpected status for PDF: %i' %
                                  (identifier, pdf_response.status_code))
        return ReadWrapper(pdf_response.iter_content)
def retrieve ( self , identifier : str , sleep : int = 5 ) -> IO [ bytes ] : target = self . _path ( f'/pdf/{identifier}' ) pdf_response = self . _session . get ( target ) if pdf_response . status_code == status . NOT_FOUND : logger . info ( 'Could not retrieve PDF for %s' , identifier ) raise DoesNotExist ( 'No such resource' ) if pdf_response . status_code != status . OK : raise IOError ( '%s: unexpected status for PDF: %i' % ( identifier , pdf_response . status_code ) ) if pdf_response . headers [ 'Content-Type' ] != 'application/pdf' : retries = 5 while pdf_response . headers [ 'Content-Type' ] != 'application/pdf' : if retries < 1 : raise IOError ( 'Could not retrieve PDF; giving up' ) logger . info ( 'Got HTML instead of PDF; retrying (%i remaining)' , retries ) time . sleep ( sleep ) retries -= 1 pdf_response = self . _session . get ( target ) if pdf_response . status_code != status . OK : raise IOError ( '%s: unexpected status for PDF: %i' % ( identifier , pdf_response . status_code ) ) return ReadWrapper ( pdf_response . iter_content )
Retrieve PDFs of published papers from the core arXiv document store.
Retrieve PDFs of published papers from the core arXiv document store .
"""
        Retrieve PDFs of published papers from the core arXiv document store.

        Parameters
        ----------
        identifier : str
            arXiv identifier for which a PDF is required.

        Returns
        -------
        str
            Path to (temporary) PDF.

        Raises
        ------
        ValueError
            If a disallowed or otherwise invalid URL is passed.
        IOError
            When there is a problem retrieving the resource at ``target``.

        """ # Classic PDF route will return 200 even if PDF is not yet generated. # But at least it will be honest about the Content-Type. If we don't # get a PDF back, we should wait and try again.
self
identifier
str
sleep
int