File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ def normcase(s):
2323 res = res + c
2424 return string .lower (res )
2525
26+
2627# Return wheter a path is absolute.
2728# Trivial in Posix, harder on the Mac or MS-DOS.
2829# For DOS it is absolute if it starts with a slash or backslash (current
@@ -34,6 +35,8 @@ def isabs(s):
3435 return s != '' and s [:1 ] in '/\\ '
3536
3637
38+ # Join two (or more) paths.
39+
3740def join (a , * p ):
3841 path = a
3942 for b in p :
@@ -244,13 +247,16 @@ def expanduser(path):
244247 while i < n and path [i ] not in '/\\ ' :
245248 i = i + 1
246249 if i == 1 :
247- try :
248- drive = os .environ ['HOMEDRIVE' ]
249- except KeyError :
250- drive = ''
251- if not os .environ .has_key ('HOMEPATH' ):
250+ if os .environ .has_key ('HOME' ):
251+ userhome = os .environ ['HOME' ]
252+ elif not os .environ .has_key ('HOMEPATH' ):
252253 return path
253- userhome = join (drive , os .environ ['HOMEPATH' ])
254+ else :
255+ try :
256+ drive = os .environ ['HOMEDRIVE' ]
257+ except KeyError :
258+ drive = ''
259+ userhome = join (drive , os .environ ['HOMEPATH' ])
254260 else :
255261 return path
256262 return userhome + path [i :]
You can’t perform that action at this time.
0 commit comments