Пример #1
0
def main() -> None:
    previous: list[str] = [""] * 20
    with Live() as live:
        while True:
            mvp, non_mvp = get_idols()

            above = Table.grid(expand=True)
            above.add_column(width=2)
            above.add_column(width=3)
            above.add_column()
            for i, player in enumerate(mvp):
                above.add_row(*format_row(i, player, previous))

            noodle = r"[yellow]\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/"

            below = Table.grid(expand=True)
            below.add_column(width=2)
            below.add_column(width=3)
            below.add_column()
            for j, player in enumerate(non_mvp):
                below.add_row(*format_row(i + j + 1, player, previous))

            live.update(Panel(RenderGroup(above, noodle, below)))
            previous = mvp + non_mvp
            time.sleep(30)
Пример #2
0
def make_info_panel(debugger) -> Layout:
    info_layout = Layout(name='Info')
    info_layout.split_row(Layout(name='runtime_state'),
                          Layout(name='world_state'))

    pc = debugger.executor.vm_context.code.pc + 1
    insn = debugger.executor.disasm_dict[pc]
    opcode = insn.byte
    mnemonic = insn.mnemonic
    msg = debugger.executor.vm_context.msg
    info_table = Table(box=box.SIMPLE)
    info_table.grid(padding=1)
    info_table.add_column('Key', justify="middle", style="cyan", no_wrap=True)
    info_table.add_column("Value", justify="middle", style="magenta")
    info_table.add_row('PC', f'{str(pc)} ({hex(pc)})')
    info_table.add_row('Opcode', f'{int(opcode[2:], 16)} ({opcode})')
    info_table.add_row('Mnemonic', f'{mnemonic}')
    info_table.add_row('', '')
    info_table.add_row('Sender', f'0x{msg.sender.hex()}')
    if msg.to:
        info_table.add_row('To', f'0x{msg.to.hex()}')
    elif msg.storage_address:
        info_table.add_row('To', f'0x{msg.storage_address.hex()}')
    elif msg.code_address:
        info_table.add_row('To', f'0x{msg.code_address.hex()}')
    info_table.add_row('Gas Price', str(msg.gas_price))
    info_table.add_row('Nonce', str(debugger.executor.vm_context.msg.depth))

    info_panel = Panel(
        info_table,
        box=box.ROUNDED,
        title="[b red]Runtime State",
        border_style="bright_blue",
    )

    state = debugger.executor.vm_context.state
    world_state_table = Table(box=box.SIMPLE)
    world_state_table.grid(padding=1)
    world_state_table.add_column('Key',
                                 justify="middle",
                                 style="cyan",
                                 no_wrap=True)
    world_state_table.add_column("Value", justify="middle", style="magenta")
    world_state_table.add_row('coinbase', f'{state.coinbase.hex()}')
    world_state_table.add_row('timestamp', f'{state.timestamp}')
    world_state_table.add_row('block_number', f'{state.block_number}')
    world_state_table.add_row('difficulty', f'{state.difficulty}')
    world_state_table.add_row('gas_limit', f'{state.gas_limit}')

    world_state_panel = Panel(
        world_state_table,
        box=box.ROUNDED,
        title="[b red]World State",
        border_style="bright_blue",
    )

    info_layout["runtime_state"].update(info_panel)
    info_layout["world_state"].update(world_state_panel)

    return info_layout
Пример #3
0
    def render(self, displays, bootstrap=True):
        b = self.board
        # Recover state
        for display in displays:
            self.round += 1
            if not display: display = {}
            change = []
            if 'x' not in display: continue
            if 'x' in display:
                x = display['x']
                y = display['y']
                if x == -1: continue
                color = 2 - self.round % 2
                b[x][y] = color
                self.count[color] += 1
                for dx, dy in ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1),
                               (1, -1), (1, 0), (1, 1)):
                    t = []
                    nx = x + dx
                    ny = y + dy
                    while self._in_board(nx, ny) and b[nx][ny] == 3 - color:
                        t.append((nx, ny))
                        nx += dx
                        ny += dy
                    if not (self._in_board(nx, ny) and b[nx][ny] == color):
                        continue
                    change.extend(t)
                for nx, ny in change:
                    b[nx][ny] = color
                self.count[color] += len(change)
                self.count[3 - color] -= len(change)

        message = 'Round: %d\n%s: %d\n%s: %d\nNext: %s' % (
            self.round, self.stones[1], self.count[1], self.stones[2],
            self.count[2], self.stones[1 + self.round % 2])
        style_cur = lambda s: Text(s, style='red')
        style_change = lambda s: Text(s, style='yellow')
        style_normal = lambda s: s
        styles = [[style_normal for i in range(8)] for j in range(8)]
        if displays:
            d = displays[-1]
            if not d: d = {}
            x = d.get('x', -1)
            y = d.get('y', -1)
            if x == -1 and self.round:
                message += '\n%s skipped!' % self.stones[2 - self.round % 2]
            else:
                styles[x][y] = style_cur
            if 'winner' in d:
                message += '\n%s wins!' % self.stones[d['winner'] + 1]
            for x, y in change:
                styles[x][y] = style_change
        t = Table.grid(padding=(0, 1))
        t.add_row('', *map(chr, range(65, 65 + 8)))
        for j in range(8):
            t.add_row(str(1 + j),
                      *[styles[i][j](self.stones[b[i][j]]) for i in range(8)])
        tt = Table.grid(padding=(0, 4))
        tt.add_row(t, message)
        print(Panel.fit(tt, box=box.SQUARE))
Пример #4
0
    def show_calendar(self):
        console = Console()

        current_date_label = Table.grid()
        current_date_label.add_column(justify='center', style='grey35')
        current_date_label.add_row(
            f'{self.selected_date.strftime("%b, %Y"):^32}')

        num_rows, _ = self.month.shape
        list_of_days = [day for day in calendar.day_abbr]

        table = Table(show_lines=True, box=box.SIMPLE)

        for header_el in list_of_days:
            table.add_column(header_el, justify="center", no_wrap=True)

        for row_idx in range(num_rows):
            data = [
                self.__add_color(self.colors, row_idx, idx, x)
                for idx, x in enumerate(self.month[row_idx])
            ]
            table.add_row(*data)

        controls = Table.grid()
        controls.add_column(justify='left', style='green', no_wrap=True)
        controls.add_column(justify='center', style='red', no_wrap=True)
        controls.add_column(justify='right', style='green', no_wrap=True)
        controls.add_row('<-- prev' + ' ' * 9, 'ESQ exit',
                         ' ' * 9 + 'next -->')

        console.print(current_date_label)
        console.print(table)
        console.print(controls)
Пример #5
0
def make_funcsign_panel(debugger) -> Panel:
    funcsign_table = Table(box=box.SIMPLE)
    funcsign_table.grid(padding=2)
    funcsign_table.add_column('Xref',
                              justify="middle",
                              style="cyan",
                              no_wrap=True)
    funcsign_table.add_column("Sign", justify="middle", style="magenta")
    funcsign_table.add_column("Name", justify="middle", style="magenta")
    funcsign_table.add_column("Prefered_name",
                              justify="middle",
                              style="magenta")
    funcsign_table.add_column("Most_prefered_name",
                              justify="middle",
                              style="magenta")

    for i in debugger.func_sign:
        prefered_name = ' '.join(i.prefered_name)
        most_prefered_name = ' '.join(i.most_prefered_name)
        funcsign_table.add_row(str(i.xref), str(i.sign), i.name, prefered_name,
                               most_prefered_name)

    funcsign_panel = Panel(
        funcsign_table,
        box=box.ROUNDED,
        padding=(1, 1),
        title="[b red]Function Sign",
        border_style="bright_blue",
    )
    return funcsign_panel
Пример #6
0
 def render(self, displays, bootstrap = True):
     b = self.board
     x = y = -1
     # Recover state
     for display in displays:
         self.round += 1
         if not display: continue
         if 'x' not in display: continue
         x = display['x']
         y = display['y']
         color = 2 - self.round % 2
         self.board[x][y] = color
     
     message = 'Round: %d' % self.round
     if displays and displays[-1]:
         winner = displays[-1].get('winner', None)
     elif self.round == 9:
         winner = ''
     else:
         winner = None
     if winner is not None:
         if isinstance(winner, int):
             message += '\n%s wins!' % self.stones[winner + 1]
         else:
             message += '\nA tie!'
     else:
         message += '\nNext: %s' % self.stones[self.round % 2 + 1]
     t = Table.grid(padding = (0, 1))
     t.add_row('', *map(chr, range(65, 65 + 3)))
     for j in range(3):
         t.add_row(str(1 + j), *[Text(self.stones[b[i][j]], style = 'red') if i == x and j == y else self.stones[b[i][j]] for i in range(3)])
     tt = Table.grid(padding = (0, 4))
     tt.add_row(t, message)
     print(Panel.fit(tt, box = box.SQUARE))
Пример #7
0
def make_sponsor_message() -> Panel:
    """Some example content."""
    sponsor_message = Table.grid(padding=1)
    sponsor_message.add_column(style="green", justify="right")
    sponsor_message.add_column(no_wrap=True)
    sponsor_message.add_row(
        "✔ GitHub 🤓 ",
        "[u blue link=https://github.com/jiaulislam]https://github.com/jiaulislam",
    )

    intro_message = Text.from_markup(
        """Consider supporting my work via Github 🤘 🤘 🤘. - Jiaul Islam"""
    )

    message = Table.grid(padding=1)
    message.add_column()
    message.add_column(no_wrap=True)
    message.add_row(intro_message, sponsor_message)

    message_panel = Panel(
        Align.center(
            RenderGroup(intro_message, "\n", Align.center(sponsor_message)),
            vertical="middle",
        ),
        box=box.ROUNDED,
        padding=(1, 2),
        title="[b red]Thanks for using my application!",
        border_style="bright_blue",
    )
    return message_panel
Пример #8
0
    def render(self, displays, bootstrap=True):
        b = self.board
        # Recover state
        for display in displays:
            self.round += 1
            if not display: continue
            status = display.get('status', None)
            if not status: status = []
            for pos in status:
                x = pos['row']
                y = pos['col']
                val = pos['val']
                b[x][y] = val
                if val == 9: self.mineleft -= 1

        message = 'Round: %d\nMines total: %d\nMines left: %d' % (
            self.round, self.minecount, self.mineleft)
        if displays:
            d = displays[-1]
            if not d: d = {}
            if 'msg' in d:
                if d['msg'] == 'INVALIDMOVE':
                    message += '\nInvalid move!'
                elif d['msg'] == 'FINISH':
                    message += '\nFinish!'
        t = Table.grid()
        for x in range(self.height):
            t.add_row(*(self.draw[b[x][y]] for y in range(self.width)))
        tt = Table.grid(padding=(0, 4))
        tt.add_row(t, message)
        print(Panel.fit(tt, box=box.SQUARE))
Пример #9
0
    def build_panel(self) -> Panel:
        """Builds and returns a panel for a Monitor of this Reservation

        Returns:
            Panel: The Build Panel
        """
        heading_information = Table.grid(expand=True)
        heading_information.add_column()
        heading_information.add_column(style="green")

        reserving_table = Table(title=f"[bold green]Reserving on ...",
                                show_header=False)

        for key, value in self.params.dict().items():
            reserving_table.add_row(key, str(value))

        heading_information.add_row(self.node.__rich__(), reserving_table)

        self.table = Table()
        self.table.add_column("Level")
        self.table.add_column("Message")

        columns = Table.grid(expand=True)
        columns.add_column()

        columns.add_row(heading_information)
        columns.add_row(self.table)

        return Panel(columns, title="Reservation")
Пример #10
0
def make_card(
    title: Optional[str],
    right_of_title: str,
    description: str,
    labels: Iterable[Label],
    card_title: str,
    card_style: str = "default",
) -> Panel:
    title = title or ""  # no silly 'None' as title
    header = Table.grid(expand=True)
    header.add_column()
    header.add_column(justify="right")
    header.add_row(
        f"[bold]{rich.markup.escape(title)}",
        f"[bold blue]{right_of_title}",
    )

    card = Table.grid(padding=1, expand=True)
    card.add_column()
    card.add_row(header)
    card.add_row(Markdown(description))

    if labels:
        label_row = Table.grid(expand=True)
        label_row.add_column(justify="right")
        label_row.add_row(", ".join(map(str, labels)))
        card.add_row(label_row)

    return Panel(
        card,
        title=card_title,
        style=card_style,
        box=rich.box.ROUNDED if "on " not in card_style else Box("    \n" * 8),
    )
Пример #11
0
    def render(self, displays, bootstrap=True):
        b = self.board
        # Recover state
        for display in displays:
            self.round += 1
            self.count = [display['blackCount'], display['whiteCount']]
            if 'x0' not in display: continue
            x0 = display['x0']
            if x0 == -1: continue
            y0 = display['y0']
            x1 = display['x1']
            y1 = display['y1']
            x2 = display['x2']
            y2 = display['y2']
            color = 2 - self.round % 2
            b[x1][y1] = b[x0][y0]
            b[x0][y0] = 0
            b[x2][y2] = -1

        message = 'Round: %d\n%s: %d\n%s: %d\nNext: %s' % (
            self.round, self.stones[1], self.count[0], self.stones[2],
            self.count[1], self.stones[1 + self.round % 2])
        styles = [[
            self.stones[b[i][j]]
            if b[i][j] >= 0 else Text(self.stones[b[i][j]], style='blue')
            for j in range(self.size)
        ] for i in range(self.size)]
        if displays:
            d = displays[-1]
            if not d: d = {}
            x0 = d.get('x0', -1)
            y0 = d.get('y0', -1)
            if x0 != -1 and isinstance(styles[x0][y0], str):
                styles[x0][y0] = Text(styles[x0][y0], 'on red')
            x1 = d.get('x1', -1)
            y1 = d.get('y1', -1)
            if x1 != -1:
                styles[x1][y1] = Text(styles[x1][y1], 'on green')
            x2 = d.get('x2', -1)
            y2 = d.get('y2', -1)
            if x2 != -1:
                styles[x2][y2].style = 'blue on yellow'
            if 'winner' in d:
                message += '\n%s wins!' % self.stones[d['winner'] + 1]
        t = Table.grid(padding=(0, 1))
        t.add_row('', *map(chr, range(65, 65 + self.size)))
        for j in range(self.size):
            t.add_row(str(1 + j), *[styles[i][j] for i in range(self.size)])
        tt = Table.grid(padding=(0, 4))
        tt.add_row(t, message)
        print(Panel.fit(tt, box=box.SQUARE))
Пример #12
0
    def render(self, displays, bootstrap=True):
        b = self.board
        x = y = -1
        # Recover state
        for display in displays:
            self.round += 1
            if not display: continue
            if 'x' not in display: continue
            x = display['x'] - 1
            y = display['y'] - 1
            color = display['color']
            self.board[x][y] = color + 1
            for d in display['remove']:
                self.board[d['x'] - 1][d['y'] - 1] = 0

        message = 'Round: %d' % self.round
        if displays:
            if 'x' not in display:
                x = y = -1
            if 'winner' in display:
                message += '\n\nwinner: %s' % self.stones[display['winner'] +
                                                          1]
                if 'stones' in display:
                    display = display['stones']
                    for i in range(2):
                        message += ('\n\n%s: %f' %
                                    (self.stones[i + 1],
                                     display[str(i)])).rstrip('0').rstrip('.')
                    message += ('\n\nkomi: %f' %
                                display['komi']).rstrip('0').rstrip('.')
                if 'error_info' in display:
                    message += '\n\nError: %s' % display['error_info']
            elif 'x' not in display and self.round > 0:
                message += '\n\n%s pass!' % self.stones[2 - self.round % 2]
            else:
                message += '\n\nNext: %s' % self.stones[self.round % 2 + 1]
        t = Table.grid(padding=(0, 1))
        t.add_row('', *map(chr, range(65, 65 + self.size)))
        for j in range(self.size):
            t.add_row(
                str(1 + j), *[
                    Text(self.stones[b[i][j]], style='red')
                    if i == x and j == y else self.stones[b[i][j]]
                    for i in range(self.size)
                ])
        tt = Table.grid(padding=(0, 4))
        tt.add_row(t, message)
        print(Panel.fit(tt, box=box.SQUARE))
Пример #13
0
    def draw_summary(self):

        grid = Table.grid(expand=True)
        grid.add_column()
        grid.add_row("[bold]Groups[/]")
        grid.add_row(self.draw_deptree_commands_summary())
        grid.add_row("")
        grid.add_row("[bold]Packages[/]")
        grid.add_row(self.draw_packages())
        grid.add_row("")
        if self.parser.unresolved:
            grid.add_row("[bold]Unresolved[/]")
            grid.add_row(self.draw_unresolved_summary())

        # Switch to using tables
        # lOutTxt = ''
        # lOutTxt += self.draw_deptree_commands_summary()

        # lOutTxt += '\n'
        # lOutTxt += self.draw_packages()

        # if self.parser.unresolved:
        #     lOutTxt += self.draw_unresolved_summary()
        #     return lOutTxt

        return grid
Пример #14
0
def make_table(
    milestone: Optional[str] = None,
    assignees: Optional[Iterable[str]] = None,
    project: Optional[str] = None,
    project_column: Optional[str] = None,
    url: Optional[str] = None,
    local_copy: Optional[str] = None,
) -> Table:
    assignees = assignees or []
    listing = Table.grid(expand=True, padding=0)
    listing.add_column()
    listing.add_column(justify="right")
    if project:
        listing.add_row(
            "Card in",
            f"[bold blue]{project}[/] [bold dim]>[/] [blue]{project_column}",
        )
    if milestone:
        listing.add_row("Milestone'd to", f"[bold blue]{milestone}[/]")
    if list(assignees):
        listing.add_row(
            "Assigned to",
            ", ".join(f"[bold dim]@[/][bold blue]{name}[/]"
                      for name in assignees),
        )

    if url:
        listing.add_row("Available at",
                        f"[blue link {url}]{rich.markup.escape(url)}")

    if local_copy:
        listing.add_row("Local copy at", f"[blue]{local_copy}")

    return listing
Пример #15
0
def update_postseason(title: str, data: Games) -> None:
    layout["header"].update(Panel(Text(title, justify="center")))

    for subleague, games in data.items():
        tables = []
        for game in games.values():
            table = Table.grid(expand=True)
            table.add_column("Seed", width=1)
            table.add_column("Name")
            table.add_column("Championships", style="#FFEB57", width=4)
            table.add_column("Wins", width=1)
            for row in game:
                table.add_row(
                    row.seed,
                    Text(row.name, style=row.color),
                    "●" * row.championships if row.championships < 4 else f"●x{row.championships}",
                    row.wins,
                )
            tables.append(Layout(table))

        all_tables = Layout()
        all_tables.split(*tables)
        layout[subleague].update(Panel(
            all_tables,
            title=subleague,
            padding=0
        ))
Пример #16
0
    def _update(self):
        wall = (f" in {readable_duration(self._walltime)}"
                if self._walltime else "")
        footer = [
            f"#{self.num} ({self._status}{wall})",
            "[bold](c)[/bold]ontinue",
            "[bold](r)[/bold]erun",
            (not self._has_result and not self._has_error)
            and "[bold](a)[/bold]bort",
            "[bold](q)[/bold]uit",
        ]
        self.dash.header = markup(f"Looping on: [bold]{self.signature()}")
        self.dash.footer = markup(" | ".join(x for x in footer if x))

        if self._gvn:
            self.dash.stack["given"].clear()
            table = Table.grid(padding=(0, 3, 0, 0))
            table.add_column("key", style="bold green")
            table.add_column("value")
            for k, v in self._gvn.items():
                table.add_row(k, Pretty(v))
            with TEMP_CONSOLE.capture() as cap:
                TEMP_CONSOLE.print(table)
            self.dash.stack["given"].add(cap.get())

        self.dash.update()
Пример #17
0
    def emit(self, record: LogRecord) -> None:
        output = Table.grid(padding=(0, 1))
        output.expand = True
        output.add_column()
        output.add_column()
        output.add_column()
        output.add_column(ratio=1, overflow="fold")

        row = []

        log_time = ""
        if self.show_time:
            log_time = f"{self.formatter.formatTime(record)}"
            color = self.log_colors.get("time")
            row.append(Text(log_time, style=color))

        log_level = ""
        if self.show_level:
            log_level = f"{record.levelname:<7}"
            color = self.log_level_colors.get(record.levelname)
            row.append(Text(log_level, style=color))

        log_path = ""
        if self.show_path:
            log_path = f"{record.name}:{record.lineno}"
            color = self.log_colors.get("path")
            row.append(Text(log_path, style=color))

        log_message = record.getMessage()
        row.append(log_message)

        output.add_row(*row)
        # items = [*filter(None, [log_time, log_level, log_path, log_message])]
        # self.console.print(*items)
        self.console.print(output)
Пример #18
0
 def render_repo(repo):
     """Yields renderables for a single repo."""
     yield Rule(style="bright_yellow")
     yield ""
     # Table with description and stats
     title_table = Table.grid(padding=(0, 1))
     title_table.expand = True
     stats = "{stargazers_count} ⭐ {forks_count} 🍴 {watchers_count} 👀".format(**repo)
     title = Text(repo["full_name"], overflow="fold")
     title.stylize_all(f"yellow link {repo['html_url']}")
     title_table.add_row(title, Text(stats, style="bold blue"))
     title_table.columns[1].no_wrap = True
     title_table.columns[1].justify = "right"
     yield title_table
     yield ""
     # Language
     language = repo["language"]
     if language:
         yield Text(language, style="bold cyan")
     else:
         yield "[i cyan]unknown language"
     yield ""
     # Descripion
     description = repo["description"]
     if description:
         yield Text(description.strip(), style="green")
     else:
         yield "[i green]no description"
     yield ""
Пример #19
0
    def RichGrid(self):
        '''
		docstring
		'''
        tasks = self.taskManager.tasks
        tasks = sorted(tasks, key=lambda task: task.DaysLeft(), reverse=False)

        grid = Table.grid(expand=True)
        grid.add_column(justify='right', no_wrap=True, max_width=16)
        grid.add_column(justify='left', no_wrap=True)
        # grid.add_column(justify='left', no_wrap=True)
        # grid.add_column(justify='left', no_wrap=True)
        grid.add_row(" ", " " + self._MonthCell())
        grid.add_row(" ", " " + self._DayCell())

        for task in tasks:
            if task.DaysLeft() < self.daysOut - 1 and task.isOpen:
                grid.add_row(task.label, self._ProgressCell(task))
        # grid.add_row(" ", " " + self._DayCell()+ '')
        # grid.add_row(" ", " " + self._MonthCell()+ '')

        return grid


####### for testing

### Testing
# if True:

# 	tasks = [Task('label1', 'tag1', 'Feb 28', True), Task('label2', 'tag2', 'Feb 27', True), Task('label3', 'tag1', 'Mar 07', True), Task('label4', 'tag2', 'Feb 19 2021', True)]

# 	calendarView = CalendarView(tasks)
# 	console = Console()

# 	console.print(calendarView.RichGrid())
Пример #20
0
def update_postseason(data: Brackets) -> None:
    for bracket, leagues in data.items():
        if bracket == "overbracket":
            layout["header"].update(
                Text(f"{leagues['name']} {leagues['round']}",
                     justify="center"))
        else:
            layout["footer"].update(
                Text(f"{leagues['name']} {leagues['round']}",
                     justify="center"))
        for subleague, games in leagues["games"].items():
            tables = []
            for game in games.values():
                table = Table.grid(expand=True)
                table.add_column("Seed", width=1)
                table.add_column("Name")
                table.add_column("Championships", width=2)
                table.add_column("Wins", width=1)
                for row in game:
                    table.add_row(
                        str(row.seed),
                        f"[{row.color}]{row.name}[/]",
                        clip_championships(row),
                        str(row.wins),
                    )
                tables.append(Layout(table))

            all_tables = Layout()
            all_tables.split(*tables)
            layout[bracket][subleague].update(
                Panel(all_tables, title=subleague, padding=0))
Пример #21
0
def update_standings(title: str, data: Prediction) -> None:
    layout["header"].update(Panel(Text(title, justify="center")))

    for subleague, rows in data.items():
        teams = Table.grid(expand=True)
        teams.add_column("Flag", width=2)
        teams.add_column("Name")
        teams.add_column("Championships", width=3, style="#FFEB57")
        teams.add_column("Wins", width=4, justify="right")
        teams.add_column("Record", width=6, justify="right")
        teams.add_column("Estimate", width=3, justify="right")
        for row in rows:
            if not row:
                teams.add_row()
            else:
                teams.add_row(
                    row.badge,
                    Text.assemble((row.name, row.color), f"[{row.tiebreaker}]"),
                    "●" * row.championships if row.championships < 4 else f"●x{row.championships}",
                    f"{'*' if row.in_progress else ''}{row.wins}",
                    row.record,
                    row.estimate,
                )

        layout[subleague].update(Panel(
            teams,
            title=subleague,
            padding=0,
        ))
Пример #22
0
def print_result():
    global info

    if info['mode'] == 2: console.print(info)
    if info['mode'] == 1: console.print('time cost:' + str(info['costs']))

    table = Table.grid(expand=True)
    for i in range(3):
        table.add_column('id%s' % i, style="cyan")
        table.add_column('ct%s' % i, style="yellow")

    info['mincost'] = fm_time(min(info.get('costs')))
    info['avgcost'] = fm_time(sum(info.get('costs')) / info['repeat'])

    table.add_row('【语言】', info['lang'], '【版本】', info['version'], '【运行程序】', info['tag'])
    table.add_row('【机器架构】', info['machine'], '【操作系统】', info['os'], '【Docker镜像】', info['docker'])
    table.add_row('【页面大小】', n2s(info['page']), '【运行模式】', str(info['mode']), '【线程数】', str(info['thread']))
    table.add_row('【计算范围】', '%.0e(%s)' % (info['limit'], n2s(info['limit'])), '【素数数量】', info['maxind'], '【最大素数】',
                  str(info['maxprime']))
    table.add_row('【计算次数】', str(info['repeat']), '【最好成绩】', '[bold magenta][red]' + info['mincost'], '【平均成绩】',
                  info['avgcost'])

    console.rule('[green]运行结果[/] ' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
    console.rule('[cyan]【CPU】[/cyan][yellow]' + info['cpu'] + ' (' + info['core'] +' 核心 '+ info['lcore']+' 线程 ' + info['clock']+' MHz)[/yellow]')
    console.print(table)
 def __init__(self, council_id, expecting_districts, csv_rows=None):
     self.council_id = council_id
     self.csv_rows = csv_rows
     self.report = Table.grid()
     # Whether the importer is expected to have imported districts;
     # controls whether relevant summaries appear in the report.
     self.expecting_districts = expecting_districts
Пример #24
0
    def rich_report(self):
        results = [task.report_table() for task in self.tasks]
        successes = [x[0] for x in results]

        if not self._is_secret() or any(successes):
            table = Table.grid(expand=True, padding=(0, 2))
            table.add_column()
            table.add_column()
            table.add_column(style='red', overflow='fold', ratio=1)
            for result, name, msg, print_if_failed in results:
                if not print_if_failed and not result:
                    continue
                emoji = ":green_heart:" if result else ":no_entry_sign:"
                name = f"[green]{name}" if result else f"[red]{name}"
                table.add_row(f"[{emoji}]", name, msg)
            if self.name == "":
                title = Text(self.__doc__, justify='center')
            else:
                title = Text(self.name, justify='center')
            success_num = successes.count(True)
            summary_line = Text(
                f"{success_num} Successful out of {len(results)}",
                justify='right')
            panel_text = RenderGroup(title, table, '', summary_line)
            border_style = "green" if all(successes) else "red"
            panel = Panel(panel_text,
                          highlight=True,
                          border_style=border_style,
                          width=100)
            print(panel)
        return successes
Пример #25
0
def print_issue(issue: jira.Issue) -> None:
    grid = Table.grid(expand=True)
    grid.add_column()
    grid.add_column()
    grid.add_row("", "")  # probably better way to add padding than this
    grid.add_row("[bold magenta]Key", issue.key)
    grid.add_row("[bold magenta]Summary", issue.fields.summary)
    grid.add_row("[bold magenta]URL", issue.permalink())
    grid.add_row("[bold magenta]Issue type", issue.fields.issuetype.name)
    grid.add_row("[bold magenta]Status", issue.fields.status.name)
    # import pdb

    # pdb.set_trace()
    # if issue.fields.issuetype.subtask is False:
    time_remaining = format_time(issue.fields.aggregatetimeestimate or 0)
    row_title = "Total time remaining"
    if issue.fields.issuetype.subtask is False:
        row_title += " (including subtasks)"
    grid.add_row(
        f"[bold magenta]{row_title}",
        time_remaining,
    )
    time_spent = format_time(issue.fields.aggregatetimespent or 0)
    row_title = "Total time spent"
    if issue.fields.issuetype.subtask is False:
        row_title += " (including subtasks)"
    grid.add_row(
        f"[bold magenta]{row_title}",
        time_spent,
    )
    grid.add_row("", "")  # probably better way to add padding than this
    print(grid)
Пример #26
0
    def get_top_layout() -> Panel:
        _memory: Tuple[str] = get_memory_info()
        _platform: str = get_platform()
        _pyversion: str = get_python_version()

        _total_memory: str = _memory[0]
        _available_memory: str = _memory[1]
        _used_percentage: str = _memory[2]
        _used_memory: str = _memory[3]
        _free_memory: str = _memory[4]

        table = Table.grid(expand=True)

        table.add_row("Total Memory: ",
                      Text(_total_memory, style="yellow", justify="right"))
        table.add_row("Available Memory: ",
                      Text(_available_memory, style="green", justify="right"))
        table.add_row("Used Memory: ",
                      Text(_used_memory, style="red", justify="right"))
        table.add_row("Free Memory: ",
                      Text(_free_memory, style="green", justify="right"))
        table.add_row("Used Percentage: ",
                      Text(_used_percentage, style="magenta", justify="right"))
        table.add_row("OS: ", Text(_platform, style="blue", justify="right"))
        table.add_row("Python Version: ",
                      Text(_pyversion, style="blue", justify="right"))
        return Panel(
            Align.center(table, vertical="middle", pad=False),
            title="System Info",
            border_style="white",
        )
Пример #27
0
    def print_table(self, print_modules: bool):
        """Prints table view of plugin information"""
        grid = Table.grid(expand=True)
        grid.add_column(style="blue")
        grid.add_column()
        grid.add_row("Key:", self.key)
        grid.add_row("Name:", self.name)
        grid.add_row("Version:", self.version)
        grid.add_row("enabled:", str(self.enabled))
        grid.add_row("userInstalled:", str(self.userInstalled))
        grid.add_row("Description:", self.description)

        modules = Table("", "Name", "Key", title="modules")
        for module in self.modules:
            if module.enabled:
                status = "[green]✓[reset]"
            else:
                status = "[yellow]![reset]"
            modules.add_row(status, module.name, module.key)

        console = Console()
        console.print(grid)
        if print_modules:
            console.print()
            console.print(modules)
Пример #28
0
def update_bt_status(st):
    panel = Table.grid(padding=0)
    for i in range(9):
        justify = "center" if i < 7 else "right"
        panel.add_column(ratio=1, min_width=9, justify=justify)
    panel.add_row("", "State", "Flags", "Error", "Services", "Features",
                  "Auth", "Tx", "Rx")
    es = ("[bold red]0x%04X" %
          (st.bt.error) if st.bt.error > 0 else "[green]0x%04X" %
          (st.bt.error))
    stx = "[orange1]%d" % (st.bt.tx_count)
    srx = "[green]%d" % (st.bt.rx_count)
    if st.status_latch1 & 0x40:
        stx = console.status(stx)
        srx = console.status(srx)

    panel.add_row(
        "[bold white]Bluetooth ",
        "[cyan]0x%02X" % (st.bt.state),
        "[cyan]0x%04X" % (st.bt.flags),
        es,
        "0x%04X" % (st.bt.services),
        "0x%04X" % (st.bt.features),
        "0x%04X" % (st.bt.auth),
        stx,
        srx,
    )
    return Panel(panel)
Пример #29
0
    def draw_error_table(self):
        lErrsTable = Table.grid(Column('error_tables'))

        if self.parser.errors:
            t = self.draw_parsing_errors()
            t.title = "Dep tree parsing error(s)"
            t.title_style = 'bold red'
            t.title_justify = 'left'
            lErrsTable.add_row(t)

        if self.parser.unresolved:
            if self.parser.unresolved_packages:
                t = self.draw_unresolved_packages()
                t.title = "[bold red]Unresolved packages[/bold red]"
                lErrsTable.add_row(t)
            # ------
            lCNF = self.parser.unresolved_components
            if lCNF:
                t = self.draw_unresolved_components()
                t.title = "[bold red]Unresolved components[/bold red]"
                lErrsTable.add_row(t)

        if self.parser.unresolved_files:
            t = self.draw_unresolved_files()
            t.title = "Unresolved files"
            t.title_style = 'bold red'
            t.title_justify = 'left'
            lErrsTable.add_row(t)

        return lErrsTable
Пример #30
0
def _get_nb_stratum_table(nb_status: NBMinerStatus) -> Table:  # noqa: WPS213
    """Get NBMiner overall status table.

    :param nb_status: current NBMiner status.
    :return: renderable table of general NBMiner status.
    """
    table = Table.grid()
    table.add_column(justify="left")
    table.add_column(justify="right")
    table.add_row(
        "NBMiner version: ",
        nb_status.version,
    )
    table.add_row("Reboots: ", str(nb_status.reboot_times))
    table.add_row("URL: ", nb_status.stratum.url)
    table.add_row(
        "User: "******"Latency: ",
        str(nb_status.stratum.latency),
    )
    table.add_row(
        "Accepts: ",
        str(nb_status.stratum.accepted_shares),
    )
    table.add_row(
        "Rejects: ",
        str(nb_status.stratum.rejected_shares),
    )
    table.add_row("HashRate 10m: ", str(nb_status.stratum.pool_hashrate_10m))
    table.add_row("HashRate 1h: ", str(nb_status.stratum.pool_hashrate_4h))
    table.add_row("HashRate 24h: ", str(nb_status.stratum.pool_hashrate_24h))
    return table