def open(self, resource): fname = self._resolve(resource) if fname is None: raise IOError, 'File does not exist: %s.' % resource fin = file(fname, 'rb') encoding = http.get_encoding(fin) fin.close() fin = codecs.open(fname, 'rbU', encoding) fin.name = fname return fin