##// END OF EJS Templates
don't use isdir=_writable_dir alias
MinRK -
Show More
@@ -170,7 +170,6 b' def get_home_dir():'
170 raised for all other OSes.
170 raised for all other OSes.
171 """
171 """
172
172
173 isdir = _writable_dir
174 env = os.environ
173 env = os.environ
175
174
176 # first, check py2exe distribution root directory for _ipython.
175 # first, check py2exe distribution root directory for _ipython.
@@ -182,7 +181,7 b' def get_home_dir():'
182 else:
181 else:
183 root=os.path.join(os.path.split(IPython.__file__)[0],"../../")
182 root=os.path.join(os.path.split(IPython.__file__)[0],"../../")
184 root=os.path.abspath(root).rstrip('\\')
183 root=os.path.abspath(root).rstrip('\\')
185 if isdir(os.path.join(root, '_ipython')):
184 if _writable_dir(os.path.join(root, '_ipython')):
186 os.environ["IPYKITROOT"] = root
185 os.environ["IPYKITROOT"] = root
187 return _cast_unicode(root, fs_encoding)
186 return _cast_unicode(root, fs_encoding)
188
187
@@ -216,7 +215,7 b' def get_home_dir():'
216 except KeyError:
215 except KeyError:
217 pass
216 pass
218 else:
217 else:
219 if isdir(homedir):
218 if _writable_dir(homedir):
220 return _cast_unicode(homedir, fs_encoding)
219 return _cast_unicode(homedir, fs_encoding)
221
220
222 # Now look for a local home directory
221 # Now look for a local home directory
@@ -225,7 +224,7 b' def get_home_dir():'
225 except KeyError:
224 except KeyError:
226 pass
225 pass
227 else:
226 else:
228 if isdir(homedir):
227 if _writable_dir(homedir):
229 return _cast_unicode(homedir, fs_encoding)
228 return _cast_unicode(homedir, fs_encoding)
230
229
231 # Now the users profile directory
230 # Now the users profile directory
@@ -234,7 +233,7 b' def get_home_dir():'
234 except KeyError:
233 except KeyError:
235 pass
234 pass
236 else:
235 else:
237 if isdir(homedir):
236 if _writable_dir(homedir):
238 return _cast_unicode(homedir, fs_encoding)
237 return _cast_unicode(homedir, fs_encoding)
239
238
240 # Use the registry to get the 'My Documents' folder.
239 # Use the registry to get the 'My Documents' folder.
@@ -249,7 +248,7 b' def get_home_dir():'
249 except:
248 except:
250 pass
249 pass
251 else:
250 else:
252 if isdir(homedir):
251 if _writable_dir(homedir):
253 return _cast_unicode(homedir, fs_encoding)
252 return _cast_unicode(homedir, fs_encoding)
254
253
255 # A user with a lot of unix tools in win32 may have defined $HOME.
254 # A user with a lot of unix tools in win32 may have defined $HOME.
@@ -259,7 +258,7 b' def get_home_dir():'
259 except KeyError:
258 except KeyError:
260 pass
259 pass
261 else:
260 else:
262 if isdir(homedir):
261 if _writable_dir(homedir):
263 return _cast_unicode(homedir, fs_encoding)
262 return _cast_unicode(homedir, fs_encoding)
264
263
265 # If all else fails, raise HomeDirError
264 # If all else fails, raise HomeDirError
@@ -276,14 +275,13 b' def get_xdg_dir():'
276 This is only for posix (Linux,Unix,OS X, etc) systems.
275 This is only for posix (Linux,Unix,OS X, etc) systems.
277 """
276 """
278
277
279 isdir = _writable_dir
280 env = os.environ
278 env = os.environ
281
279
282 if os.name == 'posix':
280 if os.name == 'posix':
283 # Linux, Unix, AIX, OS X
281 # Linux, Unix, AIX, OS X
284 # use ~/.config if not set OR empty
282 # use ~/.config if not set OR empty
285 xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config')
283 xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config')
286 if xdg and isdir(xdg):
284 if xdg and _writable_dir(xdg):
287 return _cast_unicode(xdg, fs_encoding)
285 return _cast_unicode(xdg, fs_encoding)
288
286
289 return None
287 return None
@@ -298,7 +296,6 b' def get_ipython_dir():'
298
296
299 env = os.environ
297 env = os.environ
300 pjoin = os.path.join
298 pjoin = os.path.join
301 isdir = _writable_dir
302
299
303
300
304 ipdir_def = '.ipython'
301 ipdir_def = '.ipython'
@@ -317,7 +314,7 b' def get_ipython_dir():'
317
314
318 xdg_ipdir = pjoin(xdg_dir, xdg_def)
315 xdg_ipdir = pjoin(xdg_dir, xdg_def)
319
316
320 if isdir(xdg_ipdir) or not isdir(home_ipdir):
317 if _writable_dir(xdg_ipdir) or not _writable_dir(home_ipdir):
321 ipdir = xdg_ipdir
318 ipdir = xdg_ipdir
322
319
323 if ipdir is None:
320 if ipdir is None:
General Comments 0
You need to be logged in to leave comments. Login now