def __new__()

in aws_lambda_builders/workflow.py [0:0]


    def __new__(mcs, name, bases, class_dict):
        """
        Add the builder to registry when loading the class
        """

        cls = type.__new__(mcs, name, bases, class_dict)

        # We don't want to register the base classes, so we simply return here.
        # Also, skip further steps if the class is marked for testing
        if cls.__name__ == "BaseWorkflow" or cls.__TESTING__:
            return cls

        # Validate class variables

        # All classes must provide a name
        if not isinstance(cls.NAME, str):
            raise ValueError("Workflow must provide a valid name")

        # All workflows must express their capabilities
        if not isinstance(cls.CAPABILITY, Capability):
            raise ValueError("Workflow '{}' must register valid capabilities".format(cls.NAME))

        # All workflows must define supported values for build in source
        if not isinstance(cls.BUILD_IN_SOURCE_SUPPORT, BuildInSourceSupport):
            raise ValueError("Workflow '{}' must define supported values for build in source".format(cls.NAME))

        # All workflows must define default build directory
        if not isinstance(cls.DEFAULT_BUILD_DIR, BuildDirectory):
            raise ValueError("Workflow '{}' must define default build directory".format(cls.NAME))

        LOG.debug("Registering workflow '%s' with capability '%s'", cls.NAME, cls.CAPABILITY)
        DEFAULT_REGISTRY[cls.CAPABILITY] = cls

        return cls