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

Bugfix write config option #7

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion a3fe/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.2"
__version__ = "0.1.3"
7 changes: 7 additions & 0 deletions a3fe/read/_process_somd_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ def write_simfile_option(
logger.warning(
f"Option {option} not found in simfile {simfile}. Appending new option to the end of the file."
)

# First, ensure that the previous line terminates with a newline
# (Otherwise we'll end up adding the new option to the end of the previous line)
if lines[-1][-1] != "\n":
lines[-1] += "\n"

lines.append(f"{option} = {value}\n")

# Otherwise, replace the line with the new value
else:
lines[option_line_idx] = f"{option} = {value}\n"
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Change Log
===============

0.1.3
====================

- Ensured that config options are written correctly when the template config file does not terminate in a new line. Previously, new options would be appended to the last line of the file if it did not end with \n, which could happen if the user manually edited the file.

0.1.2
====================

Expand Down
Loading