# Path: conjureup/app_config.py
# class AppConfig:
#     def __setattr__(self, name, value):
#     def _internal_state_key(self):
#     def all_steps(self):
#     def has_bundle_modifications(self):
#     async def save(self):
#     async def restore(self):


import random
from ubuntui.utils import Color
from ubuntui.widgets.hr import HR
from ubuntui.widgets.juju.service import ServiceWidget
from ubuntui.widgets.table import Table
from urwid import Pile, Text
from conjureup.app_config import app
from conjureup.ui.views.base import BaseView




class PileTable(Table):
    # ubuntui's Table uses a ListBox, which is a box widget and thus
    # incompatible with Scrollable, so this uses a Pile instead.
    # TODO: Fix or add this in ubuntui
    def __init__(self):
        super().__init__()
        self._pile = Pile([])

    def addRow(self, item, use_divider=True):
        if use_divider and len(self._pile.contents) != 0:
            self._pile.contents.append((HR(0, 0), self._pile.options()))
        self._pile.contents.append((item, self._pile.options()))

    def render(self):
        return self._pile


class DeployStatusView(BaseView):
    show_back_button = False
    metrics_title = 'Deploy Status'

    def __init__(self):
        try:
            name = app.metadata.friendly_name
        except KeyError:

# Path: conjureup/app_config.py
# class AppConfig:
#     def __setattr__(self, name, value):
#     def _internal_state_key(self):
#     def all_steps(self):
#     def has_bundle_modifications(self):
#     async def save(self):
#     async def restore(self):


# Path: conjureup/ui/views/deploystatus.py
import random
from ubuntui.utils import Color
from ubuntui.widgets.hr import HR
from ubuntui.widgets.juju.service import ServiceWidget
from ubuntui.widgets.table import Table
from urwid import Pile, Text
from conjureup.app_config import app
from conjureup.ui.views.base import BaseView





class PileTable(Table):
    # ubuntui's Table uses a ListBox, which is a box widget and thus
    # incompatible with Scrollable, so this uses a Pile instead.
    # TODO: Fix or add this in ubuntui
    def __init__(self):
        super().__init__()
        self._pile = Pile([])

    def addRow(self, item, use_divider=True):
        if use_divider and len(self._pile.contents) != 0:
            self._pile.contents.append((HR(0, 0), self._pile.options()))
        self._pile.contents.append((item, self._pile.options()))

    def render(self):
        return self._pile


class DeployStatusView(BaseView):
    show_back_button = False
    metrics_title = 'Deploy Status'

    def __init__(self):
        try:
            name = app.metadata.friendly_name
        except KeyError:

            name = app.config['spell']