aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/insane.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-09 17:05:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-09 22:25:31 +0100
commita43e0a8ecd0441131e929daf998c3cd454d9c8f3 (patch)
tree69be538a129e3f9e985aa65d07005bf067371aa5 /meta/classes/insane.bbclass
parent4808629faa1222b31f92a3e410e06adb8e081293 (diff)
downloadopenembedded-core-contrib-a43e0a8ecd0441131e929daf998c3cd454d9c8f3.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 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/insane.bbclass')
-rw-r--r--meta/classes/insane.bbclass25
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):
return
tmpdir = d.getVar('TMPDIR', True)
- file_content = open(path).read()
- if tmpdir in file_content:
- messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d))
+ with open(path) as f:
+ file_content = f.read()
+ if tmpdir in file_content:
+ messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d))
QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi"
@@ -634,15 +635,17 @@ def package_qa_check_staged(path,d):
for file in files:
path = os.path.join(root,file)
if file.endswith(".la"):
- file_content = open(path).read()
- if workdir in file_content:
- error_msg = "%s failed sanity test (workdir) in path %s" % (file,root)
- sane = package_qa_handle_error("la", error_msg, d)
+ with open(path) as f:
+ file_content = f.read()
+ if workdir in file_content:
+ error_msg = "%s failed sanity test (workdir) in path %s" % (file,root)
+ sane = package_qa_handle_error("la", error_msg, d)
elif file.endswith(".pc"):
- file_content = open(path).read()
- if pkgconfigcheck in file_content:
- error_msg = "%s failed sanity test (tmpdir) in path %s" % (file,root)
- sane = package_qa_handle_error("pkgconfig", error_msg, d)
+ with open(path) as f:
+ file_content = f.read()
+ if pkgconfigcheck in file_content:
+ error_msg = "%s failed sanity test (tmpdir) in path %s" % (file,root)
+ sane = package_qa_handle_error("pkgconfig", error_msg, d)
return sane