# Path: conjureup/utils.py
# def chdir(directory):
# def run(cmd, **kwargs):
# def run_script(path, stderr=PIPE, stdout=PIPE):
# def run_attach(cmd, output_cb=None):
#     def last_ten_lines(s):
# async def arun(cmd, input=None, check=False, env=None, encoding='utf8',
#                stdin=PIPE, stdout=PIPE, stderr=PIPE, cb_stdout=None,
#                cb_stderr=None, **kwargs):
#         async def tstream(source_name, sink, ui_cb):
# def sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# def _sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# async def can_sudo(password=None):
# def juju_version():
# def snap_version():
# def send_msg(msg, label, color, attrs=['bold']):
# def info(msg):
# def error(msg):
# def warning(msg):
# def install_home():
# def juju_path():
# def mkdir(path):
# def _normalize_bundle(original_bundle, overlay_bundle):
# def merge_dicts(*dicts):
# def subtract_dicts(*dicts):
# def chown(path, user, group=None, recursive=False):
# def spew(path, data, owner=None):
# def slurp(path):
# def install_user():
# def set_chosen_spell(spell_name, spell_dir):
# def set_spell_metadata():
# def get_spell_metadata(spell):
# def __available_on_darwin(key):
# def find_spells():
# def find_addons_matching(key):
# def find_spells_matching(key):
# def get_options_whitelist(service_name):
# def gen_hash():
# def gen_model():
# def gen_cloud():
# def is_darwin():
# def is_linux():
# def is_valid_hostname(hostname):
# def set_terminal_title(title):
# def get_physical_network_interfaces():
# def get_physical_network_ipaddr(iface):
# def get_open_port():
#     def __init__(self, *args, **kwargs):
#     def __aiter__(self):
#     async def __anext__(self):
#     async def close(self):
#     def sanitize(self, key, value):
#         def _check_str(s):
#     def __init__(self):
# class IterQueue(asyncio.Queue):
# class SanitizeDataProcessor(SanitizePasswordsProcessor):
# class TestError(Exception):
# class SudoError(Exception):
# class UtilsHTTPError(Exception):


import logging
import os
from glob import glob
from ubuntui.ev import EventLoop
from ubuntui.utils import Color, Padding
from ubuntui.widgets.buttons import PlainButton
from ubuntui.widgets.hr import HR
from urwid import BoxAdapter, Filler, ListBox, Pile, Text, WidgetWrap
from conjureup import utils

    def __init__(self, spell_name, spell_dir,
                 done_callback, initial_height):
        self.spell_name = spell_name
        self.spell_dir = spell_dir
        self.done_callback = done_callback
        self.initial_height = initial_height

        w = self.build_widgets()
        super().__init__(w)

        self.pile.focus_position = 1

    def selectable(self):
        return True

    def keypress(self, size, key):
        if key == 'tab':
            cur = self.pile.focus_position
            self.pile.focus_position = 3 if cur == 1 else 1
        else:
            return super(BundleReadmeView, self).keypress(size, key)

    def build_widgets(self):
        readme_files = glob(os.path.join(self.spell_dir, 'README.*'))
        if len(readme_files) == 0:
            self.readme_w = Text("No README found for bundle.")
        else:
            readme_file = readme_files[0]
            if len(readme_files) != 1:

# Path: conjureup/utils.py
# def chdir(directory):
# def run(cmd, **kwargs):
# def run_script(path, stderr=PIPE, stdout=PIPE):
# def run_attach(cmd, output_cb=None):
#     def last_ten_lines(s):
# async def arun(cmd, input=None, check=False, env=None, encoding='utf8',
#                stdin=PIPE, stdout=PIPE, stderr=PIPE, cb_stdout=None,
#                cb_stderr=None, **kwargs):
#         async def tstream(source_name, sink, ui_cb):
# def sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# def _sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# async def can_sudo(password=None):
# def juju_version():
# def snap_version():
# def send_msg(msg, label, color, attrs=['bold']):
# def info(msg):
# def error(msg):
# def warning(msg):
# def install_home():
# def juju_path():
# def mkdir(path):
# def _normalize_bundle(original_bundle, overlay_bundle):
# def merge_dicts(*dicts):
# def subtract_dicts(*dicts):
# def chown(path, user, group=None, recursive=False):
# def spew(path, data, owner=None):
# def slurp(path):
# def install_user():
# def set_chosen_spell(spell_name, spell_dir):
# def set_spell_metadata():
# def get_spell_metadata(spell):
# def __available_on_darwin(key):
# def find_spells():
# def find_addons_matching(key):
# def find_spells_matching(key):
# def get_options_whitelist(service_name):
# def gen_hash():
# def gen_model():
# def gen_cloud():
# def is_darwin():
# def is_linux():
# def is_valid_hostname(hostname):
# def set_terminal_title(title):
# def get_physical_network_interfaces():
# def get_physical_network_ipaddr(iface):
# def get_open_port():
#     def __init__(self, *args, **kwargs):
#     def __aiter__(self):
#     async def __anext__(self):
#     async def close(self):
#     def sanitize(self, key, value):
#         def _check_str(s):
#     def __init__(self):
# class IterQueue(asyncio.Queue):
# class SanitizeDataProcessor(SanitizePasswordsProcessor):
# class TestError(Exception):
# class SudoError(Exception):
# class UtilsHTTPError(Exception):


# Path: conjureup/ui/views/bundle_readme_view.py
import logging
import os
from glob import glob
from ubuntui.ev import EventLoop
from ubuntui.utils import Color, Padding
from ubuntui.widgets.buttons import PlainButton
from ubuntui.widgets.hr import HR
from urwid import BoxAdapter, Filler, ListBox, Pile, Text, WidgetWrap
from conjureup import utils


    def __init__(self, spell_name, spell_dir,
                 done_callback, initial_height):
        self.spell_name = spell_name
        self.spell_dir = spell_dir
        self.done_callback = done_callback
        self.initial_height = initial_height

        w = self.build_widgets()
        super().__init__(w)

        self.pile.focus_position = 1

    def selectable(self):
        return True

    def keypress(self, size, key):
        if key == 'tab':
            cur = self.pile.focus_position
            self.pile.focus_position = 3 if cur == 1 else 1
        else:
            return super(BundleReadmeView, self).keypress(size, key)

    def build_widgets(self):
        readme_files = glob(os.path.join(self.spell_dir, 'README.*'))
        if len(readme_files) == 0:
            self.readme_w = Text("No README found for bundle.")
        else:
            readme_file = readme_files[0]
            if len(readme_files) != 1:

                utils.warning("Unexpected: {} files matching README.*"