def _marking_enabled(self, markers, highlighter): options = {'AUTO': isatty(highlighter.stream), 'ON': True, 'OFF': False} try: return options[markers.upper()] except KeyError: raise DataError("Invalid console marker value '%s'. Available " "'AUTO', 'ON' and 'OFF'." % markers)
def _get_highlighter(self, stream, colors): options = {'AUTO': Highlighter if isatty(stream) else NoHighlighting, 'ON': Highlighter, 'OFF': NoHighlighting, 'ANSI': AnsiHighlighter} try: highlighter = options[colors.upper()] except KeyError: raise DataError("Invalid console color value '%s'. Available " "'AUTO', 'ON', 'OFF' and 'ANSI'." % colors) return highlighter(stream)
def _marking_enabled(self, markers, highlighter): options = { 'AUTO': isatty(highlighter.stream), 'ON': True, 'OFF': False } try: return options[markers.upper()] except KeyError: raise DataError("Invalid console marker value '%s'. Available " "'AUTO', 'ON' and 'OFF'." % markers)
def _get_highlighter(self, stream, colors): options = { 'AUTO': Highlighter if isatty(stream) else NoHighlighting, 'ON': Highlighter, 'OFF': NoHighlighting, 'ANSI': AnsiHighlighter } try: highlighter = options[colors.upper()] except KeyError: raise DataError("Invalid console color value '%s'. Available " "'AUTO', 'ON', 'OFF' and 'ANSI'." % colors) return highlighter(stream)