From 564ac84ee0388964e3b8761415804aa7cb10d416 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 19 Oct 2024 08:14:02 -0700 Subject: [PATCH] cli/_state: fix writing command to file --- src/pymcnp/cli/_state.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pymcnp/cli/_state.py b/src/pymcnp/cli/_state.py index 036c031..7e573f9 100644 --- a/src/pymcnp/cli/_state.py +++ b/src/pymcnp/cli/_state.py @@ -81,15 +81,7 @@ def __init__(self): self.path.parent.mkdir(exist_ok=True, parents=True) if not self.path.is_file(): - self.path.write_text( - "command = 'mcnp'\n" - '\n' - 'def prehook():\n' - ' return\n' - '\n' - 'def posthook():\n' - ' return\n' - ) + self._sync_down() def prehook(self): pass @@ -131,7 +123,7 @@ def _sync_down(self): posthook = 'def posthook():\n' + ''.join(inspect.getsourcelines(self.posthook)[0][1:]) self.path.write_text( - f'command = {self.command}\n' + '\n' + prehook + '\n' + posthook + '\n' + f"command = '{self.command}'\n" + '\n' + prehook + '\n' + posthook + '\n' )