# Path: ciao_contrib/downloadutils.py
# def manual_download(url):
# def retrieve_url(url, timeout=None):
#     def __init__(self, *args, **kwargs):
#     def add_link(self):
#     def handle_starttag(self, tag, attrs):
#     def handle_endtag(self, tag):
#     def handle_data(self, data):
# def unpack_filelist_html(txt, baseurl):
# def find_downloadable_files(urlname, headers):
# def find_all_downloadable_files(urlname, headers):
#     def __init__(self, size, nhash=20, hashchar='#'):
#     def start(self, nbytes=0):
#     def add(self, nbytes):
#     def end(self):
# def myint(x):
# def stringify_dt(dt):
# def stringify_size(s):
# def download_progress(url, size, outfile,
#                       headers=None,
#                       progress=None,
#                       chunksize=8192,
#                       verbose=True):
# class DirectoryContents(HTMLParser):
# class ProgressBar:


import sys
import os
import os.path
import ssl
import urllib.parse
import urllib.request
import ciao_contrib.logger_wrapper as lw
from operator import itemgetter
from ciao_contrib import downloadutils
    def download(self, headers):
        """Download the file.

        The file is written to the location obsid/filename and screen
        output will be displayed to indicate the process of the
        transfer unless the logging verbose level is set to 0.

        If the file already exists AND has a size equal to the archive
        size then we skip. If the size is smaller then we try to
        resume the download. If the size is larger then we skip, but
        with a warning message.

        The return value is a tuple of number of bytes and download
        time in seconds (if nothing is downloaded then the values are
        set to 0).
        """

        verbose = LOGGER.getEffectiveVerbose() > 0

        V3(f"Starting download of {self.filename}")
        size = self.get_filesize(headers)

        if self.localpath != '':
            create_directory(self.localpath)

        outfile = os.path.join(self.localpath, self.filename)

        # Can not use V1 here since do not want to add an end-of-line
        # character
        if verbose:

# Path: ciao_contrib/downloadutils.py
# def manual_download(url):
# def retrieve_url(url, timeout=None):
#     def __init__(self, *args, **kwargs):
#     def add_link(self):
#     def handle_starttag(self, tag, attrs):
#     def handle_endtag(self, tag):
#     def handle_data(self, data):
# def unpack_filelist_html(txt, baseurl):
# def find_downloadable_files(urlname, headers):
# def find_all_downloadable_files(urlname, headers):
#     def __init__(self, size, nhash=20, hashchar='#'):
#     def start(self, nbytes=0):
#     def add(self, nbytes):
#     def end(self):
# def myint(x):
# def stringify_dt(dt):
# def stringify_size(s):
# def download_progress(url, size, outfile,
#                       headers=None,
#                       progress=None,
#                       chunksize=8192,
#                       verbose=True):
# class DirectoryContents(HTMLParser):
# class ProgressBar:


# Path: ciao_contrib/cda/data.py
import sys
import os
import os.path
import ssl
import urllib.parse
import urllib.request
import ciao_contrib.logger_wrapper as lw
from operator import itemgetter
from ciao_contrib import downloadutils

    def download(self, headers):
        """Download the file.

        The file is written to the location obsid/filename and screen
        output will be displayed to indicate the process of the
        transfer unless the logging verbose level is set to 0.

        If the file already exists AND has a size equal to the archive
        size then we skip. If the size is smaller then we try to
        resume the download. If the size is larger then we skip, but
        with a warning message.

        The return value is a tuple of number of bytes and download
        time in seconds (if nothing is downloaded then the values are
        set to 0).
        """

        verbose = LOGGER.getEffectiveVerbose() > 0

        V3(f"Starting download of {self.filename}")
        size = self.get_filesize(headers)

        if self.localpath != '':
            create_directory(self.localpath)

        outfile = os.path.join(self.localpath, self.filename)

        # Can not use V1 here since do not want to add an end-of-line
        # character
        if verbose:

            slabel = downloadutils.stringify_size(size)