link result view and source view

This commit is contained in:
2021-11-05 19:18:24 +01:00
parent e04c4a2ab7
commit f209156eea
8 changed files with 151 additions and 54 deletions

22
linetolinemap.py Normal file
View File

@@ -0,0 +1,22 @@
import os
import tempfile
from typing import Optional
from int2intmap import Int2IntMap
class LineToLineMap:
def __init__(self):
(handle, self.tmpfilename) = tempfile.mkstemp()
os.close(handle)
self._int2intmap = Int2IntMap(self.tmpfilename)
def close(self):
self._int2intmap.close()
os.remove(self.tmpfilename)
def add_line(self, key_byte_start: int, value_byte_start):
self._int2intmap.add(key_byte_start, value_byte_start)
def get_line(self, key_byte_start: int) -> Optional[int]:
return self._int2intmap.find(key_byte_start)