def download(self, url, savepath=None, filename=None):
        """Downloads file from Redmine and saves it to savepath or returns it as bytes"""
        self.requests['stream'] = True   # We don't want to load the entire file into memory
        response = self.request('get', url, raw_response=True)
        self.requests['stream'] = False  # Return back this setting for all usual requests

        # If a savepath wasn't provided we return an iter_content method
        # so a user can call it with the desired parameters for maximum
        # control and iterate over the response data
        if savepath is None:
            return response.iter_content

        try:
            from urlparse import urlsplit
        except __HOLE__:
            from urllib.parse import urlsplit

        if filename is None:
            filename = urlsplit(url)[2].split('/')[-1]

            if not filename:
                raise FileUrlError

        savepath = os.path.join(savepath, filename)

        with open(savepath, 'wb') as f:
            for chunk in response.iter_content(1024):
                f.write(chunk)

        return savepath
dataset/ETHPy150Open maxtepkeev/python-redmine/redmine/__init__.py/Redmine.download