Skip to content

Commit

Permalink
fix: errors
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Jan 7, 2025
1 parent c39b574 commit 730bec2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions xmodule/x_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from opaque_keys.edx.asides import AsideDefinitionKeyV2, AsideUsageKeyV2
from opaque_keys.edx.keys import UsageKey
from importlib.resources import files, as_file
from pathlib import Path
from web_fragments.fragment import Fragment
from webob import Response
from webob.multidict import MultiDict
Expand Down Expand Up @@ -872,11 +873,13 @@ def get_template_dirpaths(cls):
"""
template_dirpaths = []
template_dirname = cls.get_template_dir()
if template_dirname:
template_path = files(__name__).joinpath(template_dirname)
if template_path.is_dir():
with as_file(template_path) as resolved_path:
template_dirpaths.append(str(resolved_path))
package, module_path = __name__.split('.', 1)
module_dir = str(Path(module_path).parent)
file_dirs = files(package).joinpath(module_dir, template_dirname)

if template_dirname and file_dirs.is_dir():
with as_file(file_dirs) as path:
template_dirpaths.append(path)

custom_template_dir = cls.get_custom_template_dir()
if custom_template_dir:
Expand Down

0 comments on commit 730bec2

Please sign in to comment.