##// END OF EJS Templates
Use pathlib in packaging.py, io.py, and gen_latex_symbols.py...
Justin Palmer -
Show More
@@ -11,6 +11,7 b''
11 import re
11 import re
12 import shlex
12 import shlex
13 import sys
13 import sys
14 from Pathlib import Path
14
15
15 from pathlib import Path
16 from pathlib import Path
16 from IPython.core.magic import Magics, magics_class, line_magic
17 from IPython.core.magic import Magics, magics_class, line_magic
@@ -14,6 +14,7 b' import sys'
14 import tempfile
14 import tempfile
15 import warnings
15 import warnings
16 from warnings import warn
16 from warnings import warn
17 from pathlib import Path
17
18
18 from IPython.utils.decorators import undoc
19 from IPython.utils.decorators import undoc
19 from .capture import CapturedIO, capture_output
20 from .capture import CapturedIO, capture_output
@@ -204,8 +205,8 b" def temp_pyfile(src, ext='.py'):"
204 (filename, open filehandle)
205 (filename, open filehandle)
205 It is the caller's responsibility to close the open file and unlink it.
206 It is the caller's responsibility to close the open file and unlink it.
206 """
207 """
207 fname = tempfile.mkstemp(ext)[1]
208 fname = Path(tempfile.mkstemp(ext)[1])
208 with open(fname,'w') as f:
209 with fname.open('w') as f:
209 f.write(src)
210 f.write(src)
210 f.flush()
211 f.flush()
211 return fname
212 return fname
@@ -9,7 +9,7 b''
9 #
9 #
10 # The original mapping of latex symbols to unicode comes from the `latex_symbols.jl` files from Julia.
10 # The original mapping of latex symbols to unicode comes from the `latex_symbols.jl` files from Julia.
11
11
12 import os, sys
12 from pathlib import Path
13
13
14 # Import the Julia LaTeX symbols
14 # Import the Julia LaTeX symbols
15 print('Importing latex_symbols.js from Julia...')
15 print('Importing latex_symbols.js from Julia...')
@@ -80,9 +80,8 b' s += """'
80 reverse_latex_symbol = { v:k for k,v in latex_symbols.items()}
80 reverse_latex_symbol = { v:k for k,v in latex_symbols.items()}
81 """
81 """
82
82
83 fn = os.path.join('..','IPython','core','latex_symbols.py')
83 fn = Path('..', 'IPython', 'core', 'latex_symbols.py')
84 print("Writing the file: %s" % fn)
84 print("Writing the file: %s" % str(fn))
85 with open(fn, 'w', encoding='utf-8') as f:
85 fn.write_text(s, encoding='utf-8')
86 f.write(s)
87
86
88
87
General Comments 0
You need to be logged in to leave comments. Login now