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

changed easyconfig.update to be able to specify not to allow duplicate values #2657

Merged
merged 7 commits into from
Nov 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,17 +442,18 @@ def copy(self):

return ec

def update(self, key, value):
def update(self, key, value, allow_duplicate = True):
mboisson marked this conversation as resolved.
Show resolved Hide resolved
"""
Update a string configuration value with a value (i.e. append to it).
"""
prev_value = self[key]
if isinstance(prev_value, basestring):
self[key] = '%s %s ' % (prev_value, value)
elif isinstance(prev_value, list):
self[key] = prev_value + value
else:
raise EasyBuildError("Can't update configuration value for %s, because it's not a string or list.", key)
if allow_duplicate or not value in prev_value:
mboisson marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(prev_value, basestring):
self[key] = '%s %s ' % (prev_value, value)
elif isinstance(prev_value, list):
self[key] = prev_value + value
else:
raise EasyBuildError("Can't update configuration value for %s, because it's not a string or list.", key)

def parse(self):
"""
Expand Down