def get_mimetype(self, path): path = self._resolve_path(path) # Not a file ? if not isfile(path): return "application/x-not-regular-file" name = basename(path) return get_mimetype(name)
def get_mimetype(self, path): path = self._resolve_path(path) # Not a file ? if not isfile(path): return 'application/x-not-regular-file' name = basename(path) return get_mimetype(name)
def get_mimetype(self, uri): """Try to guess the mimetype for a resource, given the resource itself and its name. See `itools.fs.base.get_mimetype` for complete description. """ g_file = self._get_g_file(uri) # TODO Use magic numbers too (like file -i). # Not a file ? if not _is_file(g_file): return 'application/x-not-regular-file' # Find out the filename extension scheme, authority, path, query, fragment = urlsplit(uri) path = unquote(path) name = basename(path) return get_mimetype(name)