Show More
@@ -41,6 +41,10 b' def _get_long_path_name(path):' | |||||
41 | """Dummy no-op.""" |
|
41 | """Dummy no-op.""" | |
42 | return path |
|
42 | return path | |
43 |
|
43 | |||
|
44 | def _writable_dir(path): | |||
|
45 | """Whether `path` is a directory, to which the user has write access.""" | |||
|
46 | return os.path.isdir(path) and os.access(path, os.W_OK) | |||
|
47 | ||||
44 | if sys.platform == 'win32': |
|
48 | if sys.platform == 'win32': | |
45 | def _get_long_path_name(path): |
|
49 | def _get_long_path_name(path): | |
46 | """Get a long path name (expand ~) on Windows using ctypes. |
|
50 | """Get a long path name (expand ~) on Windows using ctypes. | |
@@ -166,7 +170,7 b' def get_home_dir():' | |||||
166 | raised for all other OSes. |
|
170 | raised for all other OSes. | |
167 | """ |
|
171 | """ | |
168 |
|
172 | |||
169 |
isdir = |
|
173 | isdir = _writable_dir | |
170 | env = os.environ |
|
174 | env = os.environ | |
171 |
|
175 | |||
172 | # first, check py2exe distribution root directory for _ipython. |
|
176 | # first, check py2exe distribution root directory for _ipython. | |
@@ -272,7 +276,7 b' def get_xdg_dir():' | |||||
272 | This is only for posix (Linux,Unix,OS X, etc) systems. |
|
276 | This is only for posix (Linux,Unix,OS X, etc) systems. | |
273 | """ |
|
277 | """ | |
274 |
|
278 | |||
275 |
isdir = |
|
279 | isdir = _writable_dir | |
276 | env = os.environ |
|
280 | env = os.environ | |
277 |
|
281 | |||
278 | if os.name == 'posix': |
|
282 | if os.name == 'posix': | |
@@ -294,7 +298,8 b' def get_ipython_dir():' | |||||
294 |
|
298 | |||
295 | env = os.environ |
|
299 | env = os.environ | |
296 | pjoin = os.path.join |
|
300 | pjoin = os.path.join | |
297 | exists = os.path.exists |
|
301 | isdir = _writable_dir | |
|
302 | ||||
298 |
|
303 | |||
299 | ipdir_def = '.ipython' |
|
304 | ipdir_def = '.ipython' | |
300 | xdg_def = 'ipython' |
|
305 | xdg_def = 'ipython' | |
@@ -312,7 +317,7 b' def get_ipython_dir():' | |||||
312 |
|
317 | |||
313 | xdg_ipdir = pjoin(xdg_dir, xdg_def) |
|
318 | xdg_ipdir = pjoin(xdg_dir, xdg_def) | |
314 |
|
319 | |||
315 |
if |
|
320 | if isdir(xdg_ipdir) or not isdir(home_ipdir): | |
316 | ipdir = xdg_ipdir |
|
321 | ipdir = xdg_ipdir | |
317 |
|
322 | |||
318 | if ipdir is None: |
|
323 | if ipdir is None: |
General Comments 0
You need to be logged in to leave comments.
Login now