##// END OF EJS Templates
Finish getting rid of unquote_filename......
Antony Lee -
Show More
@@ -77,7 +77,8 b" def unquote_filename(name, win32=(sys.platform=='win32')):"
77 This function has been deprecated and should not be used any more:
77 This function has been deprecated and should not be used any more:
78 unquoting is now taken care of by :func:`IPython.utils.process.arg_split`.
78 unquoting is now taken care of by :func:`IPython.utils.process.arg_split`.
79 """
79 """
80 warn("'unquote_filename' is deprecated", DeprecationWarning)
80 warn("'unquote_filename' is deprecated since IPython 5.0 and should not "
81 "be used anymore", DeprecationWarning)
81 if win32:
82 if win32:
82 if name.startswith(("'", '"')) and name.endswith(("'", '"')):
83 if name.startswith(("'", '"')) and name.endswith(("'", '"')):
83 name = name[1:-1]
84 name = name[1:-1]
@@ -98,18 +99,13 b' def get_py_filename(name, force_win32=None):'
98
99
99 If the given name is not a file, it adds '.py' and searches again.
100 If the given name is not a file, it adds '.py' and searches again.
100 Raises IOError with an informative message if the file isn't found.
101 Raises IOError with an informative message if the file isn't found.
101
102 On Windows, apply Windows semantics to the filename. In particular, remove
103 any quoting that has been applied to it. This option can be forced for
104 testing purposes.
105 """
102 """
106
103
107 name = os.path.expanduser(name)
104 name = os.path.expanduser(name)
108 if force_win32 is None:
105 if force_win32 is not None:
109 win32 = (sys.platform == 'win32')
106 warn("The 'force_win32' argument to 'get_py_filename' is deprecated "
110 else:
107 "since IPython 5.0 and should not be used anymore",
111 win32 = force_win32
108 DeprecationWarning)
112 name = unquote_filename(name, win32=win32)
113 if not os.path.isfile(name) and not name.endswith('.py'):
109 if not os.path.isfile(name) and not name.endswith('.py'):
114 name += '.py'
110 name += '.py'
115 if os.path.isfile(name):
111 if os.path.isfile(name):
@@ -305,25 +305,20 b' def test_not_writable_ipdir():'
305 @with_environment
305 @with_environment
306 def test_get_py_filename():
306 def test_get_py_filename():
307 os.chdir(TMP_TEST_DIR)
307 os.chdir(TMP_TEST_DIR)
308 for win32 in (True, False):
308 with make_tempfile('foo.py'):
309 with make_tempfile('foo.py'):
309 nt.assert_equal(path.get_py_filename('foo.py'), 'foo.py')
310 nt.assert_equal(path.get_py_filename('foo.py', force_win32=win32), 'foo.py')
310 nt.assert_equal(path.get_py_filename('foo'), 'foo.py')
311 nt.assert_equal(path.get_py_filename('foo', force_win32=win32), 'foo.py')
311 with make_tempfile('foo'):
312 with make_tempfile('foo'):
312 nt.assert_equal(path.get_py_filename('foo'), 'foo')
313 nt.assert_equal(path.get_py_filename('foo', force_win32=win32), 'foo')
313 nt.assert_raises(IOError, path.get_py_filename, 'foo.py')
314 nt.assert_raises(IOError, path.get_py_filename, 'foo.py', force_win32=win32)
314 nt.assert_raises(IOError, path.get_py_filename, 'foo')
315 nt.assert_raises(IOError, path.get_py_filename, 'foo', force_win32=win32)
315 nt.assert_raises(IOError, path.get_py_filename, 'foo.py')
316 nt.assert_raises(IOError, path.get_py_filename, 'foo.py', force_win32=win32)
316 true_fn = 'foo with spaces.py'
317 true_fn = 'foo with spaces.py'
317 with make_tempfile(true_fn):
318 with make_tempfile(true_fn):
318 nt.assert_equal(path.get_py_filename('foo with spaces'), true_fn)
319 nt.assert_equal(path.get_py_filename('foo with spaces', force_win32=win32), true_fn)
319 nt.assert_equal(path.get_py_filename('foo with spaces.py'), true_fn)
320 nt.assert_equal(path.get_py_filename('foo with spaces.py', force_win32=win32), true_fn)
320 nt.assert_raises(IOError, path.get_py_filename, '"foo with spaces.py"')
321 if win32:
321 nt.assert_raises(IOError, path.get_py_filename, "'foo with spaces.py'")
322 nt.assert_equal(path.get_py_filename('"foo with spaces.py"', force_win32=True), true_fn)
323 nt.assert_equal(path.get_py_filename("'foo with spaces.py'", force_win32=True), true_fn)
324 else:
325 nt.assert_raises(IOError, path.get_py_filename, '"foo with spaces.py"', force_win32=False)
326 nt.assert_raises(IOError, path.get_py_filename, "'foo with spaces.py'", force_win32=False)
327
322
328 @onlyif_unicode_paths
323 @onlyif_unicode_paths
329 def test_unicode_in_filename():
324 def test_unicode_in_filename():
General Comments 0
You need to be logged in to leave comments. Login now