Skip to content

Commit

Permalink
Merge pull request #7 from michellab/bugfix_write_config_option
Browse files Browse the repository at this point in the history
Bugfix write config option
  • Loading branch information
fjclark authored Sep 20, 2024
2 parents 1063b5c + bf0dc88 commit 8aee7b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
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

0 comments on commit 8aee7b9

Please sign in to comment.