Skip to content

Commit

Permalink
fix(node.py): Only print last line in _module
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Vasenin committed Aug 8, 2021
1 parent d56857d commit 8980f1f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ntc/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def validate_required(cfg: CfgNode) -> None:
elif attr.required and attr.value is None:
raise MissingRequired(f"Key {attr} is required, but was not provided.")

def save(self, path: Path) -> None:
def save(self, path: Union[Path, str]) -> None:
path = Path(path)
if not self._safe_save:
raise SaveError("Config was updated in such a way that it can no longer be saved!")
if not self._module:
Expand Down Expand Up @@ -383,6 +384,7 @@ def _update_module(self, full_key: str, value) -> None:
continue
lines = [f"# {info.filename}:{info.lineno} {info.code_context[0]}", f"{full_key} = {value!r}\n"]
self._module.extend(lines)
break
else:
logger.warning(f"Config was modified with unsavable value: {value!r}")
self._safe_save = False
Expand Down

0 comments on commit 8980f1f

Please sign in to comment.