solvebio/resource/apiresource.py
def download(self, path=None, **kwargs):
        """
        Download the file to the specified directory or file path.
        Downloads to a temporary directory if no path is specified.

        Returns the absolute path to the file.
        """
        download_url = self.download_url(**kwargs)
        try:
            # For vault objects, use the object's filename
            # as the fallback if none is specified.
            filename = self.filename
        except AttributeError:
            # If the object has no filename attribute,
            # extract one from the download URL.
            filename = download_url.split('%3B%20filename%3D')[1]
            # Remove additional URL params from the name and "unquote" it.
            filename = unquote(filename.split('&')[0])

        if path:
            path = os.path.expanduser(path)
            # If the path is a dir, use the extracted filename
            if os.path.isdir(path):
                path = os.path.join(path, filename)
        else:
            # Create a temporary directory for the file
            path = os.path.join(tempfile.gettempdir(), filename)

        try:
            response = requests.request(method='get', url=download_url)
        except Exception as e:
            _handle_request_error(e)

        if not (200 <= response.status_code < 400):
            _handle_api_error(response)

        with open(path, 'wb') as fileobj:
            fileobj.write(response._content)

        return path
def download(self, path=None, **kwargs):
        """
        Download the file to the specified directory or file path.
        Downloads to a temporary directory if no path is specified.

        Returns the absolute path to the file.
        """
        download_url = self.download_url(**kwargs)
        try:
            # For vault objects, use the object's filename
            # as the fallback if none is specified.
            filename = self.filename
        except AttributeError:
            # If the object has no filename attribute,
            # extract one from the download URL.
            filename = download_url.split('%3B%20filename%3D')[1]
            # Remove additional URL params from the name and "unquote" it.
            filename = unquote(filename.split('&')[0])

        if path:
            path = os.path.expanduser(path)
            # If the path is a dir, use the extracted filename
            if os.path.isdir(path):
                path = os.path.join(path, filename)
        else:
            # Create a temporary directory for the file
            path = os.path.join(tempfile.gettempdir(), filename)

        try:
            response = requests.request(method='get', url=download_url)
        except Exception as e:
            _handle_request_error(e)

        if not (200 <= response.status_code < 400):
            _handle_api_error(response)

        with open(path, 'wb') as fileobj:
            fileobj.write(response._content)

        return path
def download ( self , path = None , * * kwargs ) : download_url = self . download_url ( * * kwargs ) try : # For vault objects, use the object's filename # as the fallback if none is specified. filename = self . filename except AttributeError : # If the object has no filename attribute, # extract one from the download URL. filename = download_url . split ( '%3B%20filename%3D' ) [ 1 ] # Remove additional URL params from the name and "unquote" it. filename = unquote ( filename . split ( '&' ) [ 0 ] ) if path : path = os . path . expanduser ( path ) # If the path is a dir, use the extracted filename if os . path . isdir ( path ) : path = os . path . join ( path , filename ) else : # Create a temporary directory for the file path = os . path . join ( tempfile . gettempdir ( ) , filename ) try : response = requests . request ( method = 'get' , url = download_url ) except Exception as e : _handle_request_error ( e ) if not ( 200 <= response . status_code < 400 ) : _handle_api_error ( response ) with open ( path , 'wb' ) as fileobj : fileobj . write ( response . _content ) return path
Download the file to the specified directory or file path.
        Downloads to a temporary directory if no path is specified.

        Returns the absolute path to the file.
Download the file to the specified directory or file path . Downloads to a temporary directory if no path is specified .