MCPcopy Index your code
hub / github.com/python/cpython / _read_terminfo_file

Function _read_terminfo_file

Lib/_pyrepl/terminfo.py:133–154  ·  view source on GitHub ↗

Find and read terminfo file for given terminal name. Terminfo files are stored in directories using the first character of the terminal name as a subdirectory.

(terminal_name: str)

Source from the content-addressed store, hash-verified

131
132
133def _read_terminfo_file(terminal_name: str) -> bytes:
134 """Find and read terminfo file for given terminal name.
135
136 Terminfo files are stored in directories using the first character
137 of the terminal name as a subdirectory.
138 """
139 _validate_terminal_name_or_raise(terminal_name)
140 first_char = terminal_name[0].lower()
141 filename = terminal_name
142
143 for directory in _get_terminfo_dirs():
144 path = directory / first_char / filename
145 if path.is_file():
146 return path.read_bytes()
147
148 # Try with hex encoding of first char (for special chars)
149 hex_dir = "%02x" % ord(first_char)
150 path = directory / hex_dir / filename
151 if path.is_file():
152 return path.read_bytes()
153
154 raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename)
155
156
157# Hard-coded terminal capabilities for common terminals

Callers 1

_parse_terminfo_fileMethod · 0.85

Calls 5

_get_terminfo_dirsFunction · 0.85
lowerMethod · 0.45
is_fileMethod · 0.45
read_bytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…