Muscat.Helpers.PrintBypass module

Send all the print statements to a file or to the sink os … Also the output can be duplicated to a file

CheckIntegrity(GUI: bool = False)[source]
class PrintBypass[source]

Bases: object

Class to be used with a “with” statement to locally redirect the output (print statements) to other targets (files, sink…)

CopyOutputToDisk(filename: str, filenameCerr: str | None = None, filterString: str = ' -> ')[source]

Copy all the output to a file. a file with the name filename+”2” is created with all the statement filtered by the string in filterString

Parameters:
  • filename (str) – File name for the standard output

  • filenameCerr (str, optional) – File name fo the error output if non filename is used, by default None

  • filterString (str, optional) – String to filter the standard output to the second file, if empty the second file is not created

Print(text: str) None[source]

To print to the original cout

Parameters:

text (str) – message to be printed

PrintCerr(text) None[source]

To print to the original cerr

Parameters:

text (str) – message to be printed

Restore() None[source]

Restore the original output buffers. Current buffers will be flushed and closed before restoring the original

ToDisk(filename: str, filenameCerr: str | None = None) None[source]

Redirect all the outputs to file

Parameters:
  • filename (str) – File name for the standard output

  • filenameCerr (str, optional) – File name fo the error output if non filename is used, by default None

ToRedirect(coutObj, cerrObj=None) None[source]
Function to redirect all the outputs to a user definer function

if cerrObj is None coutObj will be used instead

Parameters:
  • coutObj – User object implementing close(), flush(), write(data)

  • cerrObj (, optional) – User object implementing close(), flush(), write(data)

ToSink() None[source]

Redirect all the outputs to the sink os.devnull

StdErrorPrint(*args, **kwargs) None[source]

Function to print to the standard error