diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-09 17:05:58 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-09 22:28:04 +0100 |
| commit | 566628d8cd674a964d5824391cfd1585a1a22a87 (patch) | |
| tree | 670366ee1492ff8bb18b9261dfab9d06c06b0a2d /meta/classes/insane.bbclass | |
| parent | d2ef952851d9ef16875fdbbbc6ae6eb6cfc10cc0 (diff) | |
| download | poky-566628d8cd674a964d5824391cfd1585a1a22a87.tar.gz | |
class/lib: Fix up various file access methods
There are various bits of cruft that have built up around our file accesses. This patch
cleans some of them up, specifically:
* Remove pointless "from __builtin__ import file"
* Use open(), not file()
* Wrap file usage in a with container to ensure files are closed
* Add missing .close() calls in some cases
(From OE-Core rev: a43e0a8ecd0441131e929daf998c3cd454d9c8f3)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/insane.bbclass')
| -rw-r--r-- | meta/classes/insane.bbclass | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 809aa457a1..4d2392e908 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass | |||
| @@ -518,9 +518,10 @@ def package_qa_check_buildpaths(path, name, d, elf, messages): | |||
| 518 | return | 518 | return |
| 519 | 519 | ||
| 520 | tmpdir = d.getVar('TMPDIR', True) | 520 | tmpdir = d.getVar('TMPDIR', True) |
| 521 | file_content = open(path).read() | 521 | with open(path) as f: |
| 522 | if tmpdir in file_content: | 522 | file_content = f.read() |
| 523 | messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d)) | 523 | if tmpdir in file_content: |
| 524 | messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d)) | ||
| 524 | 525 | ||
| 525 | 526 | ||
| 526 | QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi" | 527 | QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi" |
| @@ -634,15 +635,17 @@ def package_qa_check_staged(path,d): | |||
| 634 | for file in files: | 635 | for file in files: |
| 635 | path = os.path.join(root,file) | 636 | path = os.path.join(root,file) |
| 636 | if file.endswith(".la"): | 637 | if file.endswith(".la"): |
| 637 | file_content = open(path).read() | 638 | with open(path) as f: |
| 638 | if workdir in file_content: | 639 | file_content = f.read() |
| 639 | error_msg = "%s failed sanity test (workdir) in path %s" % (file,root) | 640 | if workdir in file_content: |
| 640 | sane = package_qa_handle_error("la", error_msg, d) | 641 | error_msg = "%s failed sanity test (workdir) in path %s" % (file,root) |
| 642 | sane = package_qa_handle_error("la", error_msg, d) | ||
| 641 | elif file.endswith(".pc"): | 643 | elif file.endswith(".pc"): |
| 642 | file_content = open(path).read() | 644 | with open(path) as f: |
| 643 | if pkgconfigcheck in file_content: | 645 | file_content = f.read() |
| 644 | error_msg = "%s failed sanity test (tmpdir) in path %s" % (file,root) | 646 | if pkgconfigcheck in file_content: |
| 645 | sane = package_qa_handle_error("pkgconfig", error_msg, d) | 647 | error_msg = "%s failed sanity test (tmpdir) in path %s" % (file,root) |
| 648 | sane = package_qa_handle_error("pkgconfig", error_msg, d) | ||
| 646 | 649 | ||
| 647 | return sane | 650 | return sane |
| 648 | 651 | ||
