[merge] cleanup from -catbox branch

This commit is contained in:
S.Çağlar Onur
2007-05-22 16:23:57 +00:00
parent f0768ded70
commit 37c2743f6f
+6 -5
View File
@@ -282,17 +282,17 @@ class FTPRangeHandler(urllib2.FTPHandler):
path, attrs = urllib.splitattr(req.get_selector()) path, attrs = urllib.splitattr(req.get_selector())
dirs = path.split('/') dirs = path.split('/')
dirs = map(urllib.unquote, dirs) dirs = map(urllib.unquote, dirs)
dirs, file = dirs[:-1], dirs[-1] dirs, f = dirs[:-1], dirs[-1]
if dirs and not dirs[0]: if dirs and not dirs[0]:
dirs = dirs[1:] dirs = dirs[1:]
try: try:
fw = self.connect_ftp('', '', host, port, dirs) fw = self.connect_ftp('', '', host, port, dirs)
type = file and 'I' or 'D' t = f and 'I' or 'D'
for attr in attrs: for attr in attrs:
attr, value = urllib.splitattr(attr) attr, value = urllib.splitattr(attr)
if attr.lower() == 'type' and \ if attr.lower() == 'type' and \
value in ('a', 'A', 'i', 'I', 'd', 'D'): value in ('a', 'A', 'i', 'I', 'd', 'D'):
type = value.upper() t = value.upper()
rawr = req.headers.get('Range', None) rawr = req.headers.get('Range', None)
if rawr: if rawr:
@@ -300,7 +300,7 @@ class FTPRangeHandler(urllib2.FTPHandler):
else: else:
rest = 0 rest = 0
fp, retrlen = fw.retrfile(file, type, rest) fp, retrlen = fw.retrfile(f, t, rest)
fb, lb = rest, retrlen fb, lb = rest, retrlen
if retrlen is None or retrlen == 0: if retrlen is None or retrlen == 0:
@@ -327,7 +327,7 @@ class FTPRangeHandler(urllib2.FTPHandler):
raise IOError, (_('ftp error'), msg), sys.exc_info()[2] raise IOError, (_('ftp error'), msg), sys.exc_info()[2]
def connect_ftp(self, user, passwd, host, port, dirs): def connect_ftp(self, user, passwd, host, port, dirs):
fw = ftpwrapper('', '', host, port, dirs) fw = ftpwrapper(user, passwd, host, port, dirs)
return fw return fw
class ftpwrapper(urllib.ftpwrapper): class ftpwrapper(urllib.ftpwrapper):
@@ -355,6 +355,7 @@ class ftpwrapper(urllib.ftpwrapper):
if str(reason)[:3] == '501': if str(reason)[:3] == '501':
# workaround for REST not suported error # workaround for REST not suported error
fp, retrlen = self.retrfile(file, type) fp, retrlen = self.retrfile(file, type)
# WTF? No global (RangeableFileObject) found. RangeableFileObject only defined in urlgrabber / caglar
fp = RangeableFileObject(fp, (rest,'')) fp = RangeableFileObject(fp, (rest,''))
return (fp, retrlen) return (fp, retrlen)
elif str(reason)[:3] != '550': elif str(reason)[:3] != '550':