def show_table(table, item): if item.message: colorPrint._printSUCCESS(item.message) head = table.head.string if hasattr (table.head, 'string') else None data = [] for line in table.body[0]: if hasattr (line, 'string'): data.append(line.string) res = printTable(data, head) sys.stdout.write(res+"\n") sys.stdout.flush()
def print_brief_group(Fields, group_name): print_group_flag = False # if group_name: # _print ('\b'+group_name) uncompatible_count = 0 for field in Fields: if field.uncompatible: uncompatible_count += 1 continue if field.element in ['input', 'openfile']: value = field.value if field.value else '' if not print_group_flag: _print ('\b'+group_name) print_group_flag = True colorPrint._printSUCCESS('%s: %s' %(field.label, value)) elif field.element in ['combo', 'comboEdit', 'radio', 'file']: if hasattr (field.comments, 'string') and field.value in \ field.choice.string: value = map(lambda x: field.comments.string[x] \ if len(field.comments.string) > x \ else field.choice.string[x], map(lambda x: field.choice.string.index(x), \ [field.value])) value = ', '.join(value) else: value = field.value if field.value else '' if not print_group_flag: _print ('\b'+group_name) print_group_flag = True colorPrint._printSUCCESS('%s: %s' %(field.label, value)) elif field.element in ['multichoice', 'multichoice_add',\ 'selecttable', 'selecttable_add']: if hasattr (field.comments, 'string') and \ hasattr (field.listvalue, 'string'): value = map(lambda x: field.comments.string[x] \ if len(field.comments.string) > x \ else field.choice.string[x], map(lambda x: field.choice.string.index(x), \ field.listvalue.string)) value = ', '.join(value) elif hasattr (field.listvalue, 'string'): value = ', '.join(field.listvalue.string) else: value = field.value if field.value else '' if not print_group_flag: _print ('\b'+group_name) print_group_flag = True colorPrint._printSUCCESS('%s: %s' %(field.label, value)) # elif field.element == 'label': # print field.label elif field.element == 'error': if not print_group_flag: _print ('\b'+group_name) print_group_flag = True colorPrint.printERROR(field.label) elif field.element in ['check', 'check_tristate']: if field.value == 'on': value = _('yes') elif field.value == 'off': value = _('no') elif field.value == 'auto': value = _('auto') else: value = field.value if not print_group_flag: _print ('\b'+group_name) print_group_flag = True colorPrint._printSUCCESS('%s: %s' %(field.label, value)) elif field.element == 'table' and field.type != 'steps': if hasattr (field.tablevalue.head, 'string'): head = field.tablevalue.head.string else: head = None body = [] if hasattr (field.tablevalue.body, 'stringArray'): for row in field.tablevalue.body.stringArray: if hasattr(row, 'string'): body.append(row.string) else: body = [[]] # if empty table if not filter (None, map(lambda x: x, body)): body = [['']*len(head)] res = printTable(body, head) sys.stdout.flush() sys.stdout.write(res) continue ChoiceValue = field.tablevalue.values.ChoiceValue for row in xrange(len(ChoiceValue)): if ChoiceValue[row].typefield in ['check', 'check_tristate']: for i in xrange(len(body)): if body[i][row] == 'on': body[i][row] = _('yes') if body[i][row] == 'off': body[i][row] = _('no') if body[i][row] == 'auto': body[i][row] = _('auto') if ChoiceValue[row].typefield == 'password': for i in xrange(len(body)): if body[i][row]: body[i][row] = '***' data = [] for body_row in body: data.append(map(lambda x: x if x else '', body_row)) if not print_group_flag: _print ('\b'+group_name) print_group_flag = True colorPrint._printSUCCESS('%s: ' %(field.label)) res = printTable(data, head) sys.stdout.write(res+"\n") sys.stdout.flush() else: uncompatible_count += 1