Beispiel #1
0
    def input_table_to_string(self):
        count = len(self.table)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 400
            table.column_headers = [
                " alfa ", "  transition label ", "  beta  ", " Stack ",
                "Semantic subroutine"
            ]
            for i in range(0, count):
                semantic_subroutine = self.table[i].semantic_subroutine
                semantic_str = ''
                if semantic_subroutine.get('error'):
                    semantic_str += "[≠] error"
                else:
                    if semantic_subroutine.get('exit'):
                        semantic_str += "[≠] exit"
                    if semantic_subroutine.get('beta'):
                        semantic_str += "[≠] beta = {beta} ".format(
                            beta=semantic_subroutine.get('beta'))
                        if semantic_subroutine.get('stack'):
                            semantic_str += "stack ↓ {stack}".format(
                                stack=semantic_subroutine.get('stack'))
                table.append_row([
                    self.table[i].alfa,
                    to_str(self.table[i].transition_label),
                    to_str(self.table[i].beta),
                    to_str(self.table[i].stack), semantic_str
                ])

            return str(table)
        return ''
Beispiel #2
0
def display_result(headers, data):
    from beautifultable import BeautifulTable
    table = BeautifulTable()
    table._max_table_width = 100
    table.column_headers = headers
    for row in data:
        table.append_row(row)
    print(table)
Beispiel #3
0
    def show_label_table(self):
        count = len(self.label_table)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 100
            table.column_headers = ["    name     ", "        value         "]
            for i in range(0, count):
                table.append_row(
                    [self.label_table[i].name, self.label_table[i].value])
            return str(table)

        return ''
Beispiel #4
0
    def get_parse_table(self):
        count = len(self.parse_table)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 400
            table.column_headers = ["        Configuration            ", "  Current state  ", "Lexem", " Goto ",
                                    "        Stack         "]
            for i in range(0, count):
                table.append_row([self.parse_table[i].number_of_configuration,
                                  self.parse_table[i].current_state,
                                  self.parse_table[i].lexem,
                                  self.parse_table[i].state,
                                  self.parse_table[i].stack])
            return str(table)

        return ''
Beispiel #5
0
    def show_plz_table(self):
        count = len(self.plz_table)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 200
            table.column_headers = [
                "    input     ", "        stack         ",
                "             output             "
            ]
            for i in range(0, count):
                table.append_row([
                    self.plz_table[i].input, self.plz_table[i].stack,
                    self.plz_table[i].output
                ])
            return str(table)

        return ''
Beispiel #6
0
    def get_parse_table(self):
        count = len(self.parse_table)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 200
            table.column_headers = [
                "     №     ", "        Stack         ", "     Relation    ",
                "         Input row           "
            ]
            for i in range(0, count):
                table.append_row([
                    self.parse_table[i].number, self.parse_table[i].stack,
                    self.parse_table[i].relation, self.parse_table[i].input_row
                ])
            return str(table)

        return ''
Beispiel #7
0
    def table_lexes_to_string(collection_records_label) -> str:
        count = len(collection_records_label)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 400
            table.column_headers = [
                "                Label code                 ",
                "                Label name               "
            ]
            for i in range(0, count):
                table.append_row([
                    collection_records_label[i].code,
                    collection_records_label[i].name
                ])

            return str(table)
        return ''
Beispiel #8
0
    def table_lexes_to_string(collection_records_con) -> str:
        print('tyt')
        count = len(collection_records_con)
        print(count)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 400
            table.column_headers = [
                "       Constant code        ", "       Constant name      ",
                "        Constant type        "
            ]
            for i in range(0, count):
                table.append_row([
                    collection_records_con[i].code,
                    collection_records_con[i].name,
                    collection_records_con[i].type
                ])

            return str(table)
        return ' '
Beispiel #9
0
    def table_lexes_to_string(collection_records_lexem) -> str:
        count = len(collection_records_lexem)
        if count > 0:
            table = BeautifulTable()
            table._max_table_width = 400
            table.column_headers = [
                "   №   ", "line number", "lexem", "code lexem",
                "code identifier", "code сonstant", "code label"
            ]
            for i in range(0, count):
                table.append_row([
                    collection_records_lexem[i].serial_number,
                    collection_records_lexem[i].line_number,
                    collection_records_lexem[i].lexem,
                    collection_records_lexem[i].code_lexem,
                    collection_records_lexem[i].code_idn,
                    collection_records_lexem[i].code_con,
                    collection_records_lexem[i].code_label
                ])

            return str(table)
        return ''
def ShowTable(list):
    table = BeautifulTable()
    table._max_table_width = 500
    table.column_headers = [
        'Name', 'Team', 'Match', 'Wins', 'Draw', 'Losses', 'Goals +',
        'Goals -', 'Goals +/-', 'Points'
    ]
    for player in list:
        table.append_row([
            player.getName(),
            player.getTeam(),
            player.getMatchNumbers(),
            player.getMatchNumbersWin(),
            player.getMatchNumbersDraw(),
            player.getMatchNumberLoss(),
            player.getMatchGoalsPlus(),
            player.getMatchGoalsMinus(),
            player.getMatchGoalsDiff(),
            player.getPlayerPoints()
        ])
    table.sort('Goals +/-')
    table.sort('Points')
    table.reverse()
    print(table)