Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(6)  |  Derive(0)  |  Import(0)
Return the archive type of <path> or None for non-archives.

        def archive_mime_type(path):
    """Return the archive type of  or None for non-archives."""
    try:
        if os.path.isfile(path):
            if not os.access(path, os.R_OK):
                return None
            if zipfile.is_zipfile(path):
                return ZIP
            fd = open(path, 'rb')
            magic = fd.read(4)
            fd.close()
            if tarfile.is_tarfile(path) and os.path.getsize(path) > 0:
                if magic.startswith('BZh'):
                    return BZIP2
                if magic.startswith('\037\213'):
                    return GZIP
                return TAR
            if magic == 'Rar!':
                return RAR
            if magic == '7z\xbc\xaf':
                return SEVENZIP
    except Exception:
        print '! Error while reading', path
    return None
        


src/c/o/Comix-HEAD/src/filehandler.py   Comix(Download)
                _('Could not open %s: No such file.') % path)
            return False
        self.archive_type = archive.archive_mime_type(path)
        if self.archive_type is None and not is_image_file(path) and \
          not dir_path:
                f = self._tmp_dir + name
                self._wait_on_file(f)
                if archive.archive_mime_type(f) is not None:
                    self._open_subarchive(os.path.dirname(f),
                                          os.path.basename(f))
            condition.release()
            name = dir + "/" + name
            if archive.archive_mime_type(name) is not None:
                self._open_subarchive(os.path.dirname(name), os.path.basename(name))
        os.remove(dir + "/" + path)
        for f in files[current_index + 1:]:
            path = os.path.join(arch_dir, f)
            if archive.archive_mime_type(path) is not None:
                self.open_file(path)
                return
        for f in reversed(files[:current_index]):
            path = os.path.join(arch_dir, f)
            if archive.archive_mime_type(path) is not None:
                self.open_file(path, 0)
                return

src/c/o/Comix-HEAD/src/thumbnail.py   Comix(Download)
    directory.
    """
    if archive.archive_mime_type(path) is not None:
        if create:
            return _get_new_archive_thumbnail(path, dst_dir)