1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 01:19:52 +00:00

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>
This commit is contained in:
Richard Purdie
2013-05-09 17:05:58 +01:00
parent d2ef952851
commit 566628d8cd
12 changed files with 79 additions and 74 deletions
+4 -3
View File
@@ -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: