# Path: ranger/container/directory.py
# def accept_file(fobj, filters):
#     """
#     Returns True if file shall be shown, otherwise False.
#     Parameters:
#         fobj - an instance of FileSystemObject
#         filters - an array of lambdas, each expects a fobj and
#                   returns True if fobj shall be shown,
#                   otherwise False.
#     """
#     for filt in filters:
#         if filt and not filt(fobj):
#             return False
#     return True
# 
# class InodeFilterConstants(object):  # pylint: disable=too-few-public-methods
#     DIRS = 'd'
#     FILES = 'f'
#     LINKS = 'l'
# 
# Path: ranger/ext/hash.py
# def hash_chunks(filepath, h=None):
#     if not h:
#         h = sha256()
#     if isdir(filepath):
#         h.update(filepath)
#         yield h.hexdigest()
#         for fp in listdir(filepath):
#             for fp_chunk in hash_chunks(fp, h=h):
#                 yield fp_chunk
#     elif getsize(filepath) == 0:
#         yield h.hexdigest()
#     else:
#         with open(filepath, 'rb') as f:
#             # Read the file in ~64KiB chunks (multiple of sha256's block
#             # size that works well enough with HDDs and SSDs)
#             for chunk in iter(lambda: f.read(h.block_size * 1024), b''):
#                 h.update(chunk)
#                 yield h.hexdigest()


import re
    from itertools import izip_longest as zip_longest
    from itertools import zip_longest
from os.path import abspath
from ranger.container.directory import accept_file, InodeFilterConstants
from ranger.core.shared import FileManagerAware
from ranger.ext.hash import hash_chunks

    def __call__(self, fobj):
        # Turn logical AND (accept_file()) into a logical OR with the
        # De Morgan's laws.
        return not accept_file(
            fobj,
            ((lambda x, f=filt: not f(x))
             for filt
             in self.subfilters),
        )

    def __str__(self):
        return "<Filter: {comp}>".format(
            comp=" or ".join(map(str, self.subfilters)))

    def decompose(self):
        return self.subfilters


@filter_combinator("and")
class AndFilter(BaseFilter):
    def __init__(self, stack):
        self.subfilters = [stack[-2], stack[-1]]

        stack.pop()
        stack.pop()

        stack.append(self)

    def __call__(self, fobj):

# Path: ranger/container/directory.py
# def accept_file(fobj, filters):
#     """
#     Returns True if file shall be shown, otherwise False.
#     Parameters:
#         fobj - an instance of FileSystemObject
#         filters - an array of lambdas, each expects a fobj and
#                   returns True if fobj shall be shown,
#                   otherwise False.
#     """
#     for filt in filters:
#         if filt and not filt(fobj):
#             return False
#     return True
# 
# class InodeFilterConstants(object):  # pylint: disable=too-few-public-methods
#     DIRS = 'd'
#     FILES = 'f'
#     LINKS = 'l'
# 
# Path: ranger/ext/hash.py
# def hash_chunks(filepath, h=None):
#     if not h:
#         h = sha256()
#     if isdir(filepath):
#         h.update(filepath)
#         yield h.hexdigest()
#         for fp in listdir(filepath):
#             for fp_chunk in hash_chunks(fp, h=h):
#                 yield fp_chunk
#     elif getsize(filepath) == 0:
#         yield h.hexdigest()
#     else:
#         with open(filepath, 'rb') as f:
#             # Read the file in ~64KiB chunks (multiple of sha256's block
#             # size that works well enough with HDDs and SSDs)
#             for chunk in iter(lambda: f.read(h.block_size * 1024), b''):
#                 h.update(chunk)
#                 yield h.hexdigest()


# Path: ranger/core/filter_stack.py
import re
    from itertools import izip_longest as zip_longest
    from itertools import zip_longest
from os.path import abspath
from ranger.container.directory import accept_file, InodeFilterConstants
from ranger.core.shared import FileManagerAware
from ranger.ext.hash import hash_chunks


    def __call__(self, fobj):
        # Turn logical AND (accept_file()) into a logical OR with the
        # De Morgan's laws.
        return not accept_file(
            fobj,
            ((lambda x, f=filt: not f(x))
             for filt
             in self.subfilters),
        )

    def __str__(self):
        return "<Filter: {comp}>".format(
            comp=" or ".join(map(str, self.subfilters)))

    def decompose(self):
        return self.subfilters


@filter_combinator("and")
class AndFilter(BaseFilter):
    def __init__(self, stack):
        self.subfilters = [stack[-2], stack[-1]]

        stack.pop()
        stack.pop()

        stack.append(self)

    def __call__(self, fobj):

        return accept_file(fobj, self.subfilters)