Make identifiers with unique names
966105
function identifierFactory (ast, reserved) {
  reserved = reserved || new Set

  ast.find(j.Identifier).forEach(path => {
    reserved.add(path.node.name)
  })

  ast.find(j.FunctionDeclaration).forEach(path => {
    reserved.add(path.node.id.name)
  })

  function identifier (name, suffix) {
    return j.identifier(identifier.string(name, suffix))
  }

  identifier.string = function (name, suffix) {
    let sfx = suffix == null ? '' : suffix
      , unique = name + sfx
      , n = 0

    while (reserved.has(unique)) {
      unique = name + (n++) + sfx
    }

    return unique
  }

  return identifier
}
998924
def normalize(self, text, **kwargs):
        """"""
        identifiers = []
        for ident in super(IdentifierType, self).normalize(text, **kwargs):
            identifiers.append(normalize(ident))
        return identifiers
189458
def normalize_set_identifier(identifier)
      case identifier
      when nil, ""
        @environment_name
      when :all, "all"
        nil
      when Array
        identifier.map { |i| normalize_set_identifier(i) }.uniq.join(",")
      else
        identifier.to_s
      end
    end
817857
def make_entity_name(name):
    """"""
    invalid_chars = "-=!#$%^&*[](){}/~'`<>:;"
    for char in invalid_chars:
        name = name.replace(char, "_")
    return name
1259265
def quote_names(db, names):
    """"""
    c = db.cursor()
    c.execute("SELECT pg_catalog.quote_ident(n) FROM pg_catalog.unnest(%s::text[]) n", [list(names)])
    return [name for (name,) in c]
672304
def _names(lexer):
    """"""
    first = _expect_token(lexer, {NameToken}).value
    rest = _zom_name(lexer)
    rnames = (first, ) + rest
    return rnames[::-1]
162550
def get_unique_name(self, name):
        

        if name not in self._db:
            self._db[name] = 0
            return name
        else:
            index = self._db[name]
            self._db[name] = index + 1
            return f"{name}_{index}"
554173
def IdentifiersIndexer(instance):
    
    identifiers = instance.Schema()['Identifiers'].get(instance)
    return [safe_unicode(i['Identifier']) for i in identifiers]
826848
function uniqueStrings(input){
	const output = {};
	for(let i = 0, l = input.length; i < l; ++i)
		output[input[i]] = true;
	return Object.keys(output);
}
239685
function makeId(length = RANDOM_CHARACTER_LENGTH) {
    let text = "";
    for (let i = 0; i < length; i++) {
        text += RANDOM_CHARACTER_SOURCE.charAt(Math.floor(Math.random() * RANDOM_CHARACTER_SOURCE.length));
    }

    return text;
}
1323022
def _identifiers(self):
        """"""
        for handle in self._storage_broker.iter_item_handles():
            yield dtoolcore.utils.generate_identifier(handle)
642317
def unique(iterable, key=identity):
    """"""
    seen = set()
    for item in iterable:
        item_key = key(item)
        if item_key not in seen:
            seen.add(item_key)
            yield item
26922
def _ids(self):
        """"""
        for pk in self._pks:
            yield getattr(self, pk)

        for pk in self._pks:

            try:
                yield str(getattr(self, pk))
            except ValueError:
                pass
224938
def _create_identifier(rdtype, name, content):
        
        sha256 = hashlib.sha256()
        sha256.update((rdtype + '/').encode('UTF-8'))
        sha256.update((name + '/').encode('UTF-8'))
        sha256.update(content.encode('UTF-8'))
        return sha256.hexdigest()[0:7]
1326606
def unique_list(input_list):
    
    """
    output_list = []
    if len(input_list) > 0:
        dim = _sp.shape(input_list)[1]
        for i in input_list:
            match = False
            for j in output_list:
                if dim == 3:
                    if i[0] == j[0] and i[1] == j[1] and i[2] == j[2]:
                        match = True
                elif dim == 2:
                    if i[0] == j[0] and i[1] == j[1]:
                        match = True
                elif dim == 1:
                    if i[0] == j[0]:
                        match = True
            if match is False:
                output_list.append(i)
    return output_list
891329
def get_unique_name(self, obj, name='', name_from_system=''):
        
        ns = self.namespace
        newname = name
        if not newname:
            newname = name_from_system

        if not newname:
            newname = u"Nameless_" + obj.__class__.__name__

        if not newname in ns:
            return newname

        counter = 0
        while True:
            newname1 = u"%s_%.2d" % (newname, counter)
            if not newname1 in ns:
                return newname1
            counter += 1
1238395
def p_identifier_name_string(self, p):
        
        p[0] = asttypes.PropIdentifier(p[1].value)
        # manually clone the position attributes.
        for k in ('_token_map', 'lexpos', 'lineno', 'colno'):
            setattr(p[0], k, getattr(p[1], k))