diff --git a/openedx/core/lib/xblock_pipeline/finder.py b/openedx/core/lib/xblock_pipeline/finder.py index 517fd0bccf18..7d8a1a2c5101 100644 --- a/openedx/core/lib/xblock_pipeline/finder.py +++ b/openedx/core/lib/xblock_pipeline/finder.py @@ -10,7 +10,7 @@ from django.contrib.staticfiles.storage import FileSystemStorage from django.core.files.storage import Storage from django.utils import timezone -from importlib.resources import files, isdir, exists, listdir +from importlib.resources import files, exists, listdir from xblock.core import XBlock from openedx.core.lib.xblock_utils import xblock_resource_pkg @@ -54,15 +54,15 @@ def listdir(self, path): Lists the directories beneath the specified path. """ directories = [] - files = [] + dir_files = [] for item in listdir(self.module, os.path.join(self.base_dir, path)): __, file_extension = os.path.splitext(item) if file_extension not in [".py", ".pyc", ".scss"]: - if isdir(self.module, os.path.join(self.base_dir, path, item)): + if os.path.isdir(os.path.join(self.base_dir, path, item)): directories.append(item) else: - files.append(item) - return directories, files + dir_files.append(item) + return directories, dir_files def open(self, name, mode='rb'): """ diff --git a/xmodule/x_module.py b/xmodule/x_module.py index 41f849384564..1478d6b9bd6d 100644 --- a/xmodule/x_module.py +++ b/xmodule/x_module.py @@ -855,16 +855,14 @@ def templates(cls): @classmethod def get_template_dir(cls): # lint-amnesty, pylint: disable=missing-function-docstring if getattr(cls, 'template_dir_name', None): - dirname = files(__name__).joinpath('templates', cls.template_dir_name) - if not dirname.is_dir(): - log.warning( - "No resource directory {dir} found when loading {cls_name} templates".format( - dir=f'templates/{cls.template_dir_name}', - cls_name=cls.__name__, - ) - ) + dirname = os.path.join('templates', cls.template_dir_name) + if not os.path.isdir(os.path.join(os.path.dirname(__file__), dirname)): + log.warning("No resource directory {dir} found when loading {cls_name} templates".format( + dir=dirname, + cls_name=cls.__name__, + )) return None - return f'templates/{cls.template_dir_name}' + return dirname return None @classmethod