oeqa/utils/ftools: improve remove_from_file algorithm
The algorithm was sub-optimal so replace it with something more elegant. (From OE-Core rev: 6119a90173f9222efa6df25aacf873af85d64bcd) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
3a934a8087
commit
37683ef86e
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue