MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_theme

Function get_theme

Lib/_colorize.py:322–343  ·  view source on GitHub ↗

Returns the currently set theme, potentially in a zero-color variant. In cases where colorizing is not possible (see `can_colorize`), the returned theme contains all empty strings in all color definitions. See `Theme.no_colors()` for more information. It is recommended not to cache

(
    *,
    tty_file: IO[str] | IO[bytes] | None = None,
    force_color: bool = False,
    force_no_color: bool = False,
)

Source from the content-addressed store, hash-verified

320
321
322def get_theme(
323 *,
324 tty_file: IO[str] | IO[bytes] | None = None,
325 force_color: bool = False,
326 force_no_color: bool = False,
327) -> Theme:
328 """Returns the currently set theme, potentially in a zero-color variant.
329
330 In cases where colorizing is not possible (see `can_colorize`), the returned
331 theme contains all empty strings in all color definitions.
332 See `Theme.no_colors()` for more information.
333
334 It is recommended not to cache the result of this function for extended
335 periods of time because the user might influence theme selection by
336 the interactive shell, a debugger, or application-specific code. The
337 environment (including environment variable state and console configuration
338 on Windows) can also change in the course of the application life cycle.
339 """
340 if force_color or (not force_no_color and
341 can_colorize(file=tty_file)):
342 return _theme
343 return theme_no_color
344
345
346def set_theme(t: Theme) -> None:

Callers 6

_set_colorMethod · 0.90
runMethod · 0.90
__init__Method · 0.90
runMethod · 0.90
test_colorsMethod · 0.90
mainFunction · 0.90

Calls 1

can_colorizeFunction · 0.85

Tested by 1

test_colorsMethod · 0.72