[oe-commits] [bitbake] 11/13: bitbake: ConfHandler: Use with to manage filehandle lifetime
git at git.openembedded.org
git at git.openembedded.org
Wed Oct 23 22:00:15 UTC 2019
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository bitbake.
commit 459ad524756a3f9b50feeedf31e33502dceae8d5
Author: Ola x Nilsson <ola.x.nilsson at axis.com>
AuthorDate: Mon Oct 21 11:07:05 2019 +0200
bitbake: ConfHandler: Use with to manage filehandle lifetime
Signed-off-by: Ola x Nilsson <olani at axis.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/parse/parse_py/ConfHandler.py | 46 ++++++++++++++++++------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/lib/bb/parse/parse_py/ConfHandler.py b/lib/bb/parse/parse_py/ConfHandler.py
index 2e84b91..af64d34 100644
--- a/lib/bb/parse/parse_py/ConfHandler.py
+++ b/lib/bb/parse/parse_py/ConfHandler.py
@@ -119,30 +119,30 @@ def handle(fn, data, include):
oldfile = data.getVar('FILE', False)
abs_fn = resolve_file(fn, data)
- f = open(abs_fn, 'r')
-
- statements = ast.StatementGroup()
- lineno = 0
- while True:
- lineno = lineno + 1
- s = f.readline()
- if not s:
- break
- w = s.strip()
- # skip empty lines
- if not w:
- continue
- s = s.rstrip()
- while s[-1] == '\\':
- s2 = f.readline().rstrip()
+ with open(abs_fn, 'r') as f:
+
+ statements = ast.StatementGroup()
+ lineno = 0
+ while True:
lineno = lineno + 1
- if (not s2 or s2 and s2[0] != "#") and s[0] == "#" :
- bb.fatal("There is a confusing multiline, partially commented expression on line %s of file %s (%s).\nPlease clarify whether this is all a comment or should be parsed." % (lineno, fn, s))
- s = s[:-1] + s2
- # skip comments
- if s[0] == '#':
- continue
- feeder(lineno, s, abs_fn, statements)
+ s = f.readline()
+ if not s:
+ break
+ w = s.strip()
+ # skip empty lines
+ if not w:
+ continue
+ s = s.rstrip()
+ while s[-1] == '\\':
+ s2 = f.readline().rstrip()
+ lineno = lineno + 1
+ if (not s2 or s2 and s2[0] != "#") and s[0] == "#" :
+ bb.fatal("There is a confusing multiline, partially commented expression on line %s of file %s (%s).\nPlease clarify whether this is all a comment or should be parsed." % (lineno, fn, s))
+ s = s[:-1] + s2
+ # skip comments
+ if s[0] == '#':
+ continue
+ feeder(lineno, s, abs_fn, statements)
# DONE WITH PARSING... time to evaluate
data.setVar('FILE', abs_fn)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list