def validate(actor, name, value): _is_type(tuple)(actor, name, value) if not value: raise WrongAttributeTypeError( 'Actor {} attribute {} should contain at least one item of the type {}'.format(actor, name, value_type)) if not all([isinstance(item, value_type) for item in value]): raise WrongAttributeTypeError( 'Actor {} attribute {} should contain only values of the type {}'.format(actor, name, value_type)) return value
def validate(actor, name, value): _is_type(tuple)(actor, name, value) if not value: raise WrongAttributeTypeError( 'Actor {} attribute {} should at least one item of type {}'. format(actor, name, value_type)) if not all(map(lambda item: isinstance(item, value_type), value)): raise WrongAttributeTypeError( 'Actor {} attribute {} should contain only value of type {}'. format(actor, name, value_type))
def _is_tag_tuple(actor, name, value): _is_type(tuple)(actor, name, value) if not all([True] + list( map(lambda item: isinstance(item, type) and issubclass(item, Tag), value))): raise WrongAttributeTypeError( 'Actor {} attribute {} should contain only Tags'.format( actor, name))
def _is_api_tuple(actor, name, value): if isinstance(value, type) and issubclass(value, WorkflowAPI): _lint_warn(actor, name, "Apis") value = (value,) _is_type(tuple)(actor, name, value) if not all([True] + [isinstance(item, type) and issubclass(item, WorkflowAPI) for item in value]): raise WrongAttributeTypeError( 'Actor {} attribute {} should contain only WorkflowAPIs'.format(actor, name)) return value
def _is_dialog_tuple(actor, name, value): if isinstance(value, Dialog): _lint_warn(actor, name, "Dialogs") value = (value,) _is_type(tuple)(actor, name, value) if not all([True] + [isinstance(item, Dialog) for item in value]): raise WrongAttributeTypeError( 'Actor {} attribute {} should contain only Dialogs'.format(actor, name)) return value
def _is_model_tuple(actor, name, value): if isinstance(value, type) and issubclass(value, Model): _lint_warn(actor, name, "Models") value = value, _is_type(tuple)(actor, name, value) if not all([True] + list(map(lambda item: isinstance(item, type) and issubclass(item, Model), value))): raise WrongAttributeTypeError( 'Actor {} attribute {} should contain only Models'.format(actor, name)) return value
def _is_tag_tuple(actor, name, value): if isinstance(value, type) and issubclass(value, Tag): logging.getLogger("leapp.linter").warning( "Actor %s field %s should be a tuple of Tags", actor, name) value = value, _is_type(tuple)(actor, name, value) if not all([True] + list( map(lambda item: isinstance(item, type) and issubclass(item, Tag), value))): raise WrongAttributeTypeError( 'Actor {} attribute {} should contain only Tags'.format( actor, name)) return value
def validate(actor, name, value): if not isinstance(value, value_type): raise WrongAttributeTypeError('Actor {} attribute {} should be of the type {}'.format(actor, name, value_type)) return value