# Path: src/astrodynamics/utils/compat.py
# WINDOWS = (sys.platform.startswith("win") or
#            (sys.platform == 'cli' and os.name == 'nt'))
# 
# Path: src/astrodynamics/utils/helper.py
# def format_size(value, binary=False, gnu=False, format='%.1f'):
#     """Format a number of bytes like a human readable file size (e.g. 10 kB). By
#     default, decimal suffixes (kB, MB) are used.  Passing binary=true will use
#     binary suffixes (KiB, MiB) are used and the base will be 2**10 instead of
#     10**3.  If ``gnu`` is True, the binary argument is ignored and GNU-style
#     (ls -sh style) prefixes are used (K, M) with the 2**10 definition.
#     Non-gnu modes are compatible with jinja2's ``filesizeformat`` filter.
# 
#     Copyright (c) 2010 Jason Moiron and Contributors.
#     """
#     if gnu:
#         suffix = _size_suffixes['gnu']
#     elif binary:
#         suffix = _size_suffixes['binary']
#     else:
#         suffix = _size_suffixes['decimal']
# 
#     base = 1024 if (gnu or binary) else 1000
#     bytes = float(value)
# 
#     if bytes == 1 and not gnu:
#         return '1 Byte'
#     elif bytes < base and not gnu:
#         return '%d Bytes' % bytes
#     elif bytes < base and gnu:
#         return '%dB' % bytes
# 
#     for i, s in enumerate(suffix):
#         unit = base ** (i + 2)
#         if bytes < unit and not gnu:
#             return (format + ' %s') % ((base * bytes / unit), s)
#         elif bytes < unit and gnu:
#             return (format + '%s') % ((base * bytes / unit), s)
#     if gnu:
#         return (format + '%s') % ((base * bytes / unit), s)
#     return (format + ' %s') % ((base * bytes / unit), s)


import itertools
import sys
import six
    import colorama
from signal import SIGINT, default_int_handler, signal
from progress.bar import Bar, IncrementalBar
from progress.helpers import WritelnMixin
from progress.spinner import Spinner
from .compat import WINDOWS
from .helper import format_size
    @property
    def download_speed(self):
        # Avoid zero division errors...
        if self.avg == 0.0:
            return "..."
        return format_size(1 / self.avg) + "/s"

    @property
    def pretty_eta(self):
        if self.eta:
            return "eta %s" % self.eta_td
        return ""

    def iter(self, it, n=1):
        for x in it:
            yield x
            self.next(n)
        self.finish()


class WindowsMixin(object):

    def __init__(self, *args, **kwargs):
        # The Windows terminal does not support the hide/show cursor ANSI codes
        # even with colorama. So we'll ensure that hide_cursor is False on
        # Windows.
        # This call neds to go before the super() call, so that hide_cursor
        # is set in time. The base progress bar class writes the "hide cursor"
        # code to the terminal in its init, so if we don't set this soon
        # enough, we get a "hide" with no corresponding "show"...

# Path: src/astrodynamics/utils/compat.py
# WINDOWS = (sys.platform.startswith("win") or
#            (sys.platform == 'cli' and os.name == 'nt'))
# 
# Path: src/astrodynamics/utils/helper.py
# def format_size(value, binary=False, gnu=False, format='%.1f'):
#     """Format a number of bytes like a human readable file size (e.g. 10 kB). By
#     default, decimal suffixes (kB, MB) are used.  Passing binary=true will use
#     binary suffixes (KiB, MiB) are used and the base will be 2**10 instead of
#     10**3.  If ``gnu`` is True, the binary argument is ignored and GNU-style
#     (ls -sh style) prefixes are used (K, M) with the 2**10 definition.
#     Non-gnu modes are compatible with jinja2's ``filesizeformat`` filter.
# 
#     Copyright (c) 2010 Jason Moiron and Contributors.
#     """
#     if gnu:
#         suffix = _size_suffixes['gnu']
#     elif binary:
#         suffix = _size_suffixes['binary']
#     else:
#         suffix = _size_suffixes['decimal']
# 
#     base = 1024 if (gnu or binary) else 1000
#     bytes = float(value)
# 
#     if bytes == 1 and not gnu:
#         return '1 Byte'
#     elif bytes < base and not gnu:
#         return '%d Bytes' % bytes
#     elif bytes < base and gnu:
#         return '%dB' % bytes
# 
#     for i, s in enumerate(suffix):
#         unit = base ** (i + 2)
#         if bytes < unit and not gnu:
#             return (format + ' %s') % ((base * bytes / unit), s)
#         elif bytes < unit and gnu:
#             return (format + '%s') % ((base * bytes / unit), s)
#     if gnu:
#         return (format + '%s') % ((base * bytes / unit), s)
#     return (format + ' %s') % ((base * bytes / unit), s)


# Path: src/astrodynamics/utils/progress.py
import itertools
import sys
import six
    import colorama
from signal import SIGINT, default_int_handler, signal
from progress.bar import Bar, IncrementalBar
from progress.helpers import WritelnMixin
from progress.spinner import Spinner
from .compat import WINDOWS
from .helper import format_size

    @property
    def download_speed(self):
        # Avoid zero division errors...
        if self.avg == 0.0:
            return "..."
        return format_size(1 / self.avg) + "/s"

    @property
    def pretty_eta(self):
        if self.eta:
            return "eta %s" % self.eta_td
        return ""

    def iter(self, it, n=1):
        for x in it:
            yield x
            self.next(n)
        self.finish()


class WindowsMixin(object):

    def __init__(self, *args, **kwargs):
        # The Windows terminal does not support the hide/show cursor ANSI codes
        # even with colorama. So we'll ensure that hide_cursor is False on
        # Windows.
        # This call neds to go before the super() call, so that hide_cursor
        # is set in time. The base progress bar class writes the "hide cursor"
        # code to the terminal in its init, so if we don't set this soon
        # enough, we get a "hide" with no corresponding "show"...

        if WINDOWS and self.hide_cursor: