예제 #1
0
def _guess_cover(files):
    """Return the filename within <files> that is the most likely to be the
    cover of an archive using some simple heuristics.
    """
    filehandler.alphanumeric_sort(files)
    ext_re = re.compile(r'\.(jpg|jpeg|png|gif|tif|tiff|bmp)\s*$', re.I)
    front_re = re.compile('(cover|front)', re.I)
    images = filter(ext_re.search, files)
    candidates = filter(front_re.search, images)
    candidates = [c for c in candidates if 'back' not in c.lower()]
    if candidates:
        return candidates[0]
    if images:
        return images[0]
    return None
예제 #2
0
def _guess_cover(files):
    """Return the filename within <files> that is the most likely to be the
    cover of an archive using some simple heuristics.
    """
    filehandler.alphanumeric_sort(files)
    ext_re = re.compile(r'\.(jpg|jpeg|png|gif|tif|tiff)\s*$', re.I)
    front_re = re.compile('(cover|front)', re.I)
    images = filter(ext_re.search, files)
    candidates = filter(front_re.search, images)
    candidates = [c for c in candidates if 'back' not in c.lower()]
    if candidates:
        return candidates[0]
    if images:
        return images[0]
    return None
예제 #3
0
def _guess_cover(files):
    """Return the filename within <files> that is the most likely to be the
    cover of an archive using some simple heuristics.
    """
    filehandler.alphanumeric_sort(files)

    ext_re = re.compile('\.('+'|'.join(get_supported_format_extensions_preg())+')\s*$', re.I)

    front_re = re.compile('(cover|front)', re.I)
    images = filter(ext_re.search, files)
    candidates = filter(front_re.search, images)
    candidates = [c for c in candidates if 'back' not in c.lower()]
    if candidates:
        return candidates[0]
    if images:
        return images[0]
    return None