Yields merge rules as key-value pairs, in which the first element is a JSON path as a tuple, and the second element
    is a list of merge properties whose values are `true`.
343248
def _get_merge_rules(properties, path=None):
    
    if path is None:
        path = ()

    for key, value in properties.items():
        new_path = path + (key,)
        types = _get_types(value)

        # `omitWhenMerged` supersedes all other rules.
        # See http://standard.open-contracting.org/1.1-dev/en/schema/merging/#omit-when-merged
        if value.get('omitWhenMerged') or value.get('mergeStrategy') == 'ocdsOmit':
            yield (new_path, {'omitWhenMerged'})
        # `wholeListMerge` supersedes any nested rules.
        # See http://standard.open-contracting.org/1.1-dev/en/schema/merging/#whole-list-merge
        elif 'array' in types and (value.get('wholeListMerge') or value.get('mergeStrategy') == 'ocdsVersion'):
            yield (new_path, {'wholeListMerge'})
        elif 'object' in types and 'properties' in value:
            yield from _get_merge_rules(value['properties'], path=new_path)
        elif 'array' in types and 'items' in value:
            item_types = _get_types(value['items'])
            # See http://standard.open-contracting.org/1.1-dev/en/schema/merging/#objects
            if any(item_type != 'object' for item_type in item_types):
                yield (new_path, {'wholeListMerge'})
            elif 'object' in item_types and 'properties' in value['items']:
                # See http://standard.open-contracting.org/1.1-dev/en/schema/merging/#whole-list-merge
                if 'id' not in value['items']['properties']:
                    yield (new_path, {'wholeListMerge'})
                else:
                    yield from _get_merge_rules(value['items']['properties'], path=new_path)
1192797
def iter_path_splits(path):
    
    split_path = path.split('.')
    for i in range(len(split_path)):
        p1 = join_paths(*split_path[:i])
        p2 = join_paths(*split_path[i:])
        yield p1, p2
640878
def merge_sources(self, datas):
        
        datas = [data for data in datas if data is not None]

        if len(datas) == 0:
            raise ValueError("Data missing")

        if len(datas) == 1:
            return datas[0]

        if isinstance(datas[0], list):
            if len([x for x in datas if not isinstance(x, list)]) > 0:
                raise TypeError("Unable to merge: List expected")
            base = []
            for x in datas:
                base = base + x
            return base

        if isinstance(datas[0], dict):
            if len([x for x in datas if not isinstance(x, dict)]) > 0:
                raise TypeError("Unable to merge: Dictionnary expected")
            result = {}
            for element in datas:
                for key in element:
                    if key in result:
                        result[key] = self.merge_sources([result[key], element[key]])
                    else:
                        result[key] = element[key]
            return result

        if len([x for x in datas if isinstance(x, (dict, list))]) > 0:
            raise TypeError("Unable to merge: List not expected")

        raise ValueError("Unable to merge: Conflict")
856720
private static TupleCombiner asCombiner( JsonObject json)
    {
    try
      {
      TupleCombiner tupleCombiner = new TupleCombiner();

      Optional.ofNullable( json.getJsonNumber( TUPLES_KEY))
        .ifPresent( n -> tupleCombiner.setTupleSize( n.intValue()));

      Optional.ofNullable( json.getJsonArray( INCLUDE_KEY))
        .map( includes -> includes.getValuesAs( JsonString.class).stream())
        .orElse( Stream.empty())
        .map( JsonString::getString)
        .forEach( var -> {
          try
            {
            try
              {
              tupleCombiner.addIncludedVar( var);
              }
            catch( Exception e)
              {
              throw new GeneratorSetException( e.getMessage());
              }
            }
          catch( Exception e)
            {
            throw new GeneratorSetException( "Error defining included variables", e);
            }
          });

      Optional.ofNullable( json.getJsonArray( EXCLUDE_KEY))
        .map( excludes -> excludes.getValuesAs( JsonString.class).stream())
        .orElse( Stream.empty())
        .map( JsonString::getString)
        .forEach( var -> {
          try
            {
            try
              {
              tupleCombiner.addExcludedVar( var);
              }
            catch( Exception e)
              {
              throw new GeneratorSetException( e.getMessage());
              }
            }
          catch( Exception e)
            {
            throw new GeneratorSetException( "Error defining excluded variables", e);
            }
          });

      Optional.ofNullable( json.getJsonArray( ONCE_KEY))
        .map( onceTuples -> onceTuples.getValuesAs( JsonObject.class).stream())
        .orElse( Stream.empty())
        .forEach( onceTuple -> {
          try
            {
            try
              {
              tupleCombiner.addOnceTuple( asTupleRef( onceTuple));
              }
            catch( Exception e)
              {
              throw new GeneratorSetException( e.getMessage());
              }
            }
          catch( Exception e)
            {
            throw new GeneratorSetException( "Error defining once tuples", e);
            }
          });


      return tupleCombiner;
      }
    catch( GeneratorSetException e)
      {
      throw new GeneratorSetException( "Error defining combiner", e);
      }
    }
500089
def merge_properties(item_properties, prop_name, merge_value):
    
    existing_value = item_properties.get(prop_name, None)
    if not existing_value:  # A node without existing values for the property
        item_properties[prop_name] = merge_value
    else:
        if type(merge_value) is int or type(merge_value) is str:
            item_properties[prop_name] = existing_value + merge_value
        elif type(merge_value) is list:
            item_properties[prop_name] = merge_list(existing_value, merge_value)
        else:
            return False
    return item_properties
765579
def merge(var1, var2):
    
    out = {}
    out['value'] = var2.get('value', var1.get('value', None))
    out['mimetype'] = var2.get('mimetype', var1.get('mimetype', None))
    out['types'] = var2.get('types') + [x for x in var1.get('types') if x not in var2.get('types')]
    out['optional'] = var2.get('optional', var1.get('optional', False))
    out['filename'] = var2.get('filename', var2.get('filename', None))
    return Variable(var1.default_type, **out)
1305534
def parse(path):
        

        def paired(iterable):
            """s -> (s0, s1), (s2, s3), (s4, s5), ..."""
            cursor = iter(iterable)
            return zip(cursor, cursor)

        def unwrap_if_sexp_symbol(datum):
            """Convert Symbol(':key') to ':key' (Symbol isn't hashable for dict keys).
            """
            return datum.value() if isinstance(datum, sexpdata.Symbol) else datum

        def sexp2dict(sexps):
            """Transforms a nested list structure from sexpdata to dict."""
            newdict = {}

            # Turn flat list into associative pairs
            for key, value in paired(sexps):
                key = str(unwrap_if_sexp_symbol(key)).lstrip(':')

                # Recursively transform nested lists
                if isinstance(value, list) and value:
                    if isinstance(value[0], list):
                        newdict[key] = [sexp2dict(val) for val in value]
                    elif isinstance(value[0], sexpdata.Symbol):
                        newdict[key] = sexp2dict(value)
                    else:
                        newdict[key] = value
                else:
                    newdict[key] = value

            return newdict

        conf = sexpdata.loads(Util.read_file(path))
        return sexp2dict(conf)
1006567
def merge(self, other):
        
        for key, value in other.items():
            if not key in self:
                self[key] = value
            elif isinstance(value, (list, tuple)):
                self[key] += value
            elif isinstance(value, OrderedSet):
                if isinstance(self[key], str):
                    self[key] = OrderedSet([self[key]])
                elif not isinstance(self[key], OrderedSet):
                    self[key] = OrderedSet(self[key])
                self[key] |= value
            else:
                self[key] = value
        return self
622979
function (jsonObject, path, force, value) {
  if (!path) {
    return;
  }
  var newValue, obj;
  obj = jsonObject || {};
  path.trim().split('.').some(function (key, index, array) {
    if (!key && key !== 0) {
      return false;
    }
    newValue = obj[key];
    if (index == array.length - 1) {
      if (value === undefined) {
        value = {};
      }
      obj[key] = value;
      return true;
    }
    if (!newValue && newValue != 0 && index <= (array.length - 1)) {
      if (force) {
        obj[key] = {};
      } else {
        return true;
      }
    }
    obj = obj[key];
  });

  return jsonObject;
}
1085311
def _merge_unbound_var_dicts(src, dst):
  """"""
  for k, v in six.iteritems(src):
    if dst.get(k, v) != v:
      trace1 = ''.join(scopes.skip_common_stack_elements(v.stacktrace, dst[
          k].stacktrace))
      trace2 = ''.join(
          scopes.skip_common_stack_elements(dst[k].stacktrace, v.stacktrace))
      raise ValueError('Key conflict: %s\nDefined At:\n%s\nand\n%s' %
                       (k, trace1, trace2))
    else:
      dst[k] = v
723225
def _merge(self, value):
        

        if value is not None and not isinstance(value, dict):
            # bogus value; will not pass validation but should be preserved
            return value

        if not self._pairs:
            return {}

        collected = {}
#        collected.update(value)
        for k_validator, v_validator in self._pairs:
            k_default = k_validator.get_default_for(None)
            if k_default is None:
                continue

            # even None is ok
            if value:
                v_for_this_k = value.get(k_default)
            else:
                v_for_this_k = None
            v_default = v_validator.get_default_for(v_for_this_k)
            collected.update({k_default: v_default})

        if value:
            for k, v in value.items():
                if k not in collected:
                    collected[k] = v

        return collected
1368353
def merge_dicts(src, patch):
    """"""
    for key in patch:
        if key in src:
            if isinstance(src[key], dict) and isinstance(patch[key], dict):
                merge_dicts(src[key], patch[key])
            else:
                src[key] = merge_values(src[key], patch[key])
        else:
            src[key] = patch[key]

    return src
156939
def deep_merge(source, dest):
    
    for key, value in source.items():
        if key in dest:
            if isinstance(value, dict) and isinstance(dest[key], dict):
                deep_merge(value, dest[key])
                continue
            elif isinstance(value, list) and isinstance(dest[key], list):
                for item in value:
                    if item not in dest[key]:
                        dest[key].append(item)
                continue
        dest[key] = value
398502
def merge_values(src, new):
    """"""
    if isinstance(src, dict) and isinstance(new, dict):
        return merge_dicts(src, new)
    else:
        if not isinstance(src, list):
            src = [src]
        if not isinstance(new, list):
            new = [new]

        return merge_lists(src, new)
374572
private static JsonStructure toJson( TupleCombiner combiner)
    {
    JsonObjectBuilder builder = Json.createObjectBuilder();

    builder.add( TUPLES_KEY, combiner.getTupleSize());

    JsonArrayBuilder includeBuilder = Json.createArrayBuilder();
    Arrays.stream( combiner.getIncluded()).forEach( var -> includeBuilder.add( var));
    JsonArray include = includeBuilder.build();
    if( !include.isEmpty())
      {
      builder.add( INCLUDE_KEY, include);
      }

    JsonArrayBuilder excludeBuilder = Json.createArrayBuilder();
    Arrays.stream( combiner.getExcluded()).forEach( var -> excludeBuilder.add( var));
    JsonArray exclude = excludeBuilder.build();
    if( !exclude.isEmpty())
      {
      builder.add( EXCLUDE_KEY, exclude);
      }

    JsonArrayBuilder onceBuilder = Json.createArrayBuilder();
    toStream( combiner.getOnceTuples()).forEach( tuple -> onceBuilder.add( toJson( tuple)));
    JsonArray once = onceBuilder.build();
    if( !once.isEmpty())
      {
      builder.add( ONCE_KEY, once);
      }

    return builder.build();
    }
813738
function mergeJson(original, override) {
            return _.merge(original, override, function (a, b, key, aParent, bParent) {
                if (_.isUndefined(b)) {
                    aParent[key] = undefined;
                    return;
                }
            });
        }
1107268
def merge_dicts(dict_a, dict_b):
    """"""
    duplicates = [val for val in dict_a if val in dict_b]
    if duplicates:
        _LOGGER.warning(("Duplicates found during merge: %s. "
                         "Renaming is recommended."), duplicates)
    return {**dict_a, **dict_b}