# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
Transforms.ColumnTypeConverter
"""


from ..utils.entrypoints import EntryPoint
from ..utils.utils import try_set, unlist


def transforms_columntypeconverter(
        column,
        data,
        output_data=None,
        model=None,
        result_type=None,
        range=None,
        **params):
    """
    **Description**
        Converts a column to a different type, using standard conversions.

    :param column: New column definition(s) (optional form:
        name:type:src) (inputs).
    :param data: Input dataset (inputs).
    :param result_type: The result type (inputs).
    :param range: For a key column, this defines the range of values
        (inputs).
    :param output_data: Transformed dataset (outputs).
    :param model: Transform model (outputs).
    """

    entrypoint_name = 'Transforms.ColumnTypeConverter'
    inputs = {}
    outputs = {}

    if column is not None:
        inputs['Column'] = try_set(
            obj=column,
            none_acceptable=False,
            is_of_type=list,
            is_column=True)
    if data is not None:
        inputs['Data'] = try_set(
            obj=data,
            none_acceptable=False,
            is_of_type=str)
    if result_type is not None:
        inputs['ResultType'] = try_set(
            obj=result_type,
            none_acceptable=True,
            is_of_type=str,
            values=[
                'I1',
                'U1',
                'I2',
                'U2',
                'I4',
                'U4',
                'I8',
                'U8',
                'R4',
                'Num',
                'R8',
                'TX',
                'Text',
                'TXT',
                'BL',
                'Bool',
                'TimeSpan',
                'TS',
                'DT',
                'DateTime',
                'DZ',
                'DateTimeZone',
                'UG',
                'U16'])
    if range is not None:
        inputs['Range'] = try_set(
            obj=range,
            none_acceptable=True,
            is_of_type=str)
    if output_data is not None:
        outputs['OutputData'] = try_set(
            obj=output_data,
            none_acceptable=False,
            is_of_type=str)
    if model is not None:
        outputs['Model'] = try_set(
            obj=model,
            none_acceptable=False,
            is_of_type=str)

    input_variables = {
        x for x in unlist(inputs.values())
        if isinstance(x, str) and x.startswith("$")}
    output_variables = {
        x for x in unlist(outputs.values())
        if isinstance(x, str) and x.startswith("$")}

    entrypoint = EntryPoint(
        name=entrypoint_name, inputs=inputs, outputs=outputs,
        input_variables=input_variables,
        output_variables=output_variables)
    return entrypoint
