mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Handle more file closing with "with"
This commit is contained in:
@@ -138,11 +138,8 @@ else:
|
||||
domain + '.js'))
|
||||
|
||||
for js_file, (locale, po_file) in zip(js_files, po_files):
|
||||
infile = open(po_file, 'r')
|
||||
try:
|
||||
with open(po_file, 'r') as infile:
|
||||
catalog = read_po(infile, locale)
|
||||
finally:
|
||||
infile.close()
|
||||
|
||||
if catalog.fuzzy and not self.use_fuzzy:
|
||||
continue
|
||||
@@ -159,8 +156,7 @@ else:
|
||||
msgid = msgid[0]
|
||||
jscatalog[msgid] = message.string
|
||||
|
||||
outfile = open(js_file, 'wb')
|
||||
try:
|
||||
with open(js_file, 'wb') as outfile:
|
||||
outfile.write('Documentation.addTranslations(')
|
||||
dump(dict(
|
||||
messages=jscatalog,
|
||||
@@ -168,8 +164,6 @@ else:
|
||||
locale=str(catalog.locale)
|
||||
), outfile, sort_keys=True)
|
||||
outfile.write(');')
|
||||
finally:
|
||||
outfile.close()
|
||||
|
||||
cmdclass['compile_catalog'] = compile_catalog_plusjs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user