diff options
author | Filip Krska <fkrska@redhat.com> | 2018-10-23 16:27:45 +0200 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2019-03-18 18:51:40 +0000 |
commit | d4748e742f5c812c29d944dc75e7d9da51a7fe36 (patch) | |
tree | 69bf3d3f2062e63214b4e9294163ec9a06645abe | |
parent | ffa2abe7010a709808119a212fcf971ba3235a04 (diff) | |
download | sos-d4748e742f5c812c29d944dc75e7d9da51a7fe36.tar.gz |
[archive] add mode argument to Archive.add_string()
Add mode (e.g. to allow append) support to add_string() function.
Related: #1461
Signed-off-by: Filip Krska <fkrska@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/archive.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sos/archive.py b/sos/archive.py index b02b75f7..baa05c94 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -85,7 +85,7 @@ class Archive(object): def add_file(self, src, dest=None): raise NotImplementedError - def add_string(self, content, dest): + def add_string(self, content, dest, mode='w'): raise NotImplementedError def add_binary(self, content, dest): @@ -366,7 +366,7 @@ class FileCacheArchive(Archive): self.log_debug("added %s to FileCacheArchive '%s'" % (file_name, self._archive_root)) - def add_string(self, content, dest): + def add_string(self, content, dest, mode='w'): with self._path_lock: src = dest @@ -376,7 +376,7 @@ class FileCacheArchive(Archive): # on file content. dest = self._check_path(dest, P_FILE, force=True) - f = codecs.open(dest, 'w', encoding='utf-8') + f = codecs.open(dest, mode, encoding='utf-8') if isinstance(content, bytes): content = content.decode('utf8', 'ignore') f.write(content) |