Example #1
0
    def load_builders(self, force: bool = False) -> None:
        """
        Loads all builders found in preview_generator.preview.builder module
        :return: None
        """
        if force or not self.builders_loaded:
            builder_folder = get_builder_folder_name()
            builder_modules = get_builder_modules(builder_folder)
            for module_name in builder_modules:
                try:
                    import_builder_module(module_name)
                except Exception:
                    self.logger.critical("Builder {} failed to be loaded".format(module_name))

            from preview_generator.preview.generic_preview import PreviewBuilder  # nopep8

            builders = sorted(
                get_subclasses_recursively(PreviewBuilder), key=lambda x: x.weight, reverse=True
            )

            for cls in builders:
                if is_abstract(cls):
                    # INFO - G.M - 2021-06-22 - Skip abstract classes from loaded builders
                    pass
                elif cls.__name__ in ("ImagePreviewBuilderPillow", "ImagePreviewBuilderIMConvert"):
                    self.logger.info(
                        "{} builder is deprecated and is not registered by default. "
                        "Consider using ImagePreviewBuilderIMConvert instead".format(cls.__name__)
                    )
                else:
                    self.register_builder(cls, overwrite=False)

            self.builders_loaded = True
    def load_builders(self, force: bool = False) -> None:
        """
        Loads all builders found in preview_generator.preview.builder module
        :return: None
        """
        if force or not self.builders_loaded:
            builder_folder = get_builder_folder_name()
            builder_modules = get_builder_modules(builder_folder)

            for module_name in builder_modules:
                import_builder_module(module_name)

            from preview_generator.preview.generic_preview import PreviewBuilder  # nopep8
            for cls in get_subclasses_recursively(PreviewBuilder):
                self.register_builder(cls)

            self.builders_loaded = True
Example #3
0
def check_dependencies() -> None:
    builder_folder = get_builder_folder_name()
    builder_modules = get_builder_modules(builder_folder)

    for module_name in builder_modules:
        import_builder_module(module_name)

    for builder in get_subclasses_recursively(PreviewBuilder):
        try:
            builder.check_dependencies()
            dependencies = builder.dependencies_versions()
            if dependencies is not None:
                print("✓", builder.__name__, dependencies)
        except BuilderDependencyNotFound as e:
            print("✗", builder.__name__, "is missing a dependency: ", e.__str__())
        except NotImplementedError:
            print("✗", builder.__name__, "Skipped: not implemented")