# Path: slicer_cli_web/ctk_cli_adjustment.py
# class CLIParameter(ctk_cli.module.CLIParameter):
#     EXTERNAL_TYPES = ctk_cli.module.CLIParameter.EXTERNAL_TYPES.copy()
#     TYPES = ctk_cli.module.CLIParameter.VALUE_TYPES + tuple(EXTERNAL_TYPES)
#     def parse(cls, elementTree):  # noqa
# def _ctkCliParse(cls, elementTree):  # noqa


import io
from .ctk_cli_adjustment import CLIModule

SLICER_SUPPORTED_TYPES = set(['boolean', 'integer', 'float', 'double', 'string',
                              'integer-vector', 'float-vector', 'double-vector', 'string-vector',
                              'integer-enumeration', 'float-enumeration', 'double-enumeration',
                              'string-enumeration',
                              'region'] + list(SLICER_TYPE_TO_GIRDER_MODEL_MAP.keys()))


def generate_description(clim):
    """Create CLI description string."""
    str_description = ['Description: <br/><br/>' + clim.description]

    if clim.version:
        str_description.append('Version: ' + clim.version)

    if clim.license:
        str_description.append('License: ' + clim.license)

    if clim.contributor:
        str_description.append('Author(s): ' + clim.contributor)

    if clim.acknowledgements:
        str_description.append('Acknowledgements: ' + clim.acknowledgements)

    return '<br/><br/>'.join(str_description)


def as_model(cliXML):
    """Parses cli xml spec."""
    stream = io.BytesIO(cliXML if isinstance(cliXML, bytes) else cliXML.encode('utf8'))

# Path: slicer_cli_web/ctk_cli_adjustment.py
# class CLIParameter(ctk_cli.module.CLIParameter):
#     EXTERNAL_TYPES = ctk_cli.module.CLIParameter.EXTERNAL_TYPES.copy()
#     TYPES = ctk_cli.module.CLIParameter.VALUE_TYPES + tuple(EXTERNAL_TYPES)
#     def parse(cls, elementTree):  # noqa
# def _ctkCliParse(cls, elementTree):  # noqa


# Path: slicer_cli_web/cli_utils.py
import io
from .ctk_cli_adjustment import CLIModule


SLICER_SUPPORTED_TYPES = set(['boolean', 'integer', 'float', 'double', 'string',
                              'integer-vector', 'float-vector', 'double-vector', 'string-vector',
                              'integer-enumeration', 'float-enumeration', 'double-enumeration',
                              'string-enumeration',
                              'region'] + list(SLICER_TYPE_TO_GIRDER_MODEL_MAP.keys()))


def generate_description(clim):
    """Create CLI description string."""
    str_description = ['Description: <br/><br/>' + clim.description]

    if clim.version:
        str_description.append('Version: ' + clim.version)

    if clim.license:
        str_description.append('License: ' + clim.license)

    if clim.contributor:
        str_description.append('Author(s): ' + clim.contributor)

    if clim.acknowledgements:
        str_description.append('Acknowledgements: ' + clim.acknowledgements)

    return '<br/><br/>'.join(str_description)


def as_model(cliXML):
    """Parses cli xml spec."""
    stream = io.BytesIO(cliXML if isinstance(cliXML, bytes) else cliXML.encode('utf8'))

    return CLIModule(stream=stream)