sconsDoxy: Restructure code: close file in case of exception.

Up to now, the file was opened, then DoxyfileParse() was invoked, then the file
was closed. If DoxyfileParse() throws an exception, the file would not be
closed. The new solution auto-closes the file in any case.
This commit is contained in:
Tanjeff-N. Moos 2022-07-31 16:22:56 +02:00 committed by Ichthyostega
parent 035a38b177
commit ebf51f227c

View file

@ -107,9 +107,8 @@ def DoxyfileParse(file_contents, conf_dir, data=None):
if nextfile in data[key]:
raise Exception("recursive @INCLUDE in Doxygen config: " + nextfile)
data[key].append(nextfile)
fh = open(nextfile, "r")
DoxyfileParse(fh.read(), conf_dir, data)
fh.close()
with open(nextfile, "r") as fh:
DoxyfileParse(fh.read(), conf_dir, data)
else:
append_data(data, key, new_data, token)
new_data = True