home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __all__ = [
- '_defaultFetcher']
- __docformat__ = 'restructuredtext'
- __version__ = '$Id: tokenize2.py 1547 2008-12-10 20:42:26Z cthedot $'
- from cssutils import VERSION
- import encutils
- import errorhandler
- import urllib2
- import util
- log = errorhandler.ErrorHandler()
-
- def _defaultFetcher(url):
- request = urllib2.Request(url)
- request.add_header('User-agent', 'cssutils %s (http://www.cthedot.de/cssutils/)' % VERSION)
-
- try:
- res = urllib2.urlopen(request)
- except OSError:
- e = None
- log.warn(e, error = OSError)
- except (OSError, ValueError):
- e = None
- log.warn(u'ValueError, %s' % e.args[0], error = ValueError)
- except urllib2.HTTPError:
- e = None
- log.warn(u'HTTPError opening url=%r: %s %s' % (url, e.code, e.msg), error = e)
- except urllib2.URLError:
- e = None
- log.warn(u'URLError, %s' % e.reason, error = e)
-
- if res:
- (mimeType, encoding) = encutils.getHTTPInfo(res)
- if mimeType != u'text/css':
- log.error(u'Expected "text/css" mime type for url=%r but found: %r' % (url, mimeType), error = ValueError)
-
- return (encoding, res.read())
-
-