dhunter/core/filter.py
def validate_file(self, dir_entry: os.DirEntry) -> bool:
        """Validates given DirEntry. Returns False if entry should be completely ignored,
        or True if we want to keep it for further processing.

        Ignore all zero length files. There are usually there for a purpose like .dummy etc,
        so there can be tons of it with the same name even, so by default, ignore them completely.
        Also ignore all symlinks."""

        from .log import Log

        if dir_entry.is_symlink():
            Log.vv('{name}: It is the symbolic link. Skipping.'.format(name=dir_entry.name))
            return False

        # NOTE: do not call is_file() on DirEntry. It will fail in endless
        # recursion for invalid (dead) symbolic links. os.path.isfile() works).
        if not dir_entry.is_file():
            Log.vv('{name}: This is not a file. Skipping.'.format(name=dir_entry.name))
            return False

        item_size = dir_entry.stat().st_size

        if item_size == 0:
            Log.vv('{name}: File is 0 bytes long. Skipping.'.format(name=dir_entry.name))
            return False

        if self.min_size > 0 and item_size < self.min_size:
            Log.vv('{name}: File is shorter than min size ({size}). Skipping.'.format(name=dir_entry.name,
                                                                                      size=item_size))
            return False

        if 0 < self.max_size < item_size:
            Log.vv('{name}: File is biger than max size ({size}). Skipping.'.format(name=dir_entry.name,
                                                                                    size=item_size))
            return False

        for list_item in self._file_name_blacklist:
            match = re.match(list_item, dir_entry.name)
            if match is not None:
                Log.vv('File "{name}" blacklisted by "{re}" rule. Skipping.'.format(name=dir_entry.name, re=list_item))
                return False

        return True
Validates given DirEntry. Returns False if entry should be completely ignored,
        or True if we want to keep it for further processing.

        Ignore all zero length files. There are usually there for a purpose like .dummy etc,
        so there can be tons of it with the same name even, so by default, ignore them completely.
        Also ignore all symlinks.


Ignore all zero length files. There are usually there for a purpose like .dummy etc,
so there can be tons of it with the same name even, so by default, ignore them completely.
Also ignore all symlinks.
Ignore all zero length files . There are usually there for a purpose like . dummy etc so there can be tons of it with the same name even so by default ignore them completely . Also ignore all symlinks .
def validate_file(self, dir_entry: os.DirEntry) -> bool:
        from .log import Log
        if dir_entry.is_symlink():
            Log.vv('{name}: It is the symbolic link. Skipping.'.format(name=dir_entry.name))
            return False
        if not dir_entry.is_file():
            Log.vv('{name}: This is not a file. Skipping.'.format(name=dir_entry.name))
            return False
        item_size = dir_entry.stat().st_size
        if item_size == 0:
            Log.vv('{name}: File is 0 bytes long. Skipping.'.format(name=dir_entry.name))
            return False
        if self.min_size > 0 and item_size < self.min_size:
            Log.vv('{name}: File is shorter than min size ({size}). Skipping.'.format(name=dir_entry.name,
                                                                                      size=item_size))
            return False
        if 0 < self.max_size < item_size:
            Log.vv('{name}: File is biger than max size ({size}). Skipping.'.format(name=dir_entry.name,
                                                                                    size=item_size))
            return False
        for list_item in self._file_name_blacklist:
            match = re.match(list_item, dir_entry.name)
            if match is not None:
                Log.vv('File "{name}" blacklisted by "{re}" rule. Skipping.'.format(name=dir_entry.name, re=list_item))
                return False
        return True
def validate_file ( self , dir_entry : os . DirEntry ) -> bool : from . log import Log if dir_entry . is_symlink ( ) : Log . vv ( '{name}: It is the symbolic link. Skipping.' . format ( name = dir_entry . name ) ) return False if not dir_entry . is_file ( ) : Log . vv ( '{name}: This is not a file. Skipping.' . format ( name = dir_entry . name ) ) return False item_size = dir_entry . stat ( ) . st_size if item_size == 0 : Log . vv ( '{name}: File is 0 bytes long. Skipping.' . format ( name = dir_entry . name ) ) return False if self . min_size > 0 and item_size < self . min_size : Log . vv ( '{name}: File is shorter than min size ({size}). Skipping.' . format ( name = dir_entry . name , size = item_size ) ) return False if 0 < self . max_size < item_size : Log . vv ( '{name}: File is biger than max size ({size}). Skipping.' . format ( name = dir_entry . name , size = item_size ) ) return False for list_item in self . _file_name_blacklist : match = re . match ( list_item , dir_entry . name ) if match is not None : Log . vv ( 'File "{name}" blacklisted by "{re}" rule. Skipping.' . format ( name = dir_entry . name , re = list_item ) ) return False return True
Validates given DirEntry.
Validates given DirEntry .
"""Validates given DirEntry. Returns False if entry should be completely ignored,
        or True if we want to keep it for further processing.

        Ignore all zero length files. There are usually there for a purpose like .dummy etc,
        so there can be tons of it with the same name even, so by default, ignore them completely.
        Also ignore all symlinks.""" # NOTE: do not call is_file() on DirEntry. It will fail in endless # recursion for invalid (dead) symbolic links. os.path.isfile() works).
self
dir_entry
os.DirEntry