eric6/eric6_doc.py

changeset 7785
9978016560ec
parent 7781
607a6098cb44
child 7836
2f0d208b8137
equal deleted inserted replaced
7784:3257703e10c5 7785:9978016560ec
279 outputDir = os.getcwd() 279 outputDir = os.getcwd()
280 outputDir = os.path.abspath(outputDir) 280 outputDir = os.path.abspath(outputDir)
281 281
282 if stylesheetFile: 282 if stylesheetFile:
283 try: 283 try:
284 sf = open(stylesheetFile, "r", encoding="utf-8") 284 with open(stylesheetFile, "r", encoding="utf-8") as sf:
285 stylesheet = sf.read() 285 stylesheet = sf.read()
286 sf.close()
287 except IOError: 286 except IOError:
288 sys.stderr.write( 287 sys.stderr.write(
289 "The CSS stylesheet '{0}' does not exist\n".format( 288 "The CSS stylesheet '{0}' does not exist\n".format(
290 stylesheetFile)) 289 stylesheetFile))
291 sys.stderr.write("Disabling CSS usage.\n") 290 sys.stderr.write("Disabling CSS usage.\n")
396 ): 395 ):
397 continue 396 continue
398 397
399 # generate output 398 # generate output
400 try: 399 try:
401 out = open(f, "w", encoding="utf-8", newline=newline) 400 with open(f, "w", encoding="utf-8",
402 out.write(doc) 401 newline=newline) as out:
403 out.close() 402 out.write(doc)
404 except IOError as v: 403 except IOError as v:
405 sys.stderr.write("{0} error: {1}\n".format(file, v[1])) 404 sys.stderr.write("{0} error: {1}\n".format(file, v[1]))
406 else: 405 else:
407 sys.stdout.write("{0} ok\n".format(f)) 406 sys.stdout.write("{0} ok\n".format(f))
408 407

eric ide

mercurial