/usr/lib/python3/dist-packages/ansi/colour/base.py is in python3-ansi 0.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #pylint: disable=C0103,R0903
from ansi.sequence import sequence
from ansi._compat import string_types
__all__ = ['Graphic']
class Graphic(object):
'''
Compose a Select Graphic Rendition (SGR) ANSI escape sequence.
'''
def __init__(self, *values):
self.values = values
self.sequence = sequence('m', fields=-1)(*values)
def __add__(self, their):
if isinstance(their, str):
return ''.join([str(self), their])
elif isinstance(their, string_types):
raise ValueError('Use str, nothing else.')
else:
return Graphic(*(self.values + their.values))
def __call__(self, text, reset=True):
result = self.sequence + text
if reset:
result += str(Graphic('0'))
return result
def __str__(self):
return self.sequence
|