##// END OF EJS Templates
core.magics.execution: use pathlib
Blazej Michalik -
Show More
@@ -40,6 +40,7 b' from IPython.utils.timing import clock, clock2'
40 from warnings import warn
40 from warnings import warn
41 from logging import error
41 from logging import error
42 from io import StringIO
42 from io import StringIO
43 from pathlib import Path
43
44
44 if sys.version_info > (3,8):
45 if sys.version_info > (3,8):
45 from ast import Module
46 from ast import Module
@@ -362,8 +363,7 b' class ExecutionMagics(Magics):'
362 print('\n*** Profile stats marshalled to file',\
363 print('\n*** Profile stats marshalled to file',\
363 repr(dump_file)+'.',sys_exit)
364 repr(dump_file)+'.',sys_exit)
364 if text_file:
365 if text_file:
365 with open(text_file, 'w') as pfile:
366 Path(text_file).write_text(output)
366 pfile.write(output)
367 print('\n*** Profile printout saved to text file',\
367 print('\n*** Profile printout saved to text file',\
368 repr(text_file)+'.',sys_exit)
368 repr(text_file)+'.',sys_exit)
369
369
@@ -724,7 +724,7 b' class ExecutionMagics(Magics):'
724 sys.argv = [filename] + args # put in the proper filename
724 sys.argv = [filename] + args # put in the proper filename
725
725
726 if 'n' in opts:
726 if 'n' in opts:
727 name = os.path.splitext(os.path.basename(filename))[0]
727 name = Path(filename).stem
728 else:
728 else:
729 name = '__main__'
729 name = '__main__'
730
730
General Comments 0
You need to be logged in to leave comments. Login now