Example #1
0
 def show_options(self, current_module):
     tb = PrettyTable()
     tb.set_style(PLAIN_COLUMNS)
     print(f'\nModule options ({current_module}):\n')
     tb.field_names = ['Name', 'Current Setting', 'Required', 'Description']
     tb.add_row(['----', '---------------', '--------', '-----------'])
     for key in sorted(self.option.keys()):
         tb.add_row([
             key,
             self.get_options(key), self.option[key]['Required'],
             self.option[key]['Description']
         ])
     # print('Name\t\tCurrent Setting                                       \t\t\tRequired\t\tDescription')
     # print('----\t\t---------------                                       \t\t\t--------\t\t-----------')
     # for key in sorted(self.option.keys()):
     #     print('{0:<4}\t\t{1:<55}\t\t\t{2:<8}\t\t{3:<11}'.format(key, self.get_options(key), self.option[key]["Required"], self.option[key]["Description"]))
     # #
     # Name = 4
     # C_Set = 15
     # Required = 8
     # Description = 11
     # for key in sorted(self.option.keys()):
     # print('%s%s\n' % ((key if len(key) == Name else key + ' ' * (len(key) -4)), (self.get_options(key) if len(self.get_options(key)) == C_Set else self.get_options(key) + ' ' * (15 - len(self.get_options(key))))))
     # print('%s' % (self.get_options(key) if len(self.get_options(key)) == C_Set else self.get_options(key) + ' ' * (15 - len(self.get_options(key)))))
     tb.align = 'l'
     print(tb)
     print('\n')
def list_style(items):
    print('\n')
    tb = PrettyTable()
    tb.set_style(PLAIN_COLUMNS)
    tb.field_names = ['Name', 'Module', 'Description']
    tb.add_row(['----', '------', '-----------'])
    for i in items:
        _ = list(i)
        # print(_)
        tb.add_row(_)

    tb.align = 'l'
    print(tb)
    print('\n')
def search_style(result):
    tb = PrettyTable()
    tb.set_style(PLAIN_COLUMNS)
    tb.field_names = ['Name', 'Module']
    tb.add_row(['----', '------'])
    if result:
        for i in result:
            if type(i) == tuple:
                tb.add_row([i[0], i[1]])
            elif type(i) == list:
                tb.add_row([i[0][0], i[0][1]])

        tb.align = 'l'
        print(tb)
    else:
        return None