Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pkg resources #58

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions feedback/extensions/filters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Open edX Filters needed for instructor dashboard integration.
"""
import pkg_resources
import importlib.resources
from crum import get_current_request
from django.conf import settings
from django.template import Context, Template
Expand Down Expand Up @@ -75,8 +75,7 @@ def run_filter(

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


def load_blocks(request, course):
Expand Down
11 changes: 6 additions & 5 deletions feedback/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

import html
import random
import pkg_resources
import six

import importlib.resources
import six
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Scope, Integer, String, List, Float, Boolean
from web_fragments.fragment import Fragment

from feedback.utils import _

try:
from xblock.utils.resources import ResourceLoader
except ModuleNotFoundError: # For backward compatibility with releases older than Quince.
Expand Down Expand Up @@ -133,8 +135,7 @@ class FeedbackXBlock(XBlock):
@classmethod
def resource_string(cls, path):
"""Handy helper for getting resources from our kit."""
data = pkg_resources.resource_string(__name__, path)
return data.decode("utf8")
return importlib.resources.files(__package__).joinpath(path).read_text(encoding="utf-8")

def get_prompt(self, index=-1):
"""
Expand Down
Loading