No. It is to check for extensions like:
'.eps.bz2': 'image/x-bzeps'
On Saturday, 12 January 2013 14:44:40 UTC-6, Bob St John wrote:
>
> def contenttype(filename, default='text/plain'):
> """
> Returns the Content-Type string matching extension of the given
> filename.
> """
> i = filename.rfind('.')
> if i>=0:
> default = CONTENT_TYPE.get(filename[i:].lower(),default)
> j = filename.rfind('.', 0, i)
> if j>=0:
> default = CONTENT_TYPE.get(filename[j:].lower(),default)
> if default.startswith('text/'):
> default += '; charset=utf-8'
> return default
>
> I do not understand why the line:
>
> default = CONTENT_TYPE.get(filename[j:].lower(), default)
>
> is not instead:
>
> default = CONTENT_TYPE.get(filename[j:i].lower(), default)
>
> Is the purpose of this second rfind not to check for a possible double
> extension... filename.ext.ext ?
>
> I apologize in advance if I am completely missing something here in such a
> simple function.
>
>
--