| 4 | |
| 5 | |
| 6 | class SourceMappingEntry(object): |
| 7 | __slots__ = ["source_filename", "line", "end_line", "runtime_line", "runtime_source"] |
| 8 | |
| 9 | def __init__(self, line, end_line, runtime_line, runtime_source): |
| 10 | assert isinstance(runtime_source, str) |
| 11 | |
| 12 | self.line = int(line) |
| 13 | self.end_line = int(end_line) |
| 14 | self.runtime_line = int(runtime_line) |
| 15 | self.runtime_source = runtime_source # Something as <ipython-cell-xxx> |
| 16 | |
| 17 | # Should be set after translated to server (absolute_source_filename). |
| 18 | # This is what's sent to the client afterwards (so, its case should not be normalized). |
| 19 | self.source_filename = None |
| 20 | |
| 21 | def contains_line(self, i): |
| 22 | return self.line <= i <= self.end_line |
| 23 | |
| 24 | def contains_runtime_line(self, i): |
| 25 | line_count = self.end_line + self.line |
| 26 | runtime_end_line = self.runtime_line + line_count |
| 27 | return self.runtime_line <= i <= runtime_end_line |
| 28 | |
| 29 | def __str__(self): |
| 30 | return "SourceMappingEntry(%s)" % (", ".join("%s=%r" % (attr, getattr(self, attr)) for attr in self.__slots__)) |
| 31 | |
| 32 | __repr__ = __str__ |
| 33 | |
| 34 | |
| 35 | class SourceMapping(object): |
no outgoing calls