Skip to content

factory

dandy.intel.factory

IntelFactory

intel_to_json_inc_ex_schema classmethod

Source code in dandy/intel/factory.py
@classmethod
def intel_to_json_inc_ex_schema(
    cls,
    intel: BaseIntel | Type[BaseIntel],
    include: IncEx | None = None,
    exclude: IncEx | None = None,
) -> Dict:
    inc_ex_kwargs = {'include': include, 'exclude': exclude}

    json_schema = cls._run_for_intel_class_or_object(
        intel=intel,
        class_func=intel.model_json_inc_ex_schema,
        object_func=intel.model_object_json_inc_ex_schema,
        **inc_ex_kwargs,
    )

    cls._validate_json_schema_or_error(json_schema)

    return json_schema

json_str_to_intel_object classmethod

Source code in dandy/intel/factory.py
@classmethod
def json_str_to_intel_object(
    cls, json_str: str, intel: BaseIntel | Type[BaseIntel]
) -> BaseIntel:
    return cls._run_for_intel_class_or_object(
        intel=intel,
        class_func=intel.model_validate_json,
        object_func=intel.model_validate_json_and_copy,
        json_data=json_str,
    )

callable_signature_to_intel_class classmethod

Source code in dandy/intel/factory.py
@classmethod
def callable_signature_to_intel_class(cls, callable_: Callable) -> Type[BaseIntel]:

    typed_kwargs = get_typed_kwargs_from_callable_signature(callable_)

    return cls.typed_kwargs_to_intel_class(
        f'{callable_.__name__}Intel',
        typed_kwargs,
    )

simple_json_schema_to_intel_class classmethod

Source code in dandy/intel/factory.py
@classmethod
def simple_json_schema_to_intel_class(
    cls,
    simple_json_schema: dict | str,
    class_name: str = 'SimpleJsonSchemaIntel',
) -> Type[BaseIntel]:
    typed_kwargs = get_typed_kwargs_from_simple_json_schema(
        simple_json_schema,
    )

    return cls.typed_kwargs_to_intel_class(
        class_name,
        typed_kwargs,
    )

typed_kwargs_to_intel_class staticmethod

Source code in dandy/intel/factory.py
@staticmethod
def typed_kwargs_to_intel_class(
    intel_class_name: str, typed_kwargs: TypedKwargs
) -> Type[BaseIntel]:
    return create_model(intel_class_name, __base__=BaseIntel, **typed_kwargs)