1.1.4.1.3. test_automation.utils.logfiltering

Module to remove all extra and unnecessary characters from log files.

1.1.4.1.3.1. Attributes

ANSI_ESCAPE

ORPHAN_CSI

CONTROL_CHARS

_CLEANER

1.1.4.1.3.2. Classes

AnsiStrippingStream

A wrapper that strips ANSI/control sequences before writing.

1.1.4.1.3.3. Functions

strip_ansi_and_controls(text)

Removes ANSI escape codes, orphan CSI sequences, and stray control

1.1.4.1.3.4. Module Contents

test_automation.utils.logfiltering.ANSI_ESCAPE[source]
test_automation.utils.logfiltering.ORPHAN_CSI[source]
test_automation.utils.logfiltering.CONTROL_CHARS[source]
test_automation.utils.logfiltering._CLEANER[source]
test_automation.utils.logfiltering.strip_ansi_and_controls(text)[source]

Removes ANSI escape codes, orphan CSI sequences, and stray control characters.

Parameters:

text (str) – Raw string to clean.

Returns:

Cleaned string without ANSI/control sequences.

Return type:

str

class test_automation.utils.logfiltering.AnsiStrippingStream(underlying)[source]

A wrapper that strips ANSI/control sequences before writing.

This is typically used to wrap a file handle so that all log writes are cleaned of terminal formatting characters automatically.

Parameters:

underlying (TextIO)

_stream[source]
write(data)[source]

Strip ANSI/control sequences from data and write to the underlying stream.

Parameters:

data (str) – Raw string data to sanitize and write.

Returns:

Number of characters written.

Return type:

int

flush()[source]

Flush the underlying stream.

Return type:

None