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()
()
| 74 | |
| 75 | |
| 76 | def _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 | |
| 118 | def _validate_terminal_name_or_raise(terminal_name: str) -> None: |
no test coverage detected
searching dependent graphs…