Skip to content

Commit

Permalink
Merge pull request #212 from edly-io/maq/upgrade-pkg_resource
Browse files Browse the repository at this point in the history
208: Replace pkg_resourse with importlib
  • Loading branch information
farhan authored Sep 9, 2024
2 parents 0f33079 + 127268e commit 7ab1f97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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

0 comments on commit 7ab1f97

Please sign in to comment.