How to use the scandir.scandir.walk function in scandir

To help you get started, we’ve selected a few scandir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CouchPotato / CouchPotatoServer / couchpotato / core / plugins / View on Github external
folder = sp(folder)

        if not folder or not os.path.isdir(folder):
            log.error('Folder doesn\'t exists: %s', folder)
            return {}

        # Get movie "master" files
        movie_files = {}
        leftovers = []

        # Scan all files of the folder if no files are set
        if not files:
            check_file_date = True
                files = []
                for root, dirs, walk_files in scandir.walk(folder, followlinks=True):
                    files.extend([sp(os.path.join(toUnicode(root), toUnicode(filename))) for filename in walk_files])

                    # Break if CP wants to shut down
                    if self.shuttingDown():

                log.error('Failed getting files from %s: %s', (folder, traceback.format_exc()))

            log.debug('Found %s files to scan and group in %s', (len(files), folder))
            check_file_date = False
            files = [sp(x) for x in files]

        for file_path in files: