summaryrefslogtreecommitdiff
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2015-10-20 12:43:34 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-28 15:54:52 +0100
commit6119a90173f9222efa6df25aacf873af85d64bcd (patch)
tree4339c0d06cc2600aca67e09565d3e4c852633db0 /meta/lib/oeqa/utils
parent7c0c9d1411e04935675f4c4be8768723c1d09b50 (diff)
downloadopenembedded-core-6119a90173f9222efa6df25aacf873af85d64bcd.tar.gz
openembedded-core-6119a90173f9222efa6df25aacf873af85d64bcd.tar.bz2
openembedded-core-6119a90173f9222efa6df25aacf873af85d64bcd.zip
oeqa/utils/ftools: improve remove_from_file algorithm
The algorithm was sub-optimal so replace it with something more elegant. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/ftools.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py
index 1bd9a30a40..a7233d4ca6 100644
--- a/meta/lib/oeqa/utils/ftools.py
+++ b/meta/lib/oeqa/utils/ftools.py
@@ -36,10 +36,11 @@ def remove_from_file(path, data):
return
else:
raise
- lines = rdata.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))
+
+ contents = rdata.strip().splitlines()
+ for r in data.strip().splitlines():
+ try:
+ contents.remove(r)
+ except ValueError:
+ pass
+ write_file(path, "\n".join(contents))