Bug 1108294 - Modernize AccEventGen.py; r=froydnj

I/O handling in AccEventGen.py is old school. Let's use context
managers. Let's also fix some minor style foo.

--HG--
extra : rebase_source : 70a2a7c344042e1ac187282fdda32cea194aa51b
This commit is contained in:
Gregory Szorc 2014-12-06 15:26:37 -08:00
Родитель 312651fc98
Коммит bc694279e4
1 изменённых файлов: 8 добавлений и 10 удалений

Просмотреть файл

@ -208,7 +208,7 @@ def main():
o.add_option('--cachedir', dest='cachedir', default=None,
help="Directory in which to cache lex/parse tables.")
global options
(options, filenames) = o.parse_args()
options, filenames = o.parse_args()
if len(filenames) != 1:
o.error("Exactly one config filename is needed.")
filename = filenames[0]
@ -224,17 +224,15 @@ def main():
conf = readConfigFile(filename)
if options.stub_output is not None:
if options.stub_output:
makeutils.targets.append(options.stub_output)
outfd = open(options.stub_output, 'w')
print_cpp_file(outfd, conf)
outfd.close()
if options.makedepend_output is not None:
with open(options.stub_output, 'w') as fh:
print_cpp_file(fh, conf)
if options.makedepend_output:
makeutils.writeMakeDependOutput(options.makedepend_output)
if options.header_output is not None:
outfd = open(options.header_output, 'w')
print_header_file(outfd, conf)
outfd.close()
if options.header_output:
with open(options.header_output, 'w') as fh:
print_header_file(fh, conf)
if __name__ == '__main__':
main()