summaryrefslogtreecommitdiff
path: root/meta/classes/package.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/package.bbclass
parent4808629faa1222b31f92a3e410e06adb8e081293 (diff)
downloadopenembedded-core-a43e0a8ecd0441131e929daf998c3cd454d9c8f3.tar.gz
openembedded-core-a43e0a8ecd0441131e929daf998c3cd454d9c8f3.tar.bz2
openembedded-core-a43e0a8ecd0441131e929daf998c3cd454d9c8f3.zip
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/package.bbclass')
-rw-r--r--meta/classes/package.bbclass7
1 files changed, 4 insertions, 3 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 7d0684c95c..36b3ae5109 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1096,7 +1096,8 @@ python emit_pkgdata() {
def get_directory_size(dir):
if os.listdir(dir):
- size = int(os.popen('du -sk %s' % dir).readlines()[0].split('\t')[0])
+ with os.popen('du -sk %s' % dir) as f:
+ size = int(f.readlines()[0].split('\t')[0])
else:
size = 0
return size
@@ -1203,7 +1204,7 @@ python emit_pkgdata() {
g = glob('*')
if g or allow_empty == "1":
packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg
- file(packagedfile, 'w').close()
+ open(packagedfile, 'w').close()
if bb.data.inherits_class('kernel', d) or bb.data.inherits_class('module-base', d):
write_extra_runtime_pkgs(variants, packages, pkgdatadir)
@@ -1633,7 +1634,7 @@ def read_libdep_files(d):
for extension in ".shlibdeps", ".pcdeps", ".clilibdeps":
depsfile = d.expand("${PKGDEST}/" + pkg + extension)
if os.access(depsfile, os.R_OK):
- fd = file(depsfile)
+ fd = open(depsfile)
lines = fd.readlines()
fd.close()
for l in lines: