Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.rich.ansi Namespace Reference

Data Structures

class  _AnsiToken
 
class  AnsiDecoder
 

Functions

Iterable[_AnsiToken_ansi_tokenize (str ansi_text)
 
bytes read (int fd)
 

Variables

 re_ansi
 
dict SGR_STYLE_MAP
 
 decoder = AnsiDecoder()
 
 stdout = io.BytesIO()
 
 console = Console(record=True)
 
 stdout_result = stdout.getvalue().decode("utf-8")
 

Function Documentation

◆ _ansi_tokenize()

Iterable[_AnsiToken] _ansi_tokenize ( str  ansi_text)
protected
Tokenize a string in to plain text and ANSI codes.

Args:
    ansi_text (str): A String containing ANSI codes.

Yields:
    AnsiToken: A named tuple of (plain, sgr, osc)

Definition at line 27 of file ansi.py.

27def _ansi_tokenize(ansi_text: str) -> Iterable[_AnsiToken]:
28 """Tokenize a string in to plain text and ANSI codes.
29
30 Args:
31 ansi_text (str): A String containing ANSI codes.
32
33 Yields:
34 AnsiToken: A named tuple of (plain, sgr, osc)
35 """
36
37 position = 0
38 sgr: Optional[str]
39 osc: Optional[str]
40 for match in re_ansi.finditer(ansi_text):
41 start, end = match.span(0)
42 osc, sgr = match.groups()
43 if start > position:
44 yield _AnsiToken(ansi_text[position:start])
45 if sgr:
46 if sgr == "(":
47 position = end + 1
48 continue
49 if sgr.endswith("m"):
50 yield _AnsiToken("", sgr[1:-1], osc)
51 else:
52 yield _AnsiToken("", sgr, osc)
53 position = end
54 if position < len(ansi_text):
55 yield _AnsiToken(ansi_text[position:])
56
57
for i

References i.

Referenced by AnsiDecoder.decode_line().

Here is the caller graph for this function:

◆ read()

bytes read ( int  fd)

Definition at line 223 of file ansi.py.

223 def read(fd: int) -> bytes:
224 data = os.read(fd, 1024)
225 stdout.write(data)
226 return data
227

References i.

Variable Documentation

◆ console

console = Console(record=True)

Definition at line 232 of file ansi.py.

◆ decoder

decoder = AnsiDecoder()

Definition at line 219 of file ansi.py.

◆ re_ansi

re_ansi
Initial value:
2 ,
4)

Definition at line 10 of file ansi.py.

◆ SGR_STYLE_MAP

dict SGR_STYLE_MAP

Definition at line 58 of file ansi.py.

◆ stdout

stdout = io.BytesIO()

Definition at line 221 of file ansi.py.

◆ stdout_result

stdout_result = stdout.getvalue().decode("utf-8")

Definition at line 234 of file ansi.py.