# Path: src/rosrepo/util.py
# def isatty(fd):
#     return hasattr(fd, "isatty") and fd.isatty()
# 
# def get_terminal_size():
#     global _cached_terminal_size
#     if _cached_terminal_size is not None:
#         return _cached_terminal_size
#     try:
#         with open(os.ctermid(), "rb") as f:
#             cr = struct.unpack('hh', fcntl.ioctl(f.fileno(), termios.TIOCGWINSZ, '1234'))
#     except (IOError, struct.error):
#         raise OSError("Cannot determine terminal size")
#     _cached_terminal_size = int(cr[1]), int(cr[0])
#     return _cached_terminal_size
# 
# class UserError(RuntimeError):
#     pass
# 
# Path: src/rosrepo/terminal_color.py
# def fmt(msg, use_color=True, reset=True):
#     """Replaces color annotations with ansi escape sequences"""
#     global _ansi
#     msg = msg.replace('@!', '@{boldon}')
#     msg = msg.replace('@/', '@{italicson}')
#     msg = msg.replace('@_', '@{ulon}')
#     msg = msg.replace('@|', '@{reset}')
#     t = ColorTemplate(msg)
#     return t.safe_substitute(_ansi if use_color else _no_ansi) + (ansi('reset') if reset and use_color else '')


import sys
import re
from getpass import getpass
    from itertools import izip_longest as zip_longest
    from itertools import zip_longest
from .util import isatty, get_terminal_size, UserError
from .terminal_color import fmt as color_fmt
    from .terminal_color import ansi
        from .resolver import get_system_package_manager
    elif isatty(sys.stdout):
        fd = sys.stdout
    else:
        fatal("Need TTY to query credentials\n")
    msg("\n@!Authentication required for @{cf}%s\n" % domain, fd=fd)
    while True:
        login = readline("Username: ", fd=fd)
        if login == "":
            continue
        passwd = getpass("Password: ")
        if passwd == "":
            msg("Starting over\n\n", fd=fd)
            continue
        return login, passwd


def ask_personal_access_token(domain):
    if not isatty(sys.stdin):
        fatal("Need TTY to query credentials\n")
    if isatty(sys.stderr):
        fd = sys.stderr
    elif isatty(sys.stdout):
        fd = sys.stdout
    else:
        fatal("Need TTY to query credentials\n")
    msg("\n@!Authentication required for @{cf}%s\n" % domain, fd=fd)
    return readline("Personal Access Token: ", fd=fd)


def pick_dependency_resolution(package_name, pkg_list):

# Path: src/rosrepo/util.py
# def isatty(fd):
#     return hasattr(fd, "isatty") and fd.isatty()
# 
# def get_terminal_size():
#     global _cached_terminal_size
#     if _cached_terminal_size is not None:
#         return _cached_terminal_size
#     try:
#         with open(os.ctermid(), "rb") as f:
#             cr = struct.unpack('hh', fcntl.ioctl(f.fileno(), termios.TIOCGWINSZ, '1234'))
#     except (IOError, struct.error):
#         raise OSError("Cannot determine terminal size")
#     _cached_terminal_size = int(cr[1]), int(cr[0])
#     return _cached_terminal_size
# 
# class UserError(RuntimeError):
#     pass
# 
# Path: src/rosrepo/terminal_color.py
# def fmt(msg, use_color=True, reset=True):
#     """Replaces color annotations with ansi escape sequences"""
#     global _ansi
#     msg = msg.replace('@!', '@{boldon}')
#     msg = msg.replace('@/', '@{italicson}')
#     msg = msg.replace('@_', '@{ulon}')
#     msg = msg.replace('@|', '@{reset}')
#     t = ColorTemplate(msg)
#     return t.safe_substitute(_ansi if use_color else _no_ansi) + (ansi('reset') if reset and use_color else '')


# Path: src/rosrepo/ui.py
import sys
import re
from getpass import getpass
    from itertools import izip_longest as zip_longest
    from itertools import zip_longest
from .util import isatty, get_terminal_size, UserError
from .terminal_color import fmt as color_fmt
    from .terminal_color import ansi
        from .resolver import get_system_package_manager

    elif isatty(sys.stdout):
        fd = sys.stdout
    else:
        fatal("Need TTY to query credentials\n")
    msg("\n@!Authentication required for @{cf}%s\n" % domain, fd=fd)
    while True:
        login = readline("Username: ", fd=fd)
        if login == "":
            continue
        passwd = getpass("Password: ")
        if passwd == "":
            msg("Starting over\n\n", fd=fd)
            continue
        return login, passwd


def ask_personal_access_token(domain):
    if not isatty(sys.stdin):
        fatal("Need TTY to query credentials\n")
    if isatty(sys.stderr):
        fd = sys.stderr
    elif isatty(sys.stdout):
        fd = sys.stdout
    else:
        fatal("Need TTY to query credentials\n")
    msg("\n@!Authentication required for @{cf}%s\n" % domain, fd=fd)
    return readline("Personal Access Token: ", fd=fd)


def pick_dependency_resolution(package_name, pkg_list):

    if not isatty(sys.stdin):