human
I wrote the below code

    download_path = config[DOMAIN][CONF_DOWNLOAD_DIR]
    if (not os.path.isabs(download_path)):
        download_path = hass.config.path(download_path)
    if (not os.path.isdir(download_path)):
        _LOGGER.error('Download    path    %s    does    not    exist.    File    Downloader    not    active', download_path)
        return False
    def download_file(service):
        'Start    thread    to    download    file    specified    in    the    URL.'
        def do_download():
            'Download    the    file.'
            try:
                url = service.data[ATTR_URL]
                subdir = service.data.get(ATTR_SUBDIR)
                if subdir:
                    subdir = sanitize_filename(subdir)
                final_path = None
                req = requests.get(url, stream=True, timeout=10)
                if (req.status_code == 200):
                    filename = None
                    if ('content-disposition' in req.headers):
                        match = re.findall('filename=(\\S+)', req.headers['content-disposition'])
                        if match:
                            filename = match[0].strip('\'"    ')
                    if (not filename):
                        filename = os.path.basename(url).strip()
                    if (not filename):
                        filename = 'ha_download'
                    filename = sanitize_filename(filename)
                    if subdir:
                        subdir_path = os.path.join(download_path, subdir)
                        if (not os.path.isdir(subdir_path)):
                            os.makedirs(subdir_path)
                        final_path = os.path.join(subdir_path, filename)
                    else:
                        final_path = os.path.join(download_path, filename)
                    (path, ext) = os.path.splitext(final_path)
                    tries = 1
                    final_path = (path + ext)
                    while os.path.isfile(final_path):
                        tries += 1
     ...

What's a good function header?

Here's a good function header?
assistant
#Here's a good function header.

def setup(hass, config):