mirror of
https://github.com/python/cpython.git
synced 2025-09-25 09:50:37 +00:00
* posixpath.py: Fix border cases in normpath ('/foo/..' should return '/')
* ftplib.py: made cwd() use 'CDUP' when dirname is '..' * FL.py: added new constant FL_PLACE_FULLSCREEN
This commit is contained in:
parent
f1dc566328
commit
df5638662d
4 changed files with 14 additions and 6 deletions
|
@ -336,7 +336,11 @@ class FTP:
|
||||||
|
|
||||||
# Change to a directory
|
# Change to a directory
|
||||||
def cwd(self, dirname):
|
def cwd(self, dirname):
|
||||||
self.voidcmd('CWD ' + dirname)
|
if dirname == '..':
|
||||||
|
cmd = 'CDUP'
|
||||||
|
else:
|
||||||
|
cmd = 'CWD ' + dirname
|
||||||
|
self.voidcmd(cmd)
|
||||||
|
|
||||||
# Retrieve the size of a file
|
# Retrieve the size of a file
|
||||||
def size(self, filename):
|
def size(self, filename):
|
||||||
|
|
|
@ -27,6 +27,7 @@ PLACE_ASPECT = 2
|
||||||
PLACE_MOUSE = 3
|
PLACE_MOUSE = 3
|
||||||
PLACE_CENTER = 4
|
PLACE_CENTER = 4
|
||||||
PLACE_POSITION = 5
|
PLACE_POSITION = 5
|
||||||
|
FL_PLACE_FULLSCREEN = 6
|
||||||
FIND_INPUT = 0
|
FIND_INPUT = 0
|
||||||
FIND_AUTOMATIC = 1
|
FIND_AUTOMATIC = 1
|
||||||
FIND_MOUSE = 2
|
FIND_MOUSE = 2
|
||||||
|
|
|
@ -27,6 +27,7 @@ PLACE_ASPECT = 2
|
||||||
PLACE_MOUSE = 3
|
PLACE_MOUSE = 3
|
||||||
PLACE_CENTER = 4
|
PLACE_CENTER = 4
|
||||||
PLACE_POSITION = 5
|
PLACE_POSITION = 5
|
||||||
|
FL_PLACE_FULLSCREEN = 6
|
||||||
FIND_INPUT = 0
|
FIND_INPUT = 0
|
||||||
FIND_AUTOMATIC = 1
|
FIND_AUTOMATIC = 1
|
||||||
FIND_MOUSE = 2
|
FIND_MOUSE = 2
|
||||||
|
|
|
@ -270,10 +270,12 @@ def expandvars(path):
|
||||||
|
|
||||||
def normpath(path):
|
def normpath(path):
|
||||||
import string
|
import string
|
||||||
|
# Treat initial slashes specially
|
||||||
|
slashes = ''
|
||||||
|
while path[:1] == '/':
|
||||||
|
slashes = slashes + '/'
|
||||||
|
path = path[1:]
|
||||||
comps = string.splitfields(path, '/')
|
comps = string.splitfields(path, '/')
|
||||||
# If the path begins with '/', comps[0] is '', which we leave alone;
|
|
||||||
# we also leave leading multiple slashes alone for compatibility
|
|
||||||
# with certain networking naming schemes using //host/path
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(comps):
|
while i < len(comps):
|
||||||
if comps[i] == '.':
|
if comps[i] == '.':
|
||||||
|
@ -287,6 +289,6 @@ def normpath(path):
|
||||||
else:
|
else:
|
||||||
i = i+1
|
i = i+1
|
||||||
# If the path is now empty, substitute '.'
|
# If the path is now empty, substitute '.'
|
||||||
if not comps:
|
if not comps and not slashes:
|
||||||
comps.append('.')
|
comps.append('.')
|
||||||
return string.joinfields(comps, '/')
|
return slashes + string.joinfields(comps, '/')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue