diff options
| author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
|---|---|---|
| committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
| commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
| tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /meta/lib/oeqa/utils/ftools.py | |
| download | poky-daisy-140929.tar.gz | |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/lib/oeqa/utils/ftools.py')
| -rw-r--r-- | meta/lib/oeqa/utils/ftools.py | 27 |
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 @@ | |||
| 1 | import os | ||
| 2 | import re | ||
| 3 | |||
| 4 | def write_file(path, data): | ||
| 5 | wdata = data.rstrip() + "\n" | ||
| 6 | with open(path, "w") as f: | ||
| 7 | f.write(wdata) | ||
| 8 | |||
| 9 | def append_file(path, data): | ||
| 10 | wdata = data.rstrip() + "\n" | ||
| 11 | with open(path, "a") as f: | ||
| 12 | f.write(wdata) | ||
| 13 | |||
| 14 | def read_file(path): | ||
| 15 | data = None | ||
| 16 | with open(path) as f: | ||
| 17 | data = f.read() | ||
| 18 | return data | ||
| 19 | |||
| 20 | def remove_from_file(path, data): | ||
| 21 | lines = read_file(path).splitlines() | ||
| 22 | rmdata = data.strip().splitlines() | ||
| 23 | for l in rmdata: | ||
| 24 | for c in range(0, lines.count(l)): | ||
| 25 | i = lines.index(l) | ||
| 26 | del(lines[i]) | ||
| 27 | write_file(path, "\n".join(lines)) | ||
