From 73c485eba780f57d7b1b6316dab4b06d35c3e96c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 9 Jan 2011 07:42:37 -0500 Subject: [PATCH] Cleanup extension overrides in get_css.py. --- posts/get_css/get_css.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/posts/get_css/get_css.py b/posts/get_css/get_css.py index 7b5baa1..d4d3b36 100755 --- a/posts/get_css/get_css.py +++ b/posts/get_css/get_css.py @@ -147,6 +147,10 @@ class CSSReplacer (object): 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: @@ -163,12 +167,12 @@ class CSSReplacer (object): _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)) -- 2.26.2