def _create_values_provider(self, values_config, type, constant):
        if constant:
            return NoneValuesProvider()

        if self._is_plain_server_file():
            return FilesProvider(self._list_files_dir, self.file_type,
                                 self.file_extensions)

        if (type != 'list') and (type != PARAM_TYPE_MULTISELECT):
            return NoneValuesProvider()

        if is_empty(values_config):
            return EmptyValuesProvider()

        if isinstance(values_config, list):
            return ConstValuesProvider(values_config)

        elif 'script' in values_config:
            script = values_config['script']

            if '${' not in script:
                return ScriptValuesProvider(script)

            return DependantScriptValuesProvider(script,
                                                 self._parameters_supplier)

        else:
            message = 'Unsupported "values" format for ' + self.name
            raise Exception(message)
    def _create_values_provider(self, values_config, type, constant):
        if constant:
            return NoneValuesProvider()

        if self._is_plain_server_file():
            return FilesProvider(self._list_files_dir, self.file_type,
                                 self.file_extensions)

        if (type in [PARAM_TYPE_MULTISELECT, PARAM_TYPE_LIST]):

            if is_empty(values_config):
                return EmptyValuesProvider()

            if isinstance(values_config, list):
                return ConstValuesProvider(values_config)

            if PARAM_TYPE_DEPENDANT_LIST in values_config:
                return DependantValuesProvider(
                    self.name, values_config[PARAM_TYPE_DEPENDANT_LIST],
                    self._parameters_supplier)

            if 'script' in values_config:
                script = replace_auth_vars(values_config['script'],
                                           self._username, self._audit_name)
                if '${' not in script:
                    return ScriptValuesProvider(script)

                return DependantScriptValuesProvider(script,
                                                     self._parameters_supplier)

        elif (type in ["text"]):
            if is_empty(values_config):
                return NoneValuesProvider()

            if 'script' in values_config:
                script = values_config['script']

                if '${' not in script:
                    return ScriptValuesProvider(script)

                return DependantScriptValuesProvider(script,
                                                     self._parameters_supplier)
        else:
            return NoneValuesProvider()

        message = 'Unsupported "values" format for ' + self.name
        raise Exception(message)
    def _create_values_provider(self, values_config, type, constant):
        if constant:
            return NoneValuesProvider()

        if self._is_plain_server_file():
            return FilesProvider(self._list_files_dir, self.file_type,
                                 self.file_extensions,
                                 self.excluded_files_matcher)

        if (type != 'list') and (type != PARAM_TYPE_MULTISELECT) and (
                type != PARAM_TYPE_EDITABLE_LIST):
            return NoneValuesProvider()

        if is_empty(values_config):
            return EmptyValuesProvider()

        if isinstance(values_config, list):
            return ConstValuesProvider(values_config)

        elif 'script' in values_config:
            original_script = values_config['script']
            has_variables = ('${' in original_script)

            script = replace_auth_vars(original_script, self._username,
                                       self._audit_name)
            shell = read_bool_from_config('shell',
                                          values_config,
                                          default=not has_variables)

            if '${' not in script:
                return ScriptValuesProvider(script, shell)

            return DependantScriptValuesProvider(script,
                                                 self._parameters_supplier,
                                                 shell)

        else:
            message = 'Unsupported "values" format for ' + self.name
            raise Exception(message)
    def _create_values_provider(self, values_config, type, constant):
        if constant or ((type != 'list') and (type != 'multiselect')):
            return NoneValuesProvider()

        if is_empty(values_config):
            return EmptyValuesProvider()

        if isinstance(values_config, list):
            return ConstValuesProvider(values_config)

        elif 'script' in values_config:
            script = values_config['script']

            if '${' not in script:
                return ScriptValuesProvider(script)

            return DependantScriptValuesProvider(script, self._parameters_supplier)

        else:
            message = 'Unsupported "values" format for ' + self.name
            raise Exception(message)