# Path: rebasehelper/exceptions.py
# class DownloadError(Exception):
#     """Exception indicating that download of a file failed."""
# 
# Path: rebasehelper/logger.py
# class CustomLogger(logging.Logger):
# 
#     TRACE: int = logging.DEBUG + 1
#     VERBOSE: int = logging.DEBUG + 2
#     SUCCESS: int = logging.INFO + 5
#     HEADING: int = logging.INFO + 6
#     IMPORTANT: int = logging.INFO + 7
# 
#     _nameToLevel: Dict[str, int] = {
#         'TRACE': TRACE,
#         'VERBOSE': VERBOSE,
#         'SUCCESS': SUCCESS,
#         'HEADING': HEADING,
#         'IMPORTANT': IMPORTANT,
#     }
# 
#     def __init__(self, name, level=logging.NOTSET):
#         super().__init__(name, level)
# 
#         for lev, severity in self._nameToLevel.items():
#             logging.addLevelName(severity, lev)
# 
#     def __getattr__(self, level):
#         severity = self._nameToLevel.get(level.upper())
# 
#         def log(message, *args, **kwargs):
#             if self.isEnabledFor(severity):
#                 self._log(severity, message, args, **kwargs)
# 
#         if severity:
#             return log
# 
#         raise AttributeError


import logging
import os
import sys
import time
import urllib.error
import urllib.request
import requests
from typing import cast
from rebasehelper.exceptions import DownloadError
from rebasehelper.logger import CustomLogger
                    response.status_code = 200
                    response.headers = requests.structures.CaseInsensitiveDict(getattr(resp, 'headers', {}))
                    response.raw = resp
                    response.url = resp.url
                return response

            def close(self):
                pass

        session = requests.Session()
        session.mount('ftp://', FTPAdapter())

        try:
            return session.get(url, **kwargs)
        except requests.exceptions.RequestException as e:
            logger.error('%s: %s', type(e).__name__, str(e))
            return None

    @staticmethod
    def download_file(url, destination_path, blocksize=8192):
        """Downloads a file from HTTP, HTTPS or FTP URL.

        Args:
            url (str): URL to be downloaded.
            destination_path (str): Path to where the downloaded file will be stored.
            blocksize (int): Block size in bytes.

        """
        r = DownloadHelper.request(url, stream=True)
        if r is None:

# Path: rebasehelper/exceptions.py
# class DownloadError(Exception):
#     """Exception indicating that download of a file failed."""
# 
# Path: rebasehelper/logger.py
# class CustomLogger(logging.Logger):
# 
#     TRACE: int = logging.DEBUG + 1
#     VERBOSE: int = logging.DEBUG + 2
#     SUCCESS: int = logging.INFO + 5
#     HEADING: int = logging.INFO + 6
#     IMPORTANT: int = logging.INFO + 7
# 
#     _nameToLevel: Dict[str, int] = {
#         'TRACE': TRACE,
#         'VERBOSE': VERBOSE,
#         'SUCCESS': SUCCESS,
#         'HEADING': HEADING,
#         'IMPORTANT': IMPORTANT,
#     }
# 
#     def __init__(self, name, level=logging.NOTSET):
#         super().__init__(name, level)
# 
#         for lev, severity in self._nameToLevel.items():
#             logging.addLevelName(severity, lev)
# 
#     def __getattr__(self, level):
#         severity = self._nameToLevel.get(level.upper())
# 
#         def log(message, *args, **kwargs):
#             if self.isEnabledFor(severity):
#                 self._log(severity, message, args, **kwargs)
# 
#         if severity:
#             return log
# 
#         raise AttributeError


# Path: rebasehelper/helpers/download_helper.py
import logging
import os
import sys
import time
import urllib.error
import urllib.request
import requests
from typing import cast
from rebasehelper.exceptions import DownloadError
from rebasehelper.logger import CustomLogger

                    response.status_code = 200
                    response.headers = requests.structures.CaseInsensitiveDict(getattr(resp, 'headers', {}))
                    response.raw = resp
                    response.url = resp.url
                return response

            def close(self):
                pass

        session = requests.Session()
        session.mount('ftp://', FTPAdapter())

        try:
            return session.get(url, **kwargs)
        except requests.exceptions.RequestException as e:
            logger.error('%s: %s', type(e).__name__, str(e))
            return None

    @staticmethod
    def download_file(url, destination_path, blocksize=8192):
        """Downloads a file from HTTP, HTTPS or FTP URL.

        Args:
            url (str): URL to be downloaded.
            destination_path (str): Path to where the downloaded file will be stored.
            blocksize (int): Block size in bytes.

        """
        r = DownloadHelper.request(url, stream=True)
        if r is None:

            raise DownloadError("An unexpected error occurred during the download.")