| 1099 | # returns the same object. |
| 1100 | @lru_cache |
| 1101 | def __new__(cls, filename): |
| 1102 | self = object.__new__(cls) |
| 1103 | self._filename = os.fsdecode(filename) |
| 1104 | # Some TeX distributions have enormous pdftex.map files which would |
| 1105 | # take hundreds of milliseconds to parse, but it is easy enough to just |
| 1106 | # store the unparsed lines (keyed by the first word, which is the |
| 1107 | # texname) and parse them on-demand. |
| 1108 | with open(filename, 'rb') as file: |
| 1109 | self._unparsed = {} |
| 1110 | for line in file: |
| 1111 | tfmname = line.split(b' ', 1)[0] |
| 1112 | self._unparsed.setdefault(tfmname, []).append(line) |
| 1113 | self._parsed = {} |
| 1114 | return self |
| 1115 | |
| 1116 | def __getitem__(self, texname): |
| 1117 | assert isinstance(texname, bytes) |