def format_output(title, cur, headers, status, table_format, expanded=False, max_width=None): output = [] if title: # Only print the title if it's not None. output.append(title) if cur: headers = [utf8tounicode(x) for x in headers] if expanded and headers: output.append(expanded_table(cur, headers)) else: tabulated, rows = tabulate(cur, headers, tablefmt=table_format, missingval='<null>') if (max_width and content_exceeds_width(rows[0], max_width) and headers): output.append(expanded_table(rows, headers)) else: output.append(tabulated) if status: # Only print the status if it's not None. output.append(status) return output
def format_output(title, cur, headers, status, settings): output = [] missingval = settings.missingval table_format = settings.table_format dcmlfmt = settings.dcmlfmt floatfmt = settings.floatfmt expanded = settings.expanded max_width = settings.max_width case_function = settings.case_function if title: # Only print the title if it's not None. output.append(title) if cur: headers = [case_function(utf8tounicode(x)) for x in headers] if expanded and headers: output.append(expanded_table(cur, headers, missingval)) else: tabulated, rows = tabulate(cur, headers, tablefmt=table_format, missingval=missingval, dcmlfmt=dcmlfmt, floatfmt=floatfmt) if (max_width and rows and content_exceeds_width(rows[0], max_width) and headers): output.append(expanded_table(rows, headers, missingval)) else: output.append(tabulated) if status: # Only print the status if it's not None. output.append(status) return output
def format_output(title, cur, headers, status, table_format, expanded=False, max_width=None): output = [] if title: # Only print the title if it's not None. output.append(title) if cur: headers = [utf8tounicode(x) for x in headers] if expanded and headers: output.append(expanded_table(cur, headers)) else: tabulated, rows = tabulate(cur, headers, tablefmt=table_format, missingval="<null>") if max_width and rows and content_exceeds_width(rows[0], max_width) and headers: output.append(expanded_table(rows, headers)) else: output.append(tabulated) if status: # Only print the status if it's not None. output.append(status) return output