Mercurial > public > mercurial-scm > hg
comparison mercurial/byterange.py @ 8366:0bf0045000b5
some modernization cleanups, forward compatibility
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Wed, 13 May 2009 14:08:39 +0200 |
parents | 8fee8ff13d37 |
children | 59acf64995d2 |
comparison
equal
deleted
inserted
replaced
8365:94e91205d9b6 | 8366:0bf0045000b5 |
---|---|
21 | 21 |
22 import os | 22 import os |
23 import stat | 23 import stat |
24 import urllib | 24 import urllib |
25 import urllib2 | 25 import urllib2 |
26 import rfc822 | 26 import email.utils |
27 | 27 |
28 try: | 28 try: |
29 from cStringIO import StringIO | 29 from cStringIO import StringIO |
30 except ImportError, msg: | 30 except ImportError, msg: |
31 from StringIO import StringIO | 31 from StringIO import StringIO |
212 host = req.get_host() | 212 host = req.get_host() |
213 file = req.get_selector() | 213 file = req.get_selector() |
214 localfile = urllib.url2pathname(file) | 214 localfile = urllib.url2pathname(file) |
215 stats = os.stat(localfile) | 215 stats = os.stat(localfile) |
216 size = stats[stat.ST_SIZE] | 216 size = stats[stat.ST_SIZE] |
217 modified = rfc822.formatdate(stats[stat.ST_MTIME]) | 217 modified = email.utils.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 urllib2.URLError('file not on local host') | 222 raise urllib2.URLError('file not on local host') |