Downloads the files, adjusting the extension if necessary, and
update reference to point to the local copies.
"""
+ _mime_overrides = {
+ 'image/jpeg': '.jpg',
+ }
+
def __init__(self, href=None, data_dir=None, data_url=None):
self._href = href
if data_dir == None:
_url = os.path.basename(url)
root,ext = os.path.splitext(_url)
info,data = get_page(full_url)
- expected_ext = guess_extension(info.gettype())
- for _from,_to in [('.jpe', '.jpg')]:
- if expected_ext == _from:
- LOG.debug('wierd exception %s from type %s'
- % (_from, info.gettype()))
- expected_ext = _to
+ _type = info.gettype()
+ if _type in self._mime_overrides:
+ expected_ext = self._mime_overrides[_type]
+ else:
+ expected_ext = guess_extension(_type)
+ LOG.critical('XX %s\t%s' % (_type, expected_ext))
if expected_ext != ext:
LOG.info('changing extension for %s from %s to %s'
% (full_url, ext, expected_ext))