src/pds_doi_service/core/input/input_util.py
def _read_from_remote(self, input_url):
        """
        Reads a remote file from the provided URL into a local temporary file,
        then parses and returns any Dois from it. The local temp file is
        deleted once this function returns.

        Parameters
        ----------
        input_url : str
            The URL to the file to download locally.

        Returns
        -------
        dois : list of Doi
            The Doi's parsed from the remote file.

        Raises
        ------
        InputFormatException
            If the URL points to a file with an unsupported extension.

        """
        parsed_url = urllib.parse.urlparse(input_url)

        # Check for valid extension before attempting to read from remote
        extension = os.path.splitext(parsed_url.path)[-1]

        if extension not in self._valid_extensions:
            raise InputFormatException(
                f'File extension type "{extension}" is not supported for this, '
                f'operation, must be one of {",".join(self._valid_extensions)}'
            )

        response = requests.get(input_url)

        try:
            response.raise_for_status()
        except requests.exceptions.HTTPError as http_err:
            raise InputFormatException(f"Could not read remote file {input_url}, reason: {str(http_err)}")

        with tempfile.NamedTemporaryFile(suffix=basename(parsed_url.path)) as temp_file:
            temp_file.write(response.content)
            temp_file.seek(0)

            dois = self._read_from_path(temp_file.name)

        # Update input source to point to original URL, as the temp file paths
        # assigned by _read_from_path no longer exist
        for doi in dois:
            doi.input_source = input_url

        return dois

        Reads a remote file from the provided URL into a local temporary file,
        then parses and returns any Dois from it. The local temp file is
        deleted once this function returns.

        Parameters
        ----------
        input_url : str
            The URL to the file to download locally.

        Returns
        -------
        dois : list of Doi
            The Doi's parsed from the remote file.

        Raises
        ------
        InputFormatException
            If the URL points to a file with an unsupported extension.

        
Reads a remote file from the provided URL into a local temporary file,
then parses and returns any Dois from it. The local temp file is
deleted once this function returns.

Parameters

input_url : str
The URL to the file to download locally.

Returns

dois : list of Doi
The Doi's parsed from the remote file.

Raises

InputFormatException
If the URL points to a file with an unsupported extension.
Reads a remote file from the provided URL into a local temporary file then parses and returns any Dois from it . The local temp file is deleted once this function returns . Parameters input_url : str The URL to the file to download locally . Returns dois : list of Doi The Doi ' s parsed from the remote file . Raises InputFormatException If the URL points to a file with an unsupported extension .
def _read_from_remote(self, input_url):
        parsed_url = urllib.parse.urlparse(input_url)
        extension = os.path.splitext(parsed_url.path)[-1]
        if extension not in self._valid_extensions:
            raise InputFormatException(
                f'File extension type "{extension}" is not supported for this, '
                f'operation, must be one of {",".join(self._valid_extensions)}'
            )
        response = requests.get(input_url)
        try:
            response.raise_for_status()
        except requests.exceptions.HTTPError as http_err:
            raise InputFormatException(f"Could not read remote file {input_url}, reason: {str(http_err)}")
        with tempfile.NamedTemporaryFile(suffix=basename(parsed_url.path)) as temp_file:
            temp_file.write(response.content)
            temp_file.seek(0)
            dois = self._read_from_path(temp_file.name)
        for doi in dois:
            doi.input_source = input_url
        return dois
def _read_from_remote ( self , input_url ) : parsed_url = urllib . parse . urlparse ( input_url ) extension = os . path . splitext ( parsed_url . path ) [ - 1 ] if extension not in self . _valid_extensions : raise InputFormatException ( f'File extension type "{extension}" is not supported for this, ' f'operation, must be one of {",".join(self._valid_extensions)}' ) response = requests . get ( input_url ) try : response . raise_for_status ( ) except requests . exceptions . HTTPError as http_err : raise InputFormatException ( f"Could not read remote file {input_url}, reason: {str(http_err)}" ) with tempfile . NamedTemporaryFile ( suffix = basename ( parsed_url . path ) ) as temp_file : temp_file . write ( response . content ) temp_file . seek ( 0 ) dois = self . _read_from_path ( temp_file . name ) for doi in dois : doi . input_source = input_url return dois
Reads a remote file from the provided URL into a local temporary file,
then parses and returns any Dois from it.
Reads a remote file from the provided URL into a local temporary file then parses and returns any Dois from it .
"""
        Reads a remote file from the provided URL into a local temporary file,
        then parses and returns any Dois from it. The local temp file is
        deleted once this function returns.

        Parameters
        ----------
        input_url : str
            The URL to the file to download locally.

        Returns
        -------
        dois : list of Doi
            The Doi's parsed from the remote file.

        Raises
        ------
        InputFormatException
            If the URL points to a file with an unsupported extension.

        """ # Check for valid extension before attempting to read from remote # Update input source to point to original URL, as the temp file paths # assigned by _read_from_path no longer exist
self
input_url