Given two mapping it extracts a schema evolution mapping. Returns None if no evolutions are required
        :param new_mapping: the new mapping
        :return: a new evolution mapping or None
974427
def get_diff(self, new_mapping):
        
        import copy
        result = copy.deepcopy(new_mapping)
        result.clear_properties()

        no_check_types = (BooleanField, IntegerField, FloatField, DateField, LongField, BinaryField,
                          GeoPointField, IpField)

        old_fields = set(self.properties.keys())
        new_fields = set(new_mapping.properties.keys())
        #we propagate new fields
        added = new_fields - old_fields
        if added:
            for add in added:
                result.add_property(new_mapping.properties[add])

        #we check common fields
        common_fields = new_fields & old_fields

        #removing standard data
        common_fields = [c for c in common_fields if not isinstance(new_mapping.properties[c], no_check_types)]

        for field in common_fields:
            prop = new_mapping.properties[field]
            if isinstance(prop, StringField):
                continue
            if isinstance(prop, MultiField):
                diff = prop.get_diff(self.properties[field])
                if diff:
                    result.add_property(diff)
            elif isinstance(prop, ObjectField):
                diff = self.properties[field].get_diff(prop)
                if diff:
                    result.add_property(diff)

        if len(result.properties) > 0:
            return result
        return None
1298416
def from_mapping(cls, mapping):
		
		out = cls()
		for elem, count in mapping.items():
			out._set_count(elem, count)
		return out
520340
def new(arg_name, annotated_with=None):
    
    if arg_name.startswith(_PROVIDE_PREFIX):
        binding_key_name = arg_name[_PROVIDE_PREFIX_LEN:]
        provider_indirection = provider_indirections.INDIRECTION
    else:
        binding_key_name = arg_name
        provider_indirection = provider_indirections.NO_INDIRECTION
    binding_key = binding_keys.new(binding_key_name, annotated_with)
    return ArgBindingKey(arg_name, binding_key, provider_indirection)
822517
function copyAndOffsetMapping(existingMapping) {
    var column     = getColumnAfter(existingMapping.generatedLine - 1, existingMapping.generatedColumn);
    var newMapping = {
      generated: {
        line  : existingMapping.generatedLine,
        column: column
      }
    };
    if (existingMapping.source) {
      newMapping.source   = existingMapping.source;
      newMapping.original = {
        line  : existingMapping.originalLine,
        column: existingMapping.originalColumn
      };
      if (existingMapping.name) {
        newMapping.name = existingMapping.name;
      }
    }
    generator.addMapping(newMapping);
  }
1345346
def validate_mapping(mapping):
    
    file_path = os.path.join(os.path.dirname(__file__),
                             'schemas', 'mapping.json')
    with open(file_path, 'r') as fh:
        validator = Draft4Validator(json.load(fh))
        validator.validate(mapping)
    return mapping
1146841
def new(self, name):
        
        #XXX:dc: assert that the name is somewhat sane and follows python
        # naming conventions
        next_id = 0
        cls_name = '_'.join((name, next_id))
        with open(pjoin(self.migration_home, name), "w+") as new_migration:
            print >> new_migration, migration_tmpl.format(
                cls_name=cls_name, migration_name=name)
172773
def from_mapping(cls, evidence_mapping):
        
        return cls(metadata_map=MetadataMap.from_mapping(evidence_mapping['metadataMap']),
                   copyright=evidence_mapping['copyright'],
                   id=evidence_mapping['id'],
                   terms_of_use=evidence_mapping['termsOfUse'],
                   document=evidence_mapping['document'],
                   title=evidence_mapping['title'],
                   text=evidence_mapping['text'],
                   value=evidence_mapping['value'])
317484
def rename(mapping)
      new_attributes = map do |attr|
        alias_name = mapping[attr.name]
        alias_name ? attr.aliased(alias_name) : attr
      end

      new(new_attributes)
    end
1296409
def mapped(cls, key='id', **kwargs):
    """"""
    kwargs.setdefault('metadata', {})
    kwargs['metadata']['jsonldPredicate'] = {'mapSubject': key}
    kwargs.setdefault('default', attr.Factory(list))

    def converter(value):
        """Convert mapping to a list of instances."""
        if isinstance(value, dict):
            result = []
            for k, v in iteritems(value):
                if not hasattr(cls, 'from_cwl'):
                    vv = dict(v)
                    vv[key] = k
                else:
                    vv = attr.evolve(cls.from_cwl(v), **{key: k})
                result.append(vv)
        else:
            result = value

        def fix_keys(data):
            """Fix names of keys."""
            for a in fields(cls):
                a_name = a.name.rstrip('_')
                if a_name in data:
                    yield a.name, data[a_name]

        return [
            cls(**{kk: vv
                   for kk, vv in fix_keys(v)}) if not isinstance(v, cls) else v
            for v in result
        ]

    kwargs['converter'] = converter
    return attr.ib(**kwargs)
557427
def schema(self) -> dict:
        
        if not self._merged_schema:
            log.debug("merging required dict into schema for %s", self.name)
            self._merged_schema = self._schema.copy()
            self._merged_schema.update(self._required)
        return self._merged_schema
1367289
public void evolve(SchemaOperation op) {
		//TODO this is horrible!!!
		ArrayList<Object> fV = new ArrayList<Object>(Arrays.asList(fixedValues));
		ArrayList<Object> vV = new ArrayList<Object>(Arrays.asList(variableValues));
		
		//TODO resize only once to correct size
		if (op instanceof SchemaOperation.SchemaFieldDefine) {
			SchemaOperation.SchemaFieldDefine op2 = (SchemaFieldDefine) op;
			int fieldId = op2.getField().getFieldPos();
			fV.add(fieldId, PersistentSchemaOperation.getDefaultValue(op2.getField()));
			vV.add(fieldId, null);
		}
		if (op instanceof SchemaOperation.SchemaFieldDelete) {
			SchemaOperation.SchemaFieldDelete op2 = (SchemaFieldDelete) op;
			int fieldId = op2.getField().getFieldPos();
			fV.remove(fieldId);
			vV.remove(fieldId);
		}
		fixedValues = fV.toArray(fixedValues);
		variableValues = vV.toArray(variableValues);
	}
179222
def __assert_field_mapping(self, mapping):
        
        passed_keys = set(mapping.keys())
        class_fields = set(self.FIELDS)

        if passed_keys != class_fields:
            raise ValueError('\n'.join([
                "{0} got different fields from expected".format(
                    self.__class__),
                "  got     : {0}".format(list(sorted(passed_keys))),
                "  expected: {0}".format(list(sorted(class_fields)))]))
34369
public Map<K2, V> getOrPutGetNew(K1 key1,
            Supplier<Map<K2, V>> newMapSupplier) {
        return JMMap.getOrPutGetNew(nestedMap, key1, newMapSupplier);
    }
558094
function singleToMulti(mapping) {
  const newMapping = {};
  Object.entries(mapping.mapping).forEach(m => {
    newMapping[m[0]] = [m[1]];
  });
  return {
    created: mapping.created,
    fields: [mapping.field],
    key: mapping.key,
    mapping: newMapping
  };
}
925690
def get_mappings_in_network(network_id, network_2_id=None, **kwargs):
    
    qry = db.DBSession.query(ResourceAttrMap).filter(or_(ResourceAttrMap.network_a_id == network_id, ResourceAttrMap.network_b_id == network_id))

    if network_2_id is not None:
        qry = qry.filter(or_(ResourceAttrMap.network_a_id==network_2_id, ResourceAttrMap.network_b_id==network_2_id))

    return qry.all()
189017
def new(cls, rId, reltype, target, target_mode=RTM.INTERNAL):
        
        xml = '<Relationship xmlns="%s"/>' % nsmap['pr']
        relationship = parse_xml(xml)
        relationship.rId = rId
        relationship.reltype = reltype
        relationship.target_ref = target
        relationship.targetMode = target_mode
        return relationship
1343302
def new(rId, reltype, target, target_mode=RTM.INTERNAL):
        
        xml = '<Relationship xmlns="%s"/>' % nsmap['pr']
        relationship = parse_xml(xml)
        relationship.set('Id', rId)
        relationship.set('Type', reltype)
        relationship.set('Target', target)
        if target_mode == RTM.EXTERNAL:
            relationship.set('TargetMode', RTM.EXTERNAL)
        return relationship