carputils
Doxygen code documentation for the python framework controlling openCARP
Classes | Functions
carputils.format Namespace Reference

Classes

class  Cell
 
class  Summary
 
class  Table
 

Functions

def terminal_width (fallback=70)
 Get the width of the terminal, in characters. More...
 
def hline (char='-', fallback=70)
 
def header (description, char='-', fallback=70)
 
def dot_pad (string, length)
 
def stringtable (strlist, ncolumns=4, padding=3, rowprefix='')
 
def linewrap (content, length)
 
def command_line (cmd, optionals=True, cols=None, prefix='')
 Nicely format a command line for output to terminal. More...
 

Function Documentation

◆ command_line()

def carputils.format.command_line (   cmd,
  optionals = True,
  cols = None,
  prefix = '' 
)

Nicely format a command line for output to terminal.

If joining the arguments with single spaces results in a string that will fit on one line, this is returned. Otherwise, a string containing the command line nicely displayed over many lines is returned.

Parameters

cmd list list of strings representing command line arguments optionals bool, optional If True (default), flags starting with '-' start new lines. If False, all arguments are on new lines. cols int, optional Specify the number of columns to fit inside, default: terminal width prefix str, optional A string to prefix each line of the formatted output

Returns

str The formatted command line

◆ dot_pad()

def carputils.format.dot_pad (   string,
  length 
)

◆ header()

def carputils.format.header (   description,
  char = '-',
  fallback = 70 
)

◆ hline()

def carputils.format.hline (   char = '-',
  fallback = 70 
)

◆ linewrap()

def carputils.format.linewrap (   content,
  length 
)

◆ stringtable()

def carputils.format.stringtable (   strlist,
  ncolumns = 4,
  padding = 3,
  rowprefix = '' 
)

◆ terminal_width()

def carputils.format.terminal_width (   fallback = 70)

Get the width of the terminal, in characters.

Parameters

fallback int The default width to use when the width cannot be determined (default: 100)

Returns

int The number of columns in the output