def merge_raw_operation_definition(context, raw_operation, our_operation, interface_name, presentation, type_name): if not isinstance(our_operation._raw, dict): # Convert short form to long form raw_operation['implementation'] = deepcopy_with_locators( our_operation._raw) return # Add/merge inputs our_operation_inputs = our_operation.inputs if our_operation_inputs: # Make sure we have the dict if ('inputs' not in raw_operation) or (raw_operation.get('inputs') is None): raw_operation['inputs'] = OrderedDict() merge_raw_input_definitions(context, raw_operation['inputs'], our_operation_inputs, interface_name, our_operation._name, presentation, type_name) # Override the description if our_operation._raw.get('description') is not None: raw_operation['description'] = deepcopy_with_locators( our_operation._raw['description']) # Add/merge implementation if our_operation._raw.get('implementation') is not None: if raw_operation.get('implementation') is not None: merge(raw_operation['implementation'], deepcopy_with_locators(our_operation._raw['implementation'])) else: raw_operation['implementation'] = \ deepcopy_with_locators(our_operation._raw['implementation'])
def merge_raw_input_definition(context, the_raw_input, our_input, interface_name, operation_name, presentation, type_name): # Check if we changed the type # TODO: allow a sub-type? input_type1 = the_raw_input.get('type') input_type2 = our_input.type if input_type1 != input_type2: if operation_name is not None: context.validation.report( 'interface %s "%s" changes operation input "%s.%s" type from "%s" to "%s" in "%s"' % (type_name, interface_name, operation_name, our_input._name, input_type1, input_type2, presentation._fullname), locator=input_type2._locator, level=Issue.BETWEEN_TYPES) else: context.validation.report( 'interface %s "%s" changes input "%s" type from "%s" to "%s" in "%s"' % (type_name, interface_name, our_input._name, input_type1, input_type2, presentation._fullname), locator=input_type2._locator, level=Issue.BETWEEN_TYPES) # Merge merge(the_raw_input, our_input._raw)
def merge_raw_input_definition(context, the_raw_input, our_input, interface_name, operation_name, presentation, type_name): # Check if we changed the type input_type1_name = the_raw_input.get('type') input_type1 = get_type_by_name(context, input_type1_name, 'data_types') if input_type1 is None: input_type1 = get_primitive_data_type(input_type1_name) input_type2 = our_input._get_type(context) if input_type1 is not input_type2 and \ (not hasattr(input_type1, '_is_descendant') or \ not input_type1._is_descendant(context, input_type2)): if operation_name is not None: context.validation.report( u'type "{0}" is not a descendant of overridden type "{1}" for input "{2}" of ' u'operation {3} "{4}.{5}" in {6}'.format( our_input.type, input_type1_name, our_input._name, type_name, interface_name, operation_name, presentation._fullname), locator=our_input._locator, level=Issue.BETWEEN_TYPES) else: context.validation.report( u'type "{0}" is not a descendant of overridden type "{1}" for input "{2}" of ' u'interface {3} "{4}" in {5}'.format(our_input.type, input_type1_name, our_input._name, type_name, interface_name, presentation._fullname), locator=our_input._locator, level=Issue.BETWEEN_TYPES) # Merge merge(the_raw_input, our_input._raw)
def convert_requirement_interface_definitions_from_type_to_raw_template( context, raw_requirement, # pylint: disable=invalid-name interface_definitions): if not interface_definitions: return if 'interfaces' not in raw_requirement: raw_requirement['interfaces'] = OrderedDict() for interface_name, interface_definition in interface_definitions.iteritems( ): raw_interface = convert_interface_definition_from_type_to_raw_template( context, interface_definition) if interface_name in raw_requirement['interfaces']: merge(raw_requirement['interfaces'][interface_name], raw_interface) else: raw_requirement['interfaces'][interface_name] = raw_interface
def merge_raw_property_definition(context, presentation, raw_property_definition, our_property_definition, field_name, property_name): # Check if we changed the type # TODO: allow a sub-type? type1 = raw_property_definition.get('type') type2 = our_property_definition.type if type1 != type2: context.validation.report( 'override changes type from "%s" to "%s" for property "%s" in "%s"' % (type1, type2, property_name, presentation._fullname), locator=presentation._get_child_locator(field_name, property_name), level=Issue.BETWEEN_TYPES) merge(raw_property_definition, our_property_definition._raw)
def merge_raw_parameter_definition(context, presentation, raw_property_definition, our_property_definition, field_name, property_name): # Check if we changed the parameter type type1_name = raw_property_definition.get('type') type1 = get_type_by_name(context, type1_name, 'data_types') if type1 is None: type1 = get_primitive_data_type(type1_name) our_property_definition._reset_method_cache() type2 = our_property_definition._get_type(context) if (type1 is not type2) and \ (not hasattr(type1, '_is_descendant') or not type1._is_descendant(context, type2)): context.validation.report( u'property definition type "{0}" is not a descendant of overridden ' u'property definition type "{1}"' \ .format(our_property_definition.type, type1_name), locator=presentation._get_child_locator(field_name, property_name), level=Issue.BETWEEN_TYPES) merge(raw_property_definition, our_property_definition._raw)