materials_commons.cli.print_formatter module

class materials_commons.cli.print_formatter.PrintFormatter(fmt, sep=' ', end='\n', truncate=True)[source]

Bases: object

Print dict-like records, nicely

tabulate works nicely when you have all the records ahead of time, PrintFormatter lets you print without having all the records ahead of time.

Parameters

fmt

List of tuples Specify how to format records via: (key, header, alignment, size, function)

key: str, key being described header: str, header string alignment: str, string.format alignment option size: int, column size function: function, function that acts on record[key], or None if key is not in record, to determine what is printed.

print(record)[source]
print_detail(title_key, record)[source]
print_header()[source]
materials_commons.cli.print_formatter.trunc(s, size=40)[source]