From 0bb264792eb5c430fcc8012a27edb840059acf42 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 25 Aug 2024 00:10:34 +0200 Subject: [PATCH] [file] Added `file.copy` and `file.move` actions. --- platypush/plugins/file/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/platypush/plugins/file/__init__.py b/platypush/plugins/file/__init__.py index c9670c99b3..81f0885b8c 100644 --- a/platypush/plugins/file/__init__.py +++ b/platypush/plugins/file/__init__.py @@ -154,6 +154,26 @@ class FilePlugin(Plugin): """ pathlib.Path(self._get_path(file)).rename(self._get_path(name)) + @action + def copy(self, source: str, target: str): + """ + Copy a file. + + :param source: Source file. + :param target: Destination file. + """ + shutil.copy(self._get_path(source), self._get_path(target)) + + @action + def move(self, source: str, target: str): + """ + Move a file. + + :param source: Source file. + :param target: Destination file. + """ + shutil.move(self._get_path(source), self._get_path(target)) + @action def link(self, file: str, target: str, symbolic=True): """