# 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
        size_label = downloadutils.stringify_size(s)
        V1(f"Downloading files for ObsId {self.obsid}, total size is {size_label}.\n")
        V1("  Type     Format      Size  0........H.........1  Download Time Average Rate")
        V1("  ---------------------------------------------------------------------------")

        nbytes = 0
        dtime = 0

        # re-order into decreasing file size; given that
        # get_download_size has been called we can use the
        # filesize attribute.
        #
        order = sorted([(f.filesize, f) for f in self.files],
                       key=itemgetter(0), reverse=True)

        for oelem in order:
            fileobj = itemgetter(1)(oelem)

            try:
                (a, b) = fileobj.download(self.header)
            except urllib.error.URLError as uerr:
                V1(f"SKIPPING {fileobj.filename} as {uerr}")
                continue

            nbytes += a
            dtime += b

        if LOGGER.getEffectiveVerbose() > 0:
            if len(self.files) > 1 and nbytes > 0:
                sys.stdout.write("\n")

# 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

        size_label = downloadutils.stringify_size(s)
        V1(f"Downloading files for ObsId {self.obsid}, total size is {size_label}.\n")
        V1("  Type     Format      Size  0........H.........1  Download Time Average Rate")
        V1("  ---------------------------------------------------------------------------")

        nbytes = 0
        dtime = 0

        # re-order into decreasing file size; given that
        # get_download_size has been called we can use the
        # filesize attribute.
        #
        order = sorted([(f.filesize, f) for f in self.files],
                       key=itemgetter(0), reverse=True)

        for oelem in order:
            fileobj = itemgetter(1)(oelem)

            try:
                (a, b) = fileobj.download(self.header)
            except urllib.error.URLError as uerr:
                V1(f"SKIPPING {fileobj.filename} as {uerr}")
                continue

            nbytes += a
            dtime += b

        if LOGGER.getEffectiveVerbose() > 0:
            if len(self.files) > 1 and nbytes > 0:
                sys.stdout.write("\n")

                V1(f"      Total download size for ObsId {self.obsid} = {downloadutils.stringify_size(nbytes)}")