<commit_before>""" Service Walkthrough view

List out the updated bundle in a cleaner view showing what
charms and their relations will be done.
"""

from urwid import WidgetWrap, Pile, Filler
from ubuntui.widgets.buttons import PlainButton
from ubuntui.widgets.text import Instruction
from ubuntui.widgets.hr import HR
from ubuntui.utils import Padding
from ubuntui.ev import EventLoop

from conjure.ui.widgets.service_walkthrough_widget import (
    ServiceWalkthroughWidget
)


class ServiceWalkthroughView(WidgetWrap):
    def __init__(self, app, placement_controller, done_cb):
        self.app = app
        self.placement_controller = placement_controller
        self.done_cb = done_cb
        self.walkthrough_widgets = []
        w = self.build_widgets()
        super().__init__(w)

    def build_widgets(self):
        self.continue_button = PlainButton("Accept defaults and continue",
                                           self.handle_done)
        self.walkthrough_widgets = self.build_walkthrough_widgets()
        _pile = [
            Padding.center_90(
                Instruction(
                    "Services")),
            Padding.center_90(HR()),
            Padding.center_90(self.continue_button),
            Padding.center_90(Pile(self.walkthrough_widgets)),
        ]
        return Filler(Pile(_pile), valign="top")

    def build_walkthrough_widgets(self):
        ws = []

        for service in self.placement_controller.services():
            ws.append(ServiceWalkthroughWidget(service,
                                               self.app.metadata_controller,
                                               self.handle_scale_change,
                                               self.handle_ctype_change))
        return ws

    def update(self, *args, **kwargs):
        for w in self.walkthrough_widgets:
            w.update()
        EventLoop.set_alarm_in(1, self.update)

    def handle_done(self, button):
        self.done_cb()

    def handle_scale_change(self, service, value):
        ""

    def handle_ctype_change(self, service, value):
        ""
<commit_msg>Simplify padding and remove unneeded pile<commit_after>""" Service Walkthrough view

List out the updated bundle in a cleaner view showing what
charms and their relations will be done.
"""

from urwid import WidgetWrap, Pile, Filler
from ubuntui.widgets.buttons import PlainButton
from ubuntui.widgets.text import Instruction
from ubuntui.widgets.hr import HR
from ubuntui.utils import Padding
from ubuntui.ev import EventLoop

from conjure.ui.widgets.service_walkthrough_widget import (
    ServiceWalkthroughWidget
)


class ServiceWalkthroughView(WidgetWrap):
    def __init__(self, app, placement_controller, done_cb):
        self.app = app
        self.placement_controller = placement_controller
        self.done_cb = done_cb
        self.walkthrough_widgets = []
        w = self.build_widgets()
        super().__init__(w)

    def build_widgets(self):
        self.continue_button = PlainButton("Accept defaults and continue",
                                           self.handle_done)
        self.walkthrough_widgets = self.build_walkthrough_widgets()
        _pile = [
            Padding.center_90(
                Instruction(
                    "Services")),
            Padding.center_90(HR()),
            Padding.center_90(self.continue_button)] + \
            [Padding.center_70(w) for w in
             self.walkthrough_widgets]

        return Filler(Pile(_pile), valign="top")

    def build_walkthrough_widgets(self):
        ws = []

        for service in self.placement_controller.services():
            ws.append(ServiceWalkthroughWidget(service,
                                               self.app.metadata_controller,
                                               self.handle_scale_change,
                                               self.handle_ctype_change))
        return ws

    def update(self, *args, **kwargs):
        for w in self.walkthrough_widgets:
            w.update()
        EventLoop.set_alarm_in(1, self.update)

    def handle_done(self, button):
        self.done_cb()

    def handle_scale_change(self, service, value):
        ""

    def handle_ctype_change(self, service, value):
        ""

{'fraction_non_alphanumeric': 0.07850467289719626, 'fraction_numerical': 0.004205607476635514, 'mean_word_length': 2.147794117647059, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3210394', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1078, 'n_words': 259}