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 google.appengine.api import urlfetch
- import cgi
- import errorhandler
- import util
- log = errorhandler.ErrorHandler()
-
- def _defaultFetcher(url):
-
- try:
- r = urlfetch.fetch(url, method = urlfetch.GET)
- except urlfetch.Error:
- e = None
- log.warn(u'Error opening url=%r: %s' % (url, e), error = IOError)
-
- if r.status_code == 200:
- mimetype = 'application/octet-stream'
-
- try:
- (mimetype, params) = cgi.parse_header(r.headers['content-type'])
- encoding = params['charset']
- except KeyError:
- encoding = None
-
- 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, r.content)
- log.warn(u'Error opening url=%r: HTTP status %s' % (url, r.status_code), error = IOError)
-
-