[elbe-devel] [PATCH v2 1/6] Add support for 'append_file' for Filesystem
dion at linutronix.de
dion at linutronix.de
Fri May 17 16:36:54 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..978d32a1 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