diff --git a/IPython/utils/genutils.py b/IPython/utils/genutils.py index ed4f799..d27db86 100644 --- a/IPython/utils/genutils.py +++ b/IPython/utils/genutils.py @@ -614,10 +614,18 @@ def filefind(filename, path_dirs=None): ------- Raises :exc:`IOError` or returns absolute path to file. """ + + # If paths are quoted, abspath gets confused, strip them... + filename = filename.strip('"').strip("'") + # If the input is an absolute path, just check it exists + if os.path.isabs(filename) and os.path.isfile(filename): + return filename + if path_dirs is None: path_dirs = ("",) elif isinstance(path_dirs, basestring): path_dirs = (path_dirs,) + for path in path_dirs: if path == '.': path = os.getcwd() testname = expand_path(os.path.join(path, filename)) @@ -883,6 +891,7 @@ def get_ipython_dir(): """ ipdir_def = '.ipython' home_dir = get_home_dir() + #import pdb; pdb.set_trace() # dbg ipdir = os.environ.get( 'IPYTHON_DIR', os.environ.get( 'IPYTHONDIR', os.path.join(home_dir, ipdir_def) diff --git a/IPython/utils/tests/test_genutils.py b/IPython/utils/tests/test_genutils.py index 21fd622..678cd95 100644 --- a/IPython/utils/tests/test_genutils.py +++ b/IPython/utils/tests/test_genutils.py @@ -55,7 +55,7 @@ env = os.environ TEST_FILE_PATH = split(abspath(__file__))[0] TMP_TEST_DIR = tempfile.mkdtemp() HOME_TEST_DIR = join(TMP_TEST_DIR, "home_test_dir") -IP_TEST_DIR = join(HOME_TEST_DIR,'_ipython') +IP_TEST_DIR = join(HOME_TEST_DIR,'.ipython') # # Setup/teardown functions/decorators # @@ -88,19 +88,17 @@ def setup_environment(): each testfunction needs a pristine environment. """ global oldstuff, platformstuff - oldstuff = (env.copy(), os.name, genutils.get_home_dir, IPython.__file__,) + oldstuff = (env.copy(), os.name, genutils.get_home_dir, IPython.__file__) if os.name == 'nt': platformstuff = (wreg.OpenKey, wreg.QueryValueEx,) - # Remove both spellings of env variables if present - env.pop('IPYTHON_DIR', None) - env.pop('IPYTHONDIR', None) - + def teardown_environment(): """Restore things that were remebered by the setup_environment function """ (oldenv, os.name, genutils.get_home_dir, IPython.__file__,) = oldstuff + for key in env.keys(): if key not in oldenv: del env[key] @@ -233,6 +231,8 @@ def test_get_ipython_dir_2(): """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.""" genutils.get_home_dir = lambda : "someplace" os.name = "posix" + env.pop('IPYTHON_DIR', None) + env.pop('IPYTHONDIR', None) ipdir = genutils.get_ipython_dir() nt.assert_equal(ipdir, os.path.join("someplace", ".ipython"))