aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/ftools.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/utils/ftools.py')
-rw-r--r--meta/lib/oeqa/utils/ftools.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py
new file mode 100644
index 0000000000..64ebe3d217
--- /dev/null
+++ b/meta/lib/oeqa/utils/ftools.py
@@ -0,0 +1,27 @@
+import os
+import re
+
+def write_file(path, data):
+ wdata = data.rstrip() + "\n"
+ with open(path, "w") as f:
+ f.write(wdata)
+
+def append_file(path, data):
+ wdata = data.rstrip() + "\n"
+ with open(path, "a") as f:
+ f.write(wdata)
+
+def read_file(path):
+ data = None
+ with open(path) as f:
+ data = f.read()
+ return data
+
+def remove_from_file(path, data):
+ lines = read_file(path).splitlines()
+ rmdata = data.strip().splitlines()
+ for l in rmdata:
+ for c in range(0, lines.count(l)):
+ i = lines.index(l)
+ del(lines[i])
+ write_file(path, "\n".join(lines))