|
61 | 61 | import saneyaml
|
62 | 62 | import xlsxwriter
|
63 | 63 | from django_filters.views import FilterView
|
64 |
| -from packageurl.contrib.django.models import PACKAGE_URL_FIELDS |
65 | 64 | from licensedcode.spans import Span
|
66 |
| -from matchcode_toolkit.fingerprinting import get_line_by_pos |
| 65 | +from packageurl.contrib.django.models import PACKAGE_URL_FIELDS |
67 | 66 |
|
68 | 67 | from scancodeio.auth import ConditionalLoginRequired
|
69 | 68 | from scancodeio.auth import conditional_login_required
|
@@ -1937,24 +1936,21 @@ def get_context_data(self, **kwargs):
|
1937 | 1936 | matched_snippet_annotations = []
|
1938 | 1937 | matched_snippets = resource.extra_data.get("matched_snippets")
|
1939 | 1938 | if matched_snippets:
|
1940 |
| - # tokenize file content and map tokens to line numbers |
1941 |
| - line_by_pos = get_line_by_pos(resource.file_content) |
1942 |
| - last_pos = max(line_by_pos, key=line_by_pos.get) |
| 1939 | + line_by_pos = resource.extra_data.get("line_by_pos") |
1943 | 1940 | for matched_snippet in matched_snippets:
|
1944 | 1941 | qspan = Span(matched_snippet["qspan"])
|
1945 |
| - matched_snippet_annotations.append |
1946 | 1942 | matched_snippet["qspan"] = qspan
|
1947 | 1943 | for span in qspan.subspans():
|
1948 |
| - # Convert qstart and qends to start_line and end_lines |
1949 |
| - end = min(span.end, last_pos) |
| 1944 | + # line_by_pos is stored as JSON and keys in JSON are always |
| 1945 | + # strings |
1950 | 1946 | matched_snippet_annotations.append(
|
1951 | 1947 | {
|
1952 |
| - "start_line": line_by_pos[span.start], |
1953 |
| - "end_line": line_by_pos[end], |
| 1948 | + "start_line": line_by_pos[str(span.start)], |
| 1949 | + "end_line": line_by_pos[str(span.end)], |
1954 | 1950 | }
|
1955 | 1951 | )
|
1956 |
| - |
1957 | 1952 | context["detected_values"]["matched_snippets"] = matched_snippet_annotations
|
| 1953 | + |
1958 | 1954 | return context
|
1959 | 1955 |
|
1960 | 1956 |
|
|
0 commit comments