summaryrefslogtreecommitdiffstats
path: root/bin/bitbake-layers
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-08-17 12:12:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-18 12:12:07 +0100
commit1ef38549cae5639f2c8bcc2b270c5c82a5e29e3c (patch)
treed50f31e2e3383b55f83c47aa454312438c430641 /bin/bitbake-layers
parent60a253555a3ebadea775cfdc3331cba78ee3e71b (diff)
downloadbitbake-contrib-1ef38549cae5639f2c8bcc2b270c5c82a5e29e3c.tar.gz
bitbake-layers: use "with open" consistently
It's best practice to use "with open..." rather than open & close where practical. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bin/bitbake-layers')
-rwxr-xr-xbin/bitbake-layers62
1 files changed, 29 insertions, 33 deletions
diff --git a/bin/bitbake-layers b/bin/bitbake-layers
index 8cf7196c5..5518c6364 100755
--- a/bin/bitbake-layers
+++ b/bin/bitbake-layers
@@ -705,13 +705,11 @@ build results (as the layer priority order has effectively changed).
return os.path.basename(layerdir.rstrip(os.sep))
def apply_append(self, appendname, recipename):
- appendfile = open(appendname, 'r')
- recipefile = open(recipename, 'a')
- recipefile.write('\n')
- recipefile.write('##### bbappended from %s #####\n' % self.get_file_layer(appendname))
- recipefile.writelines(appendfile.readlines())
- recipefile.close()
- appendfile.close()
+ with open(appendname, 'r') as appendfile:
+ with open(recipename, 'a') as recipefile:
+ recipefile.write('\n')
+ recipefile.write('##### bbappended from %s #####\n' % self.get_file_layer(appendname))
+ recipefile.writelines(appendfile.readlines())
def do_show_appends(self, args):
"""list bbappend files and recipe files they apply to
@@ -879,20 +877,19 @@ NOTE: .bbappend files can impact the dependencies.
# The 'require/include xxx' in the bb file
pv_re = re.compile(r"\${PV}")
- fnfile = open(f, 'r')
- line = fnfile.readline()
- while line:
- m, keyword = self.match_require_include(line)
- # Found the 'require/include xxxx'
- if m:
- needed_file = m.group(1)
- # Replace the ${PV} with the real PV
- if pv_re.search(needed_file) and f in self.bbhandler.cooker_data.pkg_pepvpr:
- pv = self.bbhandler.cooker_data.pkg_pepvpr[f][1]
- needed_file = re.sub(r"\${PV}", pv, needed_file)
- self.print_cross_files(bbpath, keyword, layername, f, needed_file, args.filenames, ignore_layers)
+ with open(f, 'r') as fnfile:
line = fnfile.readline()
- fnfile.close()
+ while line:
+ m, keyword = self.match_require_include(line)
+ # Found the 'require/include xxxx'
+ if m:
+ needed_file = m.group(1)
+ # Replace the ${PV} with the real PV
+ if pv_re.search(needed_file) and f in self.bbhandler.cooker_data.pkg_pepvpr:
+ pv = self.bbhandler.cooker_data.pkg_pepvpr[f][1]
+ needed_file = re.sub(r"\${PV}", pv, needed_file)
+ self.print_cross_files(bbpath, keyword, layername, f, needed_file, args.filenames, ignore_layers)
+ line = fnfile.readline()
# The "require/include xxx" in conf/machine/*.conf, .inc and .bbclass
conf_re = re.compile(".*/conf/machine/[^\/]*\.conf$")
@@ -906,20 +903,19 @@ NOTE: .bbappend files can impact the dependencies.
f = os.path.join(dirpath, name)
s = conf_re.match(f) or inc_re.match(f) or bbclass_re.match(f)
if s:
- ffile = open(f, 'r')
- line = ffile.readline()
- while line:
- m, keyword = self.match_require_include(line)
- # Only bbclass has the "inherit xxx" here.
- bbclass=""
- if not m and f.endswith(".bbclass"):
- m, keyword = self.match_inherit(line)
- bbclass=".bbclass"
- # Find a 'require/include xxxx'
- if m:
- self.print_cross_files(bbpath, keyword, layername, f, m.group(1) + bbclass, args.filenames, ignore_layers)
+ with open(f, 'r') as ffile:
line = ffile.readline()
- ffile.close()
+ while line:
+ m, keyword = self.match_require_include(line)
+ # Only bbclass has the "inherit xxx" here.
+ bbclass=""
+ if not m and f.endswith(".bbclass"):
+ m, keyword = self.match_inherit(line)
+ bbclass=".bbclass"
+ # Find a 'require/include xxxx'
+ if m:
+ self.print_cross_files(bbpath, keyword, layername, f, m.group(1) + bbclass, args.filenames, ignore_layers)
+ line = ffile.readline()
def print_cross_files(self, bbpath, keyword, layername, f, needed_filename, show_filenames, ignore_layers):
"""Print the depends that crosses a layer boundary"""