# Path: slicer_cli_web/cli_utils.py
# SLICER_TYPE_TO_GIRDER_MODEL_MAP = {
#     'image': 'file',
#     'file': 'file',
#     'item': 'item',
#     'directory': 'folder'
# }
# 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):
# def as_model(cliXML):
# def get_cli_parameters(clim):
#     def get_flag(p):
# def is_on_girder(param):
# def is_girder_api(param):


import json
import jinja2
    import uuid
from girder import logger
from girder.api.rest import RestException
from girder.constants import AccessType
from girder.exceptions import FilePathException
from girder.models.file import File
from girder.models.setting import Setting
from girder.utility.model_importer import ModelImporter
from .cli_utils import (SLICER_TYPE_TO_GIRDER_MODEL_MAP, is_girder_api, is_on_girder,
                        return_parameter_file_name)
    from girder_worker.docker.transforms.girder import (GirderFileIdToVolume,
                                                        GirderFolderIdToVolume,
                                                        GirderItemIdToVolume)
    from girder_worker.girder_plugin.constants import PluginSettings
    from .girder_worker_plugin.direct_docker_run import DirectGirderFileIdToVolume
    from .girder_worker_plugin.direct_docker_run import GirderApiUrl, GirderToken
    from girder_worker.docker.transforms import VolumePath
    from girder_worker.docker.transforms.girder import GirderUploadVolumePathToFolder
    from girder_worker.docker.transforms import VolumePath
    from girder_worker.docker.transforms.girder import GirderUploadVolumePathToFolder
    from girder_worker.docker.transforms import VolumePath
    from girder_worker.docker.transforms.girder import GirderUploadVolumePathToFolder
    primary_input_name = None

    templateParams = _populateTemplateParams(
        params, user, token, index_params, opt_params, templateParams)

    # Get primary name and reference
    for param in index_params:
        if param.channel != 'output':
            arg, name = _add_indexed_input_param(param, params, user, token)
            if (name and not primary_input_name and
                    SLICER_TYPE_TO_GIRDER_MODEL_MAP[param.typ] != 'folder'):
                primary_input_name = name
                reference['userId'] = str(user['_id'])
                value = _parseParamValue(param, params[param.identifier()], user, token)
                itemId = value['_id']
                if SLICER_TYPE_TO_GIRDER_MODEL_MAP[param.typ] == 'file':
                    reference['fileId'] = str(value['_id'])
                    itemId = value['itemId']
                reference['itemId'] = str(itemId)
                reference['uuid'] = uuidVal

    # optional params
    for param in opt_params:
        if param.channel == 'output':
            ca.extend(_add_optional_output_param(
                param, params, user, result_hooks, reference, templateParams))
        else:
            ca.extend(_add_optional_input_param(param, params, user, token, templateParams))

    if has_simple_return_file:

# Path: slicer_cli_web/cli_utils.py
# SLICER_TYPE_TO_GIRDER_MODEL_MAP = {
#     'image': 'file',
#     'file': 'file',
#     'item': 'item',
#     'directory': 'folder'
# }
# 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):
# def as_model(cliXML):
# def get_cli_parameters(clim):
#     def get_flag(p):
# def is_on_girder(param):
# def is_girder_api(param):


# Path: slicer_cli_web/prepare_task.py
import json
import jinja2
    import uuid
from girder import logger
from girder.api.rest import RestException
from girder.constants import AccessType
from girder.exceptions import FilePathException
from girder.models.file import File
from girder.models.setting import Setting
from girder.utility.model_importer import ModelImporter
from .cli_utils import (SLICER_TYPE_TO_GIRDER_MODEL_MAP, is_girder_api, is_on_girder,
                        return_parameter_file_name)
    from girder_worker.docker.transforms.girder import (GirderFileIdToVolume,
                                                        GirderFolderIdToVolume,
                                                        GirderItemIdToVolume)
    from girder_worker.girder_plugin.constants import PluginSettings
    from .girder_worker_plugin.direct_docker_run import DirectGirderFileIdToVolume
    from .girder_worker_plugin.direct_docker_run import GirderApiUrl, GirderToken
    from girder_worker.docker.transforms import VolumePath
    from girder_worker.docker.transforms.girder import GirderUploadVolumePathToFolder
    from girder_worker.docker.transforms import VolumePath
    from girder_worker.docker.transforms.girder import GirderUploadVolumePathToFolder
    from girder_worker.docker.transforms import VolumePath
    from girder_worker.docker.transforms.girder import GirderUploadVolumePathToFolder

    primary_input_name = None

    templateParams = _populateTemplateParams(
        params, user, token, index_params, opt_params, templateParams)

    # Get primary name and reference
    for param in index_params:
        if param.channel != 'output':
            arg, name = _add_indexed_input_param(param, params, user, token)
            if (name and not primary_input_name and
                    SLICER_TYPE_TO_GIRDER_MODEL_MAP[param.typ] != 'folder'):
                primary_input_name = name
                reference['userId'] = str(user['_id'])
                value = _parseParamValue(param, params[param.identifier()], user, token)
                itemId = value['_id']
                if SLICER_TYPE_TO_GIRDER_MODEL_MAP[param.typ] == 'file':
                    reference['fileId'] = str(value['_id'])
                    itemId = value['itemId']
                reference['itemId'] = str(itemId)
                reference['uuid'] = uuidVal

    # optional params
    for param in opt_params:
        if param.channel == 'output':
            ca.extend(_add_optional_output_param(
                param, params, user, result_hooks, reference, templateParams))
        else:
            ca.extend(_add_optional_input_param(param, params, user, token, templateParams))

    if has_simple_return_file:

        param_id = return_parameter_file_name + FOLDER_SUFFIX