comparison mercurial/byterange.py @ 667:31a9aa890016

A number of minor fixes to problems that pychecker found. # HG changeset patch # User mark.williamson@cl.cam.ac.uk # Node ID 55d38977b7f2e73b8c1090179928ac96c8922b90 # Parent b3bba126b04ab2f24274a1bcf5a224c6317c8e0d A number of minor fixes to problems that pychecker found.
author mark.williamson@cl.cam.ac.uk
date Sun, 10 Jul 2005 16:01:11 -0800
parents 7f5ce4bbdd7b
children 6513ba7d858a
comparison
equal deleted inserted replaced
666:0100a43788ca 667:31a9aa890016
217 modified = rfc822.formatdate(stats[stat.ST_MTIME]) 217 modified = rfc822.formatdate(stats[stat.ST_MTIME])
218 mtype = mimetypes.guess_type(file)[0] 218 mtype = mimetypes.guess_type(file)[0]
219 if host: 219 if host:
220 host, port = urllib.splitport(host) 220 host, port = urllib.splitport(host)
221 if port or socket.gethostbyname(host) not in self.get_names(): 221 if port or socket.gethostbyname(host) not in self.get_names():
222 raise URLError('file not on local host') 222 raise urllib2.URLError('file not on local host')
223 fo = open(localfile,'rb') 223 fo = open(localfile,'rb')
224 brange = req.headers.get('Range',None) 224 brange = req.headers.get('Range',None)
225 brange = range_header_to_tuple(brange) 225 brange = range_header_to_tuple(brange)
226 assert brange != () 226 assert brange != ()
227 if brange: 227 if brange:
247 from urllib import splitport, splituser, splitpasswd, splitattr, \ 247 from urllib import splitport, splituser, splitpasswd, splitattr, \
248 unquote, addclosehook, addinfourl 248 unquote, addclosehook, addinfourl
249 import ftplib 249 import ftplib
250 import socket 250 import socket
251 import sys 251 import sys
252 import ftplib
253 import mimetypes 252 import mimetypes
254 import mimetools 253 import mimetools
255 254
256 class FTPRangeHandler(urllib2.FTPHandler): 255 class FTPRangeHandler(urllib2.FTPHandler):
257 def ftp_open(self, req): 256 def ftp_open(self, req):
273 passwd = unquote(passwd or '') 272 passwd = unquote(passwd or '')
274 273
275 try: 274 try:
276 host = socket.gethostbyname(host) 275 host = socket.gethostbyname(host)
277 except socket.error, msg: 276 except socket.error, msg:
278 raise URLError(msg) 277 raise urllib2.URLError(msg)
279 path, attrs = splitattr(req.get_selector()) 278 path, attrs = splitattr(req.get_selector())
280 dirs = path.split('/') 279 dirs = path.split('/')
281 dirs = map(unquote, dirs) 280 dirs = map(unquote, dirs)
282 dirs, file = dirs[:-1], dirs[-1] 281 dirs, file = dirs[:-1], dirs[-1]
283 if dirs and not dirs[0]: 282 if dirs and not dirs[0]: