Fix ResourceWarning: unclosed file in MetaTools
This commit is contained in:
parent
698aa676e8
commit
bfde7268c3
@ -30,7 +30,7 @@ modules.sort()
|
||||
tables.sort()
|
||||
|
||||
|
||||
file = open(os.path.join(tablesDir, "__init__.py"), "w")
|
||||
with open(os.path.join(tablesDir, "__init__.py"), "w") as file:
|
||||
|
||||
file.write('''
|
||||
from __future__ import print_function, division, absolute_import
|
||||
@ -54,12 +54,11 @@ if __name__ == "__main__":
|
||||
sys.exit(doctest.testmod().failed)
|
||||
''')
|
||||
|
||||
file.close()
|
||||
|
||||
|
||||
begin = ".. begin table list\n.. code::\n"
|
||||
end = ".. end table list"
|
||||
doc = open(docFile).read()
|
||||
with open(docFile) as f:
|
||||
doc = f.read()
|
||||
beginPos = doc.find(begin)
|
||||
assert beginPos > 0
|
||||
beginPos = beginPos + len(begin) + 1
|
||||
@ -70,4 +69,5 @@ blockquote = "\n".join(" "*4 + line for line in lines) + "\n"
|
||||
|
||||
doc = doc[:beginPos] + blockquote + doc[endPos:]
|
||||
|
||||
open(docFile, "w").write(doc)
|
||||
with open(docFile, "w") as f:
|
||||
f.write(doc)
|
||||
|
Loading…
x
Reference in New Issue
Block a user