##// END OF EJS Templates
setup: switch to with open as...
timeless -
r28418:121d2571 default
parent child Browse files
Show More
@@ -207,11 +207,9 b" elif os.path.exists('.hg_archival.txt'):"
207 207 version = kw.get('node', '')[:12]
208 208
209 209 if version:
210 f = open("mercurial/__version__.py", "w")
211 f.write('# this file is autogenerated by setup.py\n')
212 f.write('version = "%s"\n' % version)
213 f.close()
214
210 with open("mercurial/__version__.py", "w") as f:
211 f.write('# this file is autogenerated by setup.py\n')
212 f.write('version = "%s"\n' % version)
215 213
216 214 try:
217 215 from mercurial import __version__
@@ -345,9 +343,8 b' class buildhgextindex(Command):'
345 343
346 344 def run(self):
347 345 if os.path.exists(self._indexfilename):
348 f = open(self._indexfilename, 'w')
349 f.write('# empty\n')
350 f.close()
346 with open(self._indexfilename, 'w') as f:
347 f.write('# empty\n')
351 348
352 349 # here no extension enabled, disabled() lists up everything
353 350 code = ('import pprint; from mercurial import extensions; '
@@ -356,11 +353,10 b' class buildhgextindex(Command):'
356 353 if err:
357 354 raise DistutilsExecError(err)
358 355
359 f = open(self._indexfilename, 'w')
360 f.write('# this file is autogenerated by setup.py\n')
361 f.write('docs = ')
362 f.write(out)
363 f.close()
356 with open(self._indexfilename, 'w') as f:
357 f.write('# this file is autogenerated by setup.py\n')
358 f.write('docs = ')
359 f.write(out)
364 360
365 361 class buildhgexe(build_ext):
366 362 description = 'compile hg.exe from mercurial/exewrapper.c'
@@ -373,10 +369,9 b' class buildhgexe(build_ext):'
373 369 self.compiler.dll_libraries = [] # no -lmsrvc90
374 370 hv = sys.hexversion
375 371 pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xff)
376 f = open('mercurial/hgpythonlib.h', 'wb')
377 f.write('/* this file is autogenerated by setup.py */\n')
378 f.write('#define HGPYTHONLIB "%s"\n' % pythonlib)
379 f.close()
372 with open('mercurial/hgpythonlib.h', 'wb') as f:
373 f.write('/* this file is autogenerated by setup.py */\n')
374 f.write('#define HGPYTHONLIB "%s"\n' % pythonlib)
380 375 objects = self.compiler.compile(['mercurial/exewrapper.c'],
381 376 output_dir=self.build_temp)
382 377 dir = os.path.dirname(self.get_ext_fullpath('dummy'))
@@ -476,9 +471,8 b' class hginstallscripts(install_scripts):'
476 471 libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):]
477 472
478 473 for outfile in self.outfiles:
479 fp = open(outfile, 'rb')
480 data = fp.read()
481 fp.close()
474 with open(outfile, 'rb') as fp:
475 data = fp.read()
482 476
483 477 # skip binary files
484 478 if b'\0' in data:
@@ -493,9 +487,8 b' class hginstallscripts(install_scripts):'
493 487 continue
494 488
495 489 data = data.replace(b'@LIBDIR@', libdir.encode(libdir_escape))
496 fp = open(outfile, 'wb')
497 fp.write(data)
498 fp.close()
490 with open(outfile, 'wb') as fp:
491 fp.write(data)
499 492
500 493 cmdclass = {'build': hgbuild,
501 494 'build_mo': hgbuildmo,
General Comments 0
You need to be logged in to leave comments. Login now