[elbe-devel] [PATCH 1/7] Add support for 'append_file' for Filesystem

dion at linutronix.de dion at linutronix.de
Fri May 17 11:16:55 CEST 2019


From: Olivier Dion <dion at linutronix.de>

'append_file' appends content to a file and can optionally change the
file mode.

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/filesystem.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 6ced9ddb..5d8c8cea 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -154,6 +154,13 @@ class Filesystem(object):
         f.close()
         self.chmod(path, mode)
 
+    def append_file(self, path, content, mode=None):
+        f = self.open(path, "a")
+        f.write(content)
+        f.close()
+        if mode is not None
+            self.chmod(path, mode)
+
     def read_file(self, path):
         fp = self.open(path, "r")
         retval = fp.read()
-- 
2.21.0




More information about the elbe-devel mailing list