PrettyPrint

Utilities for pretty printing table data and more Author: A.Tsaregorodtsev

DIRAC.Core.Utilities.PrettyPrint.int_with_commas(inputValue)
Utility to make a string of a large integer with comma separated degrees

of thousand

Parameters:

inputValue (int) – value to be interpreted

Returns:

output string

DIRAC.Core.Utilities.PrettyPrint.printDict(dDict, printOut=False)

Utility to pretty print a dictionary

Parameters:
  • dDict (dict) – Dictionary to be printed out

  • printOut (bool) – flag to print to the stdout

Returns:

pretty dictionary string

DIRAC.Core.Utilities.PrettyPrint.printTable(fields, records, sortField='', numbering=True, printOut=True, columnSeparator=' ')

Utility to pretty print tabular data

Parameters:
  • fields (list) – list of column names

  • records (list) – list of records, each record is a list or tuple of field values where field value itself can be a string or a list of strings or a dictionary of the structure { “Value”: string_value, ‘Just’: ‘L|R|C’ } to specify justification

  • sortField (str) – name of the column by which the output will be sorted

  • numbering (bool) – flag for numbering rows

  • printOut (bool) – flag for printing into the stdout

  • columnSeparator (str) – string to be used as a column separator

Returns:

pretty table string