Skip to content

Commit 0e65692

Browse files
committed
chore: Transition from pkg_resources API to importlib-resources API
1 parent fc2fc88 commit 0e65692

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

feedback/extensions/filters.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Open edX Filters needed for instructor dashboard integration.
33
"""
4-
import pkg_resources
4+
import importlib.resources
55
from crum import get_current_request
66
from django.conf import settings
77
from django.template import Context, Template
@@ -75,8 +75,7 @@ def run_filter(
7575

7676
def resource_string(self, path):
7777
"""Handy helper for getting resources from our kit."""
78-
data = pkg_resources.resource_string("feedback", path)
79-
return data.decode("utf8")
78+
return importlib.resources.files("feedback").joinpath(path).read_text(encoding="utf-8")
8079

8180

8281
def load_blocks(request, course):

feedback/feedback.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
import html
1010
import random
11-
import pkg_resources
12-
import six
1311

12+
import importlib.resources
13+
import six
14+
from web_fragments.fragment import Fragment
1415
from xblock.core import XBlock
1516
from xblock.fields import Scope, Integer, String, List, Float, Boolean
16-
from web_fragments.fragment import Fragment
17+
1718
from feedback.utils import _
19+
1820
try:
1921
from xblock.utils.resources import ResourceLoader
2022
except ModuleNotFoundError: # For backward compatibility with releases older than Quince.
@@ -133,8 +135,7 @@ class FeedbackXBlock(XBlock):
133135
@classmethod
134136
def resource_string(cls, path):
135137
"""Handy helper for getting resources from our kit."""
136-
data = pkg_resources.resource_string(__name__, path)
137-
return data.decode("utf8")
138+
return importlib.resources.files(__package__).joinpath(path).read_text(encoding="utf-8")
138139

139140
def get_prompt(self, index=-1):
140141
"""

0 commit comments

Comments
 (0)