diff options
author | Ola x Nilsson <ola.x.nilsson@axis.com> | 2019-10-21 11:07:05 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-10-28 05:31:53 +0000 |
commit | 5107dce38e6b4e8b30b125113abdcb1c19ec9664 (patch) | |
tree | aba9e75c1e3ba28926839b7dab1de07e08cc712c /bitbake | |
parent | beda62448dc544ae7969b31a1524fed28e4d2e1f (diff) | |
download | poky-5107dce38e6b4e8b30b125113abdcb1c19ec9664.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 2e84b913d8..af64d3446e 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -119,30 +119,30 @@ def handle(fn, data, include): | |||
119 | oldfile = data.getVar('FILE', False) | 119 | oldfile = data.getVar('FILE', False) |
120 | 120 | ||
121 | abs_fn = resolve_file(fn, data) | 121 | abs_fn = resolve_file(fn, data) |
122 | f = open(abs_fn, 'r') | 122 | with open(abs_fn, 'r') as f: |
123 | 123 | ||
124 | statements = ast.StatementGroup() | 124 | statements = ast.StatementGroup() |
125 | lineno = 0 | 125 | lineno = 0 |
126 | while True: | 126 | while True: |
127 | lineno = lineno + 1 | ||
128 | s = f.readline() | ||
129 | if not s: | ||
130 | break | ||
131 | w = s.strip() | ||
132 | # skip empty lines | ||
133 | if not w: | ||
134 | continue | ||
135 | s = s.rstrip() | ||
136 | while s[-1] == '\\': | ||
137 | s2 = f.readline().rstrip() | ||
138 | lineno = lineno + 1 | 127 | lineno = lineno + 1 |
139 | if (not s2 or s2 and s2[0] != "#") and s[0] == "#" : | 128 | s = f.readline() |
140 | 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)) | 129 | if not s: |
141 | s = s[:-1] + s2 | 130 | break |
142 | # skip comments | 131 | w = s.strip() |
143 | if s[0] == '#': | 132 | # skip empty lines |
144 | continue | 133 | if not w: |
145 | feeder(lineno, s, abs_fn, statements) | 134 | continue |
135 | s = s.rstrip() | ||
136 | while s[-1] == '\\': | ||
137 | s2 = f.readline().rstrip() | ||
138 | lineno = lineno + 1 | ||
139 | if (not s2 or s2 and s2[0] != "#") and s[0] == "#" : | ||
140 | 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)) | ||
141 | s = s[:-1] + s2 | ||
142 | # skip comments | ||
143 | if s[0] == '#': | ||
144 | continue | ||
145 | feeder(lineno, s, abs_fn, statements) | ||
146 | 146 | ||
147 | # DONE WITH PARSING... time to evaluate | 147 | # DONE WITH PARSING... time to evaluate |
148 | data.setVar('FILE', abs_fn) | 148 | data.setVar('FILE', abs_fn) |