MCPcopy Index your code
hub / github.com/google/python-fire / GetConsoleAttr

Function GetConsoleAttr

fire/console/console_attr.py:631–661  ·  view source on GitHub ↗

Gets the console attribute state. If this is the first call or reset is True or encoding is not None and does not match the current encoding or out is not None and does not match the current out then the state is (re)initialized. Otherwise the current state is returned. This call associa

(encoding=None, reset=False)

Source from the content-addressed store, hash-verified

629
630
631def GetConsoleAttr(encoding=None, reset=False):
632 """Gets the console attribute state.
633
634 If this is the first call or reset is True or encoding is not None and does
635 not match the current encoding or out is not None and does not match the
636 current out then the state is (re)initialized. Otherwise the current state
637 is returned.
638
639 This call associates the out file stream with the console. All console related
640 output should go to the same stream.
641
642 Args:
643 encoding: Encoding override.
644 ascii -- ASCII. This is the default.
645 utf8 -- UTF-8 unicode.
646 win -- Windows code page 437.
647 reset: Force re-initialization if True.
648
649 Returns:
650 The global ConsoleAttr state object.
651 """
652 attr = ConsoleAttr._CONSOLE_ATTR_STATE # pylint: disable=protected-access
653 if not reset:
654 if not attr:
655 reset = True
656 elif encoding and encoding != attr.GetEncoding():
657 reset = True
658 if reset:
659 attr = ConsoleAttr(encoding=encoding)
660 ConsoleAttr._CONSOLE_ATTR_STATE = attr # pylint: disable=protected-access
661 return attr
662
663
664def ResetConsoleAttr(encoding=None):

Callers 5

__init__Method · 0.85
ResetConsoleAttrFunction · 0.85
SafeTextFunction · 0.85
EncodeToBytesFunction · 0.85
DecodeFunction · 0.85

Calls 2

GetEncodingMethod · 0.95
ConsoleAttrClass · 0.85

Tested by

no test coverage detected