[oe-commits] [openembedded-core] 19/23: oeqa/utils/ftools: improve remove_from_file algorithm

git at git.openembedded.org git at git.openembedded.org
Mon Mar 28 14:56:44 UTC 2016


rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 6119a90173f9222efa6df25aacf873af85d64bcd
Author: Ross Burton <ross.burton at intel.com>
AuthorDate: Tue Oct 20 12:43:34 2015 +0100

    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 at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/utils/ftools.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py
index 1bd9a30..a7233d4 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))

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list