Skip to content

Commit

Permalink
replace pkg_resources with importlib.resources
Browse files Browse the repository at this point in the history
  • Loading branch information
blingenf committed Mar 9, 2024
1 parent 59c1aa5 commit 3c49ceb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Empty file added copydetect/data/__init__.py
Empty file.
8 changes: 5 additions & 3 deletions copydetect/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time
import logging
import webbrowser
import pkg_resources
import importlib.resources
import io
import base64
import json
Expand All @@ -17,6 +17,7 @@
import matplotlib.pyplot as plt
from jinja2 import Template

import copydetect.data as data_files
from .utils import (filter_code, highlight_overlap, get_copied_slices,
get_document_fingerprints, find_fingerprint_overlap,
get_token_coverage)
Expand Down Expand Up @@ -541,7 +542,6 @@ def generate_html_report(self, output_mode="save"):
return

code_list = self.get_copied_code_list()
data_dir = pkg_resources.resource_filename('copydetect', 'data/')

plot_mtx = np.copy(self.similarity_matrix[:,:,0])
plot_mtx[plot_mtx == -1] = np.nan
Expand All @@ -564,7 +564,9 @@ def generate_html_report(self, output_mode="save"):
plt.close()

# render template with jinja and save as html
with open(data_dir + "report.html", encoding="utf-8") as template_fp:
with importlib.resources.open_text(
data_files, "report.html", encoding="utf-8"
) as template_fp:
template = Template(template_fp.read())

flagged = self.similarity_matrix[:,:,0] > self.conf.display_t
Expand Down

0 comments on commit 3c49ceb

Please sign in to comment.