Skip to content

Commit

Permalink
fix: Address PR notified exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Jul 19, 2024
1 parent 91565c9 commit 41c5a14
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions xblock/utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def load_unicode(self, resource_path):
Gets the content of a resource
"""
package_name = importlib.import_module(self.module_name).__package__
return importlib.resources.files(package_name).joinpath(resource_path).read_text()
return importlib.resources.files(package_name).joinpath(resource_path.lstrip('/')).read_text()

def render_django_template(self, template_path, context=None, i18n_service=None):
"""
Expand Down Expand Up @@ -56,8 +56,7 @@ def render_mako_template(self, template_path, context=None):
)
context = context or {}
template_str = self.load_unicode(template_path)
directory = str(importlib.resources.as_file(
importlib.resources.files(sys.modules[self.module_name].__package__)))
directory = os.path.dirname(os.path.realpath(sys.modules[self.module_name].__file__))
lookup = MakoTemplateLookup(directories=[directory])
template = MakoTemplate(template_str, lookup=lookup)
return template.render(**context)
Expand Down

0 comments on commit 41c5a14

Please sign in to comment.