summaryrefslogtreecommitdiffstats
path: root/bitbake
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-19 18:05:47 +0100
commit97067755b936547f1bf87c1c0c64eccc320f48ca (patch)
treee85b4ae85dd56bb3db93af9ce29633d0f6c62efc /bitbake
parent90d97f7a57125df00c0fd62772e782a638176d7a (diff)
downloadpoky-97067755b936547f1bf87c1c0c64eccc320f48ca.tar.gz
bitbake: bitbake-layers: use "with open" consistently
It's best practice to use "with open..." rather than open & close where practical. (Bitbake rev: 1ef38549cae5639f2c8bcc2b270c5c82a5e29e3c) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake-layers62
1 files changed, 29 insertions, 33 deletions
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index 8cf7196c53..5518c63641 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -705,13 +705,11 @@ build results (as the layer priority order has effectively changed).
705 return os.path.basename(layerdir.rstrip(os.sep)) 705 return os.path.basename(layerdir.rstrip(os.sep))
706 706
707 def apply_append(self, appendname, recipename): 707 def apply_append(self, appendname, recipename):
708 appendfile = open(appendname, 'r') 708 with open(appendname, 'r') as appendfile:
709 recipefile = open(recipename, 'a') 709 with open(recipename, 'a') as recipefile:
710 recipefile.write('\n') 710 recipefile.write('\n')
711 recipefile.write('##### bbappended from %s #####\n' % self.get_file_layer(appendname)) 711 recipefile.write('##### bbappended from %s #####\n' % self.get_file_layer(appendname))
712 recipefile.writelines(appendfile.readlines()) 712 recipefile.writelines(appendfile.readlines())
713 recipefile.close()
714 appendfile.close()
715 713
716 def do_show_appends(self, args): 714 def do_show_appends(self, args):
717 """list bbappend files and recipe files they apply to 715 """list bbappend files and recipe files they apply to
@@ -879,20 +877,19 @@ NOTE: .bbappend files can impact the dependencies.
879 877
880 # The 'require/include xxx' in the bb file 878 # The 'require/include xxx' in the bb file
881 pv_re = re.compile(r"\${PV}") 879 pv_re = re.compile(r"\${PV}")
882 fnfile = open(f, 'r') 880 with open(f, 'r') as fnfile:
883 line = fnfile.readline()
884 while line:
885 m, keyword = self.match_require_include(line)
886 # Found the 'require/include xxxx'
887 if m:
888 needed_file = m.group(1)
889 # Replace the ${PV} with the real PV
890 if pv_re.search(needed_file) and f in self.bbhandler.cooker_data.pkg_pepvpr:
891 pv = self.bbhandler.cooker_data.pkg_pepvpr[f][1]
892 needed_file = re.sub(r"\${PV}", pv, needed_file)
893 self.print_cross_files(bbpath, keyword, layername, f, needed_file, args.filenames, ignore_layers)
894 line = fnfile.readline() 881 line = fnfile.readline()
895 fnfile.close() 882 while line:
883 m, keyword = self.match_require_include(line)
884 # Found the 'require/include xxxx'
885 if m:
886 needed_file = m.group(1)
887 # Replace the ${PV} with the real PV
888 if pv_re.search(needed_file) and f in self.bbhandler.cooker_data.pkg_pepvpr:
889 pv = self.bbhandler.cooker_data.pkg_pepvpr[f][1]
890 needed_file = re.sub(r"\${PV}", pv, needed_file)
891 self.print_cross_files(bbpath, keyword, layername, f, needed_file, args.filenames, ignore_layers)
892 line = fnfile.readline()
896 893
897 # The "require/include xxx" in conf/machine/*.conf, .inc and .bbclass 894 # The "require/include xxx" in conf/machine/*.conf, .inc and .bbclass
898 conf_re = re.compile(".*/conf/machine/[^\/]*\.conf$") 895 conf_re = re.compile(".*/conf/machine/[^\/]*\.conf$")
@@ -906,20 +903,19 @@ NOTE: .bbappend files can impact the dependencies.
906 f = os.path.join(dirpath, name) 903 f = os.path.join(dirpath, name)
907 s = conf_re.match(f) or inc_re.match(f) or bbclass_re.match(f) 904 s = conf_re.match(f) or inc_re.match(f) or bbclass_re.match(f)
908 if s: 905 if s:
909 ffile = open(f, 'r') 906 with open(f, 'r') as ffile:
910 line = ffile.readline()
911 while line:
912 m, keyword = self.match_require_include(line)
913 # Only bbclass has the "inherit xxx" here.
914 bbclass=""
915 if not m and f.endswith(".bbclass"):
916 m, keyword = self.match_inherit(line)
917 bbclass=".bbclass"
918 # Find a 'require/include xxxx'
919 if m:
920 self.print_cross_files(bbpath, keyword, layername, f, m.group(1) + bbclass, args.filenames, ignore_layers)
921 line = ffile.readline() 907 line = ffile.readline()
922 ffile.close() 908 while line:
909 m, keyword = self.match_require_include(line)
910 # Only bbclass has the "inherit xxx" here.
911 bbclass=""
912 if not m and f.endswith(".bbclass"):
913 m, keyword = self.match_inherit(line)
914 bbclass=".bbclass"
915 # Find a 'require/include xxxx'
916 if m:
917 self.print_cross_files(bbpath, keyword, layername, f, m.group(1) + bbclass, args.filenames, ignore_layers)
918 line = ffile.readline()
923 919
924 def print_cross_files(self, bbpath, keyword, layername, f, needed_filename, show_filenames, ignore_layers): 920 def print_cross_files(self, bbpath, keyword, layername, f, needed_filename, show_filenames, ignore_layers):
925 """Print the depends that crosses a layer boundary""" 921 """Print the depends that crosses a layer boundary"""