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

Bug fix for modpath_extensions_for function. #1474

Merged
merged 1 commit into from
May 18, 2016
Merged
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
12 changes: 9 additions & 3 deletions easybuild/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,15 @@ def modpath_extensions_for(self, mod_names):

modpath_exts = {}
for mod_name in mod_names:
modtxt = self.read_module_file(mod_name)
useregex = re.compile(r"^\s*module\s+use\s+(\S+)", re.M)
exts = useregex.findall(modtxt)
# Should be module show so as to catch conditional loads.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not loads, use statements

modtxt = self.show(mod_name)
useregex = re.compile(r"^\s*module\s+use\s+(\S+)|^\s*prepend_path\(\"MODULEPATH\",\s*\"(\S+)\"", re.M)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, do we have to consider single quotes here too in the prepend_path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although since we are creating the line, we might be able to get away with only double.

exts = []
for i in useregex.finditer(modtxt):
if i.group(1):
exts.append(i.group(1))
elif i.group(2):
exts.append(i.group(2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, findall doesn't do the job anymore? there must be a better/easier way than this...


self.log.debug("Found $MODULEPATH extensions for %s: %s" % (mod_name, exts))
modpath_exts.update({mod_name: exts})
Expand Down