Skip to content

Commit 9dd88ff

Browse files
committed
scripts/augeas/gen-nutupsconf-aug.py.in: fix ResourceWarnings about unclosed file descriptors [networkupstools#3256]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 54c9e42 commit 9dd88ff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

scripts/augeas/gen-nutupsconf-aug.py.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ if __name__ == '__main__':
141141
defRow = re.findall(r'"([^"]*)",?', varDefine)
142142
if (len(defRow) == 1):
143143
variableNames.append(defRow[0])
144+
defFd.close()
144145
else:
145146
# Remove quotes
146147
variableNames.append(row[1].replace('"', '').lstrip())
148+
fd.close()
147149

148150
# Filter multiply defined variables
149151
variableNames = sortUnique(variableNames)
@@ -160,6 +162,7 @@ if __name__ == '__main__':
160162

161163
# 2.1/ Search for the pattern to replace
162164
outputText = tplFd.read()
165+
tplFd.close()
163166
outputText = outputText.replace('@SPECIFIC_DRV_VARS@', specificVars)
164167

165168
# 3/ Output final lens
@@ -168,3 +171,4 @@ if __name__ == '__main__':
168171
else:
169172
outFd = open(outputFilename, mode='w', encoding='utf-8')
170173
outFd.write(outputText)
174+
outFd.close()

0 commit comments

Comments
 (0)