def handle(self, *args, **options):

        self.process_options(options)
        self.print_debug("Options: ")
        self.print_debug(options)

        subdir = re.sub(
            '[^('+re.escape(os.sep)+')]*%[^%].*',
            '',
            photos_settings.UPLOAD_TO
            ).strip(os.sep)

        from ella.photos.models import Photo
        storage = Photo().image.storage

        extensions = self.extensions or photos_settings.TYPE_EXTENSION.values()
        self.print_info('Accepted extensions: ' +str(extensions))
        photo_extension_re = re.compile(
                '(%s)$' % ('|'.join([re.escape(ex) for ex in extensions])),
                self.extensions_ic and re.IGNORECASE or 0)

        # breadth-first search
        files = []
        nodes = [subdir]
        while nodes:
            current = nodes.pop()
            self.print_debug(current % "Entering directory '%s'")
            current_dirs, current_files = storage.listdir(current)

            if not (current_dirs or current_files):
                self.print_info("Directory '%s' is empty" % current)
            else:
                nodes += [
                        '%s%s%s' % (current, os.sep, directory)
                        for directory in current_dirs]

                for current_file in current_files:
                    f = '%s%s%s' % (current, os.sep, current_file)
                    is_image = bool(photo_extension_re.search(current_file))
                    if not is_image:
                        self.print_info("File '%s' is not image" % f)
                    if is_image or self.all:
                        files.append(f)
                        self.print_debug("Appending file '%s'" % f)

            self.print_debug("Leaving directory '%s'" % current)

        photo_files_set = set(files)
        db_files_set = set([photo.image.url for photo in Photo.objects.all()])
        self.print_summarization(photo_files_set, db_files_set)

        if self.delete:
            self.delete_files(storage, photo_files_set -db_files_set)
dataset/ETHPy150Open ella/ella/ella/photos/management/commands/check_photo_files_consistence.py/Command.handle/swapped operands of `%`