mirror of
https://git.yoctoproject.org/poky
synced 2026-05-09 17:39:31 +00:00
bitbake: bitbake: ConfHandler: Use with to manage filehandle lifetime
(Bitbake rev: 459ad524756a3f9b50feeedf31e33502dceae8d5) Signed-off-by: Ola x Nilsson <olani@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
beda62448d
commit
5107dce38e
@@ -119,30 +119,30 @@ def handle(fn, data, include):
|
|||||||
oldfile = data.getVar('FILE', False)
|
oldfile = data.getVar('FILE', False)
|
||||||
|
|
||||||
abs_fn = resolve_file(fn, data)
|
abs_fn = resolve_file(fn, data)
|
||||||
f = open(abs_fn, 'r')
|
with open(abs_fn, 'r') as f:
|
||||||
|
|
||||||
statements = ast.StatementGroup()
|
statements = ast.StatementGroup()
|
||||||
lineno = 0
|
lineno = 0
|
||||||
while True:
|
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()
|
|
||||||
lineno = lineno + 1
|
lineno = lineno + 1
|
||||||
if (not s2 or s2 and s2[0] != "#") and s[0] == "#" :
|
s = f.readline()
|
||||||
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))
|
if not s:
|
||||||
s = s[:-1] + s2
|
break
|
||||||
# skip comments
|
w = s.strip()
|
||||||
if s[0] == '#':
|
# skip empty lines
|
||||||
continue
|
if not w:
|
||||||
feeder(lineno, s, abs_fn, statements)
|
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
|
# DONE WITH PARSING... time to evaluate
|
||||||
data.setVar('FILE', abs_fn)
|
data.setVar('FILE', abs_fn)
|
||||||
|
|||||||
Reference in New Issue
Block a user