[elbe-devel] [PATCH 2/7] elbepack: efilesystem: only calculate excursion destination once
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Tue Dec 17 13:24:25 CET 2024
Keep the logic simpler to understand by always calculating the
destination in the constructor.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/efilesystem.py | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 95d118bbb4a5863caa51bdc479734177abb247f6..32dc19fa0494937f60f6654eb9565459e65bb5d9 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -257,18 +257,14 @@ class Excursion:
def __init__(self, path, restore=True, dst=None):
self.origin = path
self.restore = restore
- self.dst = dst
+ self.dst = dst or self.origin
def do(self, rfs):
if rfs.lexists(self.origin) and self.restore is True:
save_to = self._saved_to()
shutil.move(rfs.fname(self.origin), rfs.fname(save_to))
if os.path.exists(self.origin):
- if self.dst is not None:
- dst = self.dst
- else:
- dst = self.origin
- shutil.copy2(self.origin, rfs.fname(dst))
+ shutil.copy2(self.origin, rfs.fname(self.dst))
def end(self, rfs):
self._undo_excursion(rfs)
--
2.47.1
More information about the elbe-devel
mailing list