# 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
    container_args = []
    if param.longflag:
        container_args.append(param.longflag)
    elif param.flag:
        container_args.append(param.flag)
    else:
        return []

    folderModel = ModelImporter.model('folder')
    instance = folderModel.load(folder, level=AccessType.WRITE, user=user)
    if not instance:
        raise RestException('Invalid Folder id (%s).' % (str(folder)))

    # Output Binding !!
    path = VolumePath(value)
    container_args.append(path)
    ref = reference.copy()
    ref['identifier'] = param.identifier()
    result_hooks.append(GirderUploadVolumePathToFolder(
        path, folder, upload_kwargs={'reference': json.dumps(ref)}))

    return container_args


def _add_indexed_input_param(param, args, user, token, templateParams=None):
    value = _parseParamValue(param, args[param.identifier()], user, token)

    if is_on_girder(param):
        # Bindings
        return _to_file_volume(param, value), value['name']

# 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

    container_args = []
    if param.longflag:
        container_args.append(param.longflag)
    elif param.flag:
        container_args.append(param.flag)
    else:
        return []

    folderModel = ModelImporter.model('folder')
    instance = folderModel.load(folder, level=AccessType.WRITE, user=user)
    if not instance:
        raise RestException('Invalid Folder id (%s).' % (str(folder)))

    # Output Binding !!
    path = VolumePath(value)
    container_args.append(path)
    ref = reference.copy()
    ref['identifier'] = param.identifier()
    result_hooks.append(GirderUploadVolumePathToFolder(
        path, folder, upload_kwargs={'reference': json.dumps(ref)}))

    return container_args


def _add_indexed_input_param(param, args, user, token, templateParams=None):
    value = _parseParamValue(param, args[param.identifier()], user, token)

    if is_on_girder(param):
        # Bindings
        return _to_file_volume(param, value), value['name']

    if is_girder_api(param):