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

208: Replace pkg_resourse with importlib #212

Merged
merged 1 commit into from
Sep 9, 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
2 changes: 1 addition & 1 deletion invideoquiz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""
from .invideoquiz import InVideoQuizXBlock

__version__ = '1.6.0'
__version__ = '1.6.1'
12 changes: 7 additions & 5 deletions invideoquiz/invideoquiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,37 @@
import json
import os

import pkg_resources

from xblock.core import XBlock
from xblock.fields import Scope
from xblock.fields import String
from xblock.validation import ValidationMessage

try:
from web_fragments.fragment import Fragment
except ImportError:
# For backward compatibility with quince and earlier.
from xblock.fragment import Fragment
from xblock.validation import ValidationMessage

try:
from xblock.utils.studio_editable import StudioEditableXBlockMixin
from xblock.utils.resources import ResourceLoader
except ModuleNotFoundError:
# For backward compatibility with releases older than Quince.
from xblockutils.studio_editable import StudioEditableXBlockMixin
from xblockutils.resources import ResourceLoader


from .utils import _

resource_loader = ResourceLoader(__name__)


def get_resource_string(path):
"""
Retrieve string contents for the file path
"""
path = os.path.join('public', path)
resource_string = pkg_resources.resource_string(__name__, path)
return resource_string.decode('utf8')
return resource_loader.load_unicode(path)


class InVideoQuizXBlock(StudioEditableXBlockMixin, XBlock):
Expand Down