Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)