How to use the sen.tui.widgets.table.assemble_rows function in sen

To help you get started, we’ve selected a few sen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TomasTomecek / sen / tests / test_widgets.py View on Github external
def test_assemble_rows_long_text():
    rows = [[get_random_text_widget(10),
             get_random_text_widget(300)] for _ in range(5)]
    assembled_rows = assemble_rows(rows, ignore_columns=[1])
    lb = WidgetBase(SimpleListWalker(assembled_rows))
    canvas = lb.render((80, 20), focus=False)
    text = [bytes().join([t for at, cs, t in ln]) for ln in canvas.content()]
    logging.info("%r", text)
    assert len(text) == 20
    first_col, second_col = text[0].split(b" ", 1)
    assert first_col == rows[0][0].text.encode("utf-8")
    assert rows[0][1].text.encode("utf-8").startswith(second_col)
github TomasTomecek / sen / sen / tui / views / image_info.py View on Github external
def _labels(self):
        if not self.docker_image.labels:
            return []
        data = []
        self.walker.append(RowWidget([SelectableText("")]))
        self.walker.append(RowWidget([SelectableText("Labels", maps=get_map("main_list_white"))]))
        for label_key, label_value in self.docker_image.labels.items():
            data.append([SelectableText(label_key, maps=get_map("main_list_green")), SelectableText(label_value)])
        self.walker.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
data.extend([[SelectableText("")], [
                SelectableText("Network Name", maps=get_map("main_list_white")),
                SelectableText("IP Address", maps=get_map("main_list_white"))
            ]])
            for net_name, net_data in ips.items():
                a4 = net_data.get("ip_address4", "none")
                a6 = net_data.get("ip_address6", "")
                data.append([
                    SelectableText(net_name), SelectableText(a4)
                ])
                if a6:
                    data.append([
                        SelectableText(net_name), SelectableText(a6)
                    ])
        if data:
            self.view_widgets.extend(assemble_rows(data, dividechars=3, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
# TODO: add exit code, created, started, finished, pid
        if self.docker_container.names:
            data.append(
                [SelectableText("Name", maps=get_map("main_list_green")),
                 SelectableText("".join(self.docker_container.names))],
            )

        data.append(
            [SelectableText("FS-type", maps=get_map("main_list_white")),
             SelectableText("size", maps=get_map("main_list_white"))])
        data.append(
            [SelectableText("root"), SelectableText(humanize_bytes(self.docker_container.size_root_fs))])
        data.append(
            [SelectableText("rw"), SelectableText(humanize_bytes(self.docker_container.size_rw_fs))])

        self.view_widgets.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / views / help.py View on Github external
template = [
            SingleTextRow("Buffer: " + self.buffer.display_name,
                          maps={"normal": "main_list_white", "focus": MAIN_LIST_FOCUS}),
            SingleTextRow(""),
            SingleTextRow(self.buffer.description,
                          maps={"normal": "main_list_dg", "focus": MAIN_LIST_FOCUS}),
            SingleTextRow(""),
        ]

        if self.buffer.keybinds:
            template += [
                SingleTextRow("Buffer-specific Keybindings",
                              maps={"normal": "main_list_white", "focus": MAIN_LIST_FOCUS}),
                SingleTextRow(""),
            ]
            template.extend(assemble_rows(
                [[SelectableText(key, maps=get_map("main_list_yellow")),
                  SelectableText(command, maps=get_map("main_list_lg"))]
                 for key, command in self.buffer.keybinds.items()],
                ignore_columns=[1], dividechars=3))

        template += [
            SingleTextRow(""),
            SingleTextRow("Global Keybindings",
                          maps={"normal": "main_list_white", "focus": MAIN_LIST_FOCUS}),
            SingleTextRow("")
        ]
        template.extend(assemble_rows(
            [[SelectableText(key, maps=get_map("main_list_yellow")),
              SelectableText(command, maps=get_map("main_list_lg"))]
             for key, command in self.global_keybinds.items()],
            ignore_columns=[1], dividechars=3))
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
def _labels(self):
        if not self.docker_container.labels:
            return []
        data = []
        self.view_widgets.append(RowWidget([SelectableText("Labels", maps=get_map("main_list_white"))]))
        for label_key, label_value in self.docker_container.labels.items():
            data.append([SelectableText(label_key, maps=get_map("main_list_green")), SelectableText(label_value)])
        self.view_widgets.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / views / image_info.py View on Github external
SelectableText("{0}, {1}".format(self.docker_image.display_formal_time_created(),
                                              self.docker_image.display_time_created()))],
            [SelectableText("Size", maps=get_map("main_list_green")),
             SelectableText(humanize_bytes(self.docker_image.total_size))],
        ]
        if self.docker_image.unique_size:
            data.append(
                [SelectableText("Unique Size", maps=get_map("main_list_green")),
                 SelectableText(humanize_bytes(self.docker_image.unique_size))])
        if self.docker_image.shared_size:
            data.append(
                [SelectableText("Shared Size", maps=get_map("main_list_green")),
                 SelectableText(humanize_bytes(self.docker_image.shared_size))])
        data.append([SelectableText("Command", maps=get_map("main_list_green")),
                     SelectableText(self.docker_image.container_command)])
        self.walker.extend(assemble_rows(data, ignore_columns=[1]))