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

fix --try-software-version using non-greedy matching + lookahead assertion, add test for tweak_one #2166

Merged
merged 2 commits into from Mar 14, 2017

Conversation

boegel
Copy link
Member

@boegel boegel commented Mar 14, 2017

fix for #2163; #2163 (comment) is probably useful to get a good idea of why this fix is needed

regexp = re.compile(r"^(?P<key>\s*%s)\s*=\s*(?P<val>\[(.|\n)*\])\s*$" % key, re.M)
# use non-greedy matching for list value using '*?' to avoid including other parameters in match,
# and a lookahead assertion (?=...) so next line is either another parameter definition or a blank line
regexp = re.compile(r"^(?P<key>\s*%s)\s*=\s*(?P<val>\[(.|\n)*?\])\s*$(?=\n^(\w+\s*=.*|\s*)$)" % key, 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.

why the last |?

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't \s also match \n in multiline mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

The last | in the lookahead assertion is there to check that the next line is either a parameter definition or a blank line (or the end of the file, see last commit).

Where is it relevant that \s also matches \n?

@boegel
Copy link
Member Author

boegel commented Mar 14, 2017

Thanks for the review @wpoely86!

@boegel boegel merged commit def11b9 into easybuilders:develop Mar 14, 2017
@boegel boegel deleted the fix_try_software_version branch March 14, 2017 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants