Find resources with the same name, and call onDupe to change the names
337940
function dedupe(resources, onDupe) {
  // first create a map of name->[array of resources with same name]
  var names = {};
  resources.forEach(function(scriptResource) {
    if (names[scriptResource.name] == null) {
      names[scriptResource.name] = [];
    }
    names[scriptResource.name].push(scriptResource);
  });

  // Call the de-dupe function for each set of dupes
  Object.keys(names).forEach(function(name) {
    var clones = names[name];
    if (clones.length > 1) {
      onDupe(clones);
    }
  });
}
130544
def update_resources(self, data, type_, names=None, languages=None):
        
        UpdateResources(self.filename, data, type_, names, languages)
1149004
def _resolve_resource_name(self, name):
        """"""
        if name[:4] == 'http':  # already a url
            return name
        name = name.rstrip('/').lstrip('/')
        return '%s%s/%s' % (self.scheme, self.host, name)
653678
def prune_dupes(self):
        
        n = 0
        pruned1 = []
        seen = set()
        deletes = {}
        for r in reversed(self.resources):
            if (r.uri in seen):
                n += 1
                if (r.uri in deletes):
                    deletes[r.uri] = r.change
            else:
                pruned1.append(r)
                seen.add(r.uri)
                if (r.change == 'deleted'):
                    deletes[r.uri] = r.change
        # go through all deletes and prune if first was create
        pruned2 = []
        for r in reversed(pruned1):
            if (r.uri in deletes and deletes[r.uri] == 'created'):
                n += 1
            else:
                pruned2.append(r)
        self.resources = pruned2
        return(n)
230621
function getNames (resourceType) {
  const aliases = [resourceType];
  if (resourceAliases[resourceType]) {
    return aliases.concat(resourceAliases[resourceType]);
  }
  return alias(resourceType);
}
606500
def file_name(self, resource):
        """"""
        warnings.warn(
            "file_name is deprecated; use resource_name instead",
            DeprecationWarning, stacklevel=2)
        return self.resource_name(resource)
1222054
def _find_init_change(name, ret, **kwargs):
    '''
    
    '''
    kwargs = salt.utils.args.clean_kwargs(**kwargs)
    if 'vm' in kwargs:
        kwargs.update(kwargs.pop('vm'))
    # the state processing eats 'runas' so we rename
    kwargs['runas'] = kwargs.pop('vagrant_runas', '')
    try:
        vm_ = __salt__['vagrant.get_vm_info'](name)
    except SaltInvocationError:
        vm_ = {}
        for key, value in kwargs.items():
            ret['changes'][key] = {'old': None, 'new': value}
    if vm_:  # test for changed values
        for key in vm_:
            value = vm_[key] or ''  # supply a blank if value is None
            if key != 'name':  # will be missing in kwargs
                new = kwargs.get(key, '')
                if new != value:
                    if key == 'machine' and new == '':
                        continue  # we don't know the default machine name
                    ret['changes'][key] = {'old': value, 'new': new}
    return ret, kwargs
293807
def get_name_locations(self, name):
        """"""
        result = []
        for module in self.names:
            if name in self.names[module]:
                try:
                    pymodule = self.project.get_module(module)
                    if name in pymodule:
                        pyname = pymodule[name]
                        module, lineno = pyname.get_definition_location()
                        if module is not None:
                            resource = module.get_module().get_resource()
                            if resource is not None and lineno is not None:
                                result.append((resource, lineno))
                except exceptions.ModuleNotFoundError:
                    pass
        return result
1328916
def _makeUniqueFilename(taken_names, name):
    
    if name in taken_names:
        # try to form up new name
        basename, ext = os.path.splitext(name)
        num = 1
        name = "%s-%d%s" % (basename, num, ext)
        while name in taken_names:
            num += 1
            name = "%s-%d%s" % (basename, num, ext)
    # finally, enter name into set
    taken_names.add(name)
    return name
83945
def get_same_name_files(files_path_list, filename):
    """"""
    same_name_files = []
    for fname in files_path_list:
        if filename == os.path.basename(fname):
            same_name_files.append(path_components(fname))
    return same_name_files
891578
private function detectNameConflicts(): void
  {
    // Get same method names from array
    list($sources_by_path, $sources_by_method) = $this->getDuplicates();

    // Add every not unique method name to myErrorFileNames
    foreach ($sources_by_path as $source)
    {
      $this->errorFilenames[] = $source['path_name'];
    }

    // Log the sources files with duplicate method names.
    foreach ($sources_by_method as $method => $sources)
    {
      $tmp = [];
      foreach ($sources as $source)
      {
        $tmp[] = $source['path_name'];
      }

      $this->io->error(sprintf("The following source files would result wrapper methods with equal name '%s'",
                               $method));
      $this->io->listing($tmp);
    }

    // Remove duplicates from mySources.
    foreach ($this->sources as $i => $source)
    {
      if (isset($sources_by_path[$source['path_name']]))
      {
        unset($this->sources[$i]);
      }
    }
  }
1172225
def same_resource?(resource_a, resource_b)
      resource_a.namespace == resource_b.namespace &&
        resource_a.apiVersion == resource_b.apiVersion &&
        resource_a.kind == resource_b.kind &&
        resource_a.metadata[:name] == resource_b.metadata[:name]
    end
927639
def _copy_resources(self):
        

        for resource in self._client._resources:
            # set the name param, the keys now have / in them
            potion_resource = self._client._resources[resource]

            try:
                oc_cls = _model_lookup[resource]
                oc_cls._api = self
                oc_cls._resource = potion_resource
                setattr(self, oc_cls.__name__, oc_cls)
            except KeyError:  # Ignore resources we don't explicitly model
                pass
990395
function rename(oldPath, newPath, callback) {
        appshell.fs.rename(oldPath, newPath, _wrap(callback));
    }
1064416
def renamed(self, source, dest):
        """"""
        filename = osp.abspath(to_text_string(source))
        index = self.editorstacks[0].has_filename(filename)
        if index is not None:
            for editorstack in self.editorstacks:
                editorstack.rename_in_data(filename,
                                           new_filename=to_text_string(dest))
591536
def rename(self, new_name):
        """"""
        old_name = self.name
        self.name = new_name
        pypath = self.relative_pythonpath  # ??
        self.root_path = self.root_path[:-len(old_name)]+new_name
        self.relative_pythonpath = pypath  # ??
        self.save()
1046937
def replace(self, source, dest):
        """"""
        for i, broker in enumerate(self.replicas):
            if broker == source:
                self.replicas[i] = dest
                return