Logo Search packages:      
Sourcecode: zope-cps-portaltransforms version File versions  Download package

def PortalTransforms::MimeTypesRegistry::MimeTypesRegistry::lookupExtension (   self,
  filename 
)

Lookup for imimetypes object matching filename

Filename maybe a file name like 'content.txt' or an extension
like 'rest'

Return an imimetype object associated with the file's
extension or None

XXX Changed by Nuxeo for types like tar.gz, which is different from a
plain tar file and is not just a gzip'ed file; even the Mimetype tool
makes a difference between x-tar files and x-gtar files.
Combinations not in 'cps_suffix_map' are considered to be nothing but
gzip'ed files (for instance) using the same mimetype.

Definition at line 148 of file MimeTypesRegistry.py.

00148                                        :
        """Lookup for imimetypes object matching filename

        Filename maybe a file name like 'content.txt' or an extension
        like 'rest'

        Return an imimetype object associated with the file's
        extension or None

        XXX Changed by Nuxeo for types like tar.gz, which is different from a
        plain tar file and is not just a gzip'ed file; even the Mimetype tool
        makes a difference between x-tar files and x-gtar files.
        Combinations not in 'cps_suffix_map' are considered to be nothing but
        gzip'ed files (for instance) using the same mimetype.
        """
        if filename.rfind('.') != -1:
            base, ext = splitext(filename)
            ext = ext[1:] # remove the dot
            while cps_suffix_map.has_key(ext):
                base, prevext = splitext(base)
                if not prevext:
                    break
                prevext = prevext[1:] # remove the dot
                if prevext in cps_suffix_map[ext]:
                    # both extensions mean something else than a single one
                    ext = '%s.%s' % (prevext, ext)
                else:
                    # this previous suffix don't map to a different mimetype
                    # but this is supposed to be more specific.
                    ext = prevext
        else:
            ext = filename
        # XXX Nuxeo: the rest of that method was removed in version 1.0.4
        # and above
        return self.extensions.get(ext)

    def _classifiers(self):


Generated by  Doxygen 1.6.0   Back to index