[OE-core] [PATCH v3 35/52] oeqa/utils/ftools: From functions that expect data, check if None

Joshua Lock joshua.lock at collabora.co.uk
Thu Oct 22 15:21:56 UTC 2015


From: Leonardo Sandoval <leonardo.sandoval.gonzalez at linux.intel.com>

ftools functions that expect data may get 'None'; this patch does this check
and return immediately if this is the case.

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez at linux.intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/lib/oeqa/utils/ftools.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py
index 1ec8a09..1bd9a30 100644
--- a/meta/lib/oeqa/utils/ftools.py
+++ b/meta/lib/oeqa/utils/ftools.py
@@ -3,11 +3,17 @@ import re
 import errno
 
 def write_file(path, data):
+    # In case data is None, return immediately
+    if data is None:
+        return
     wdata = data.rstrip() + "\n"
     with open(path, "w") as f:
         f.write(wdata)
 
 def append_file(path, data):
+    # In case data is None, return immediately
+    if data is None:
+        return
     wdata = data.rstrip() + "\n"
     with open(path, "a") as f:
             f.write(wdata)
@@ -19,6 +25,9 @@ def read_file(path):
     return data
 
 def remove_from_file(path, data):
+    # In case data is None, return immediately
+    if data is None:
+        return
     try:
         rdata = read_file(path)
     except IOError as e:
-- 
2.1.4




More information about the Openembedded-core mailing list