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

cmdline/utils/multi_line_input: fix "referenced before assignment" #4440

Closed
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
5 changes: 4 additions & 1 deletion aiida/cmdline/utils/multi_line_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def edit_multiline_template(template_name, comment_marker='#=', extension=None,
"""Open a template file for editing in a text editor.

:param template: name of the template to use from the ``aiida.cmdline.templates`` directory.
:param comment_marker: the set of symbols that mark a comment line that should be stripped from the final value
:param comment_marker: the set of symbols that mark a comment line that should be stripped
from the final value
:param extension: the file extension to give to the rendered template file.
:param kwargs: keywords that will be passed to the template rendering engine.
:return: the final string value entered in the editor with all comment lines stripped.
Expand All @@ -30,6 +31,8 @@ def edit_multiline_template(template_name, comment_marker='#=', extension=None,
if content:
# Remove all comments, which are all lines that start with the comment marker
value = re.sub(f'(^{re.escape(comment_marker)}.*$\n)+', '', content, flags=re.M).strip()
else:
value = ''

return value

Expand Down