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

Function _get_terminfo_dirs

Lib/_pyrepl/terminfo.py:76–115  ·  view source on GitHub ↗

Get list of directories to search for terminfo files. Based on ncurses behavior in: - ncurses/tinfo/db_iterator.c:_nc_next_db() - ncurses/tinfo/read_entry.c:_nc_read_entry()

()

Source from the content-addressed store, hash-verified

74
75
76def _get_terminfo_dirs() -> list[Path]:
77 """Get list of directories to search for terminfo files.
78
79 Based on ncurses behavior in:
80 - ncurses/tinfo/db_iterator.c:_nc_next_db()
81 - ncurses/tinfo/read_entry.c:_nc_read_entry()
82 """
83 dirs = []
84
85 terminfo = os.environ.get("TERMINFO")
86 if terminfo:
87 dirs.append(terminfo)
88
89 try:
90 home = Path.home()
91 dirs.append(str(home / ".terminfo"))
92 except RuntimeError:
93 pass
94
95 # Check TERMINFO_DIRS
96 terminfo_dirs = os.environ.get("TERMINFO_DIRS", "")
97 if terminfo_dirs:
98 for d in terminfo_dirs.split(":"):
99 if d:
100 dirs.append(d)
101
102 dirs.extend(
103 [
104 "/etc/terminfo",
105 "/lib/terminfo",
106 "/usr/lib/terminfo",
107 "/usr/share/terminfo",
108 "/usr/share/lib/terminfo",
109 "/usr/share/misc/terminfo",
110 "/usr/local/lib/terminfo",
111 "/usr/local/share/terminfo",
112 ]
113 )
114
115 return [Path(d) for d in dirs if Path(d).is_dir()]
116
117
118def _validate_terminal_name_or_raise(terminal_name: str) -> None:

Callers 1

_read_terminfo_fileFunction · 0.85

Calls 8

PathClass · 0.90
strFunction · 0.85
getMethod · 0.45
appendMethod · 0.45
homeMethod · 0.45
splitMethod · 0.45
extendMethod · 0.45
is_dirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…