woob.tools.application.formatters.iformatter

class IFormatter(display_keys=True, display_header=True, outfile=None)[source]

Bases: object

MANDATORY_FIELDS = None
DISPLAYED_FIELDS = None
BOLD = '\x1b[1m'
NC = '\x1b[0m'
colored(string, color, attrs=None, on_color=None)[source]
output(formatted)[source]
start_format(**kwargs)[source]
flush()[source]
format(obj, selected_fields=None, alias=None)[source]

Format an object to be human-readable. An object has fields which can be selected.

Parameters:
  • obj (BaseObject or dict) – object to format

  • selected_fields (tuple) – fields to display. If None, all fields are selected (default: None)

  • alias (str) – an alias to use instead of the object’s ID (default: None)

format_obj(obj, alias=None)[source]

Format an object to be human-readable. Called by format(). This method has to be overridden in child classes.

Parameters:

obj (BaseObject) – object to format

Return type:

str

format_dict(obj)[source]

Format a dict to be human-readable.

Parameters:

obj (dict) – dict to format

Return type:

str

format_collection(collection, only)[source]

Format a collection to be human-readable.

Parameters:

collection (BaseCollection) – collection to format

Return type:

str

exception MandatoryFieldsNotFound(missing_fields)[source]

Bases: Exception