Generate an unique Atom id for the given content
4748
def _get_id(owner, date, content):
    
    h = hashlib.sha256()
    # Hash still contains the original project url, keep as is
    h.update("github.com/spacetelescope/asv".encode('utf-8'))
    for x in content:
        if x is None:
            h.update(",".encode('utf-8'))
        else:
            h.update(x.encode('utf-8'))
        h.update(",".encode('utf-8'))

    if date is None:
        date = datetime.datetime(1970, 1, 1)
    return "tag:{0},{1}:/{2}".format(owner, date.strftime('%Y-%m-%d'), h.hexdigest())
566468
def generate_id
      raise "generate_id only makes sense for headers" unless node_type == :header
      generated_id = children_to_s.tr(' ', '_').downcase.gsub(/\W/, '').strip
      num_occurs = (@doc.header_ids[generated_id] += 1)
      generated_id += "_#{num_occurs}" if num_occurs > 1
      generated_id
    end
800900
private static void createIDsForAtomContainer(IAtomContainer container, List<String> tabuList) {
        if (tabuList == null) tabuList = AtomContainerManipulator.getAllIDs(container);

        if (null == container.getID()) {
            // generate new ID and remember it
            atomContainerCount = setID(ATOMCONTAINER_PREFIX, atomContainerCount, container, tabuList);
        }

        // the tabu list for the container should force singularity
        // within a container only!
        List<String> internalTabuList = AtomContainerManipulator.getAllIDs(container);
        if (policy == OBJECT_UNIQUE_POLICY) {
            // start atom and bond indices within a container set always from 1
            atomCount = 0;
            bondCount = 0;
        } else {
            internalTabuList = tabuList;
        }

        Iterator<IAtom> atoms = container.atoms().iterator();
        while (atoms.hasNext()) {
            IAtom atom = atoms.next();
            if (null == atom.getID()) {
                atomCount = setID(ATOM_PREFIX, atomCount, atom, internalTabuList);
            }
        }

        Iterator<IBond> bonds = container.bonds().iterator();
        while (bonds.hasNext()) {
            IBond bond = bonds.next();
            if (null == bond.getID()) {
                bondCount = setID(BOND_PREFIX, bondCount, bond, internalTabuList);
            }
        }
    }
951372
def _get_unique_child(xtag, eltname):
    """"""
    try:
        results = xtag.findall(eltname)
        if len(results) > 1:
            raise Exception("Multiple elements found where 0/1 expected")
        elif len(results) == 1:
            return results[0]
        else:
            return None
    except Exception:
        return None
12502
def element!(name, content = nil, attributes = nil)
      build! do
        if content or block_given?
          @_crafted << "<#{name}#{Tools.format_attributes(attributes)}>"
          if block_given?
            value = yield
            content = value if !@_appended or value.kind_of? String
          end
          content = content.to_s
          @_crafted << Tools.escape(content) if content != ""
          @_crafted << "</#{name}>"
        else
          @_crafted << "<#{name}#{Tools.format_attributes(attributes)}/>"
        end
      end
    end
711822
def generate(self):
        """"""
        # atom demands either an author element in every entry or a global one
        if not self.author:
            if False in map(lambda e: bool(e.author), self.entries):
                self.author = ({'name': u'unbekannter Autor'},)

        if not self.updated:
            dates = sorted([entry.updated for entry in self.entries])
            self.updated = dates and dates[-1] or datetime.utcnow()

        yield u'<?xml version="1.0" encoding="utf-8"?>\n'
        yield u'<feed xmlns="http://www.w3.org/2005/Atom">\n'
        yield '  ' + _make_text_block('title', self.title, self.title_type)
        yield u'  <id>%s</id>\n' % escape(self.id)
        yield u'  <updated>%s</updated>\n' % format_iso8601(self.updated, self.timezone)
        if self.url:
            yield u'  <link href="%s" />\n' % escape(self.url, True)
        if self.feed_url:
            yield u'  <link href="%s" rel="self" />\n' % \
                escape(self.feed_url, True)
        for link in self.links:
            yield u'  <link %s/>\n' % ''.join('%s="%s" ' % \
                (k, escape(link[k], True)) for k in link)
        for author in self.author:
            yield u'  <author>\n'
            yield u'    <name>%s</name>\n' % escape(author['name'])
            if 'uri' in author:
                yield u'    <uri>%s</uri>\n' % escape(author['uri'])
            if 'email' in author:
                yield '    <email>%s</email>\n' % escape(author['email'])
            yield '  </author>\n'
        if self.subtitle:
            yield '  ' + _make_text_block('subtitle', self.subtitle,
                                          self.subtitle_type)
        if self.icon:
            yield u'  <icon>%s</icon>\n' % escape(self.icon)
        if self.logo:
            yield u'  <logo>%s</logo>\n' % escape(self.logo)
        if self.rights:
            yield '  ' + _make_text_block('rights', self.rights,
                                          self.rights_type)
        generator_name, generator_url, generator_version = self.generator
        if generator_name or generator_url or generator_version:
            tmp = [u'  <generator']
            if generator_url:
                tmp.append(u' uri="%s"' % escape(generator_url, True))
            if generator_version:
                tmp.append(u' version="%s"' % escape(generator_version, True))
            tmp.append(u'>%s</generator>\n' % escape(generator_name))
            yield u''.join(tmp)
        for entry in self.entries:
            for line in entry.generate():
                yield u'  ' + line
        yield u'</feed>\n'
722529
def id_to_atom(self, idx):
        
        mapped_idx = self.mapid(idx, 'reversed')
        return pybel.Atom(self.original_structure.GetAtom(mapped_idx))
1344984
def unique_id(self):
        
        chain = self.parent.parent.id
        residue = self.parent.id
        return chain, residue, self.id
704804
function(target) {
      var id = 'unknown';

      if (target && typeof target.innerHTML === 'string') {
        if (target.id) {
          id = '#' + target.id;
        } else if (target.nodeName) {
          id = target.nodeName.toLowerCase();

          if (target.className) {
            var classes = target.className.split(/\s+/);
            for (var i = 0, length = classes.length; i < length; i++) {
              id += '.' + classes[i];
            }
          }
        }
      }

      return id;
    }
326795
private static void createIDsForReaction(IReaction reaction, List<String> tabuList) {
        if (tabuList == null) tabuList = ReactionManipulator.getAllIDs(reaction);

        if (null == reaction.getID()) {
            // generate new ID
            reactionCount  = setID(REACTION_PREFIX, reactionCount , reaction, tabuList);
        }

        if (policy == OBJECT_UNIQUE_POLICY) {
            // start atom and bond indices within a reaction set always from 1
            atomCount = 0;
            bondCount = 0;
        }

        for (IAtomContainer reactant : reaction.getReactants().atomContainers()) {
            createIDsForAtomContainer(reactant, tabuList);
        }
        for (IAtomContainer product : reaction.getReactants().atomContainers()) {
            createIDsForAtomContainer(product, tabuList);
        }
        Iterator<IAtomContainer> agents = reaction.getAgents().atomContainers().iterator();
        while (agents.hasNext()) {
            createIDsForAtomContainer((IAtomContainer) agents.next(), tabuList);
        }
    }
741984
function getUniqueIdentifier( root, libs, com ) {
  var id = root.attribs.id || ( com.name + ID++ );
  com.attr.id = id;
}
269978
def _construct_unique_id(self, id_prefix, lines):
        
        text = []
        for line in lines:
            if isinstance(line, str):
                text.append(line)
            elif isinstance(line, CodeAnswer):
                text.append(line.dump())
        return id_prefix + '\n' + '\n'.join(text)
990638
public AtomSymbolElement generateElement(IAtom atom, int alignment, RendererModel model) {
        String text;
        if (atom instanceof IPseudoAtom) {
            text = ((IPseudoAtom) atom).getLabel();
        } else {
            text = atom.getSymbol();
        }
        return new AtomSymbolElement(atom.getPoint2d().x, atom.getPoint2d().y, text, atom.getFormalCharge(),
                atom.getImplicitHydrogenCount(), alignment, getAtomColor(atom, model));
    }
1128999
def _make_unique(name, idx):
    """"""
    p = re.compile(".[aA-zZ]+_x[0-9]+")
    if p.match(name):
        tags = name[1:].split("_x")
        return ">%s_%s_x%s" % (tags[0], idx, tags[1])
    return name.replace("@", ">")
1283605
def get_element_by_id(self, ident):
        """"""
        for group in list(self.toc.keys()):
            for name in list(self.toc[group].keys()):
                if self.toc[group][name].ident == ident:
                    return self.toc[group][name]
        return None
825218
def generate_hash_id(node):
    
    try:
        content = tostring(node)
    except Exception:
        logger.exception("Generating of hash failed")
        content = to_bytes(repr(node))

    hash_id = md5(content).hexdigest()
    return hash_id[:8]
379707
def generate_node_id
      # a little bit more creative
      if @registry.respond_to? :unique
        @registry.unique
      else
        digest = Digest::SHA512.new
        seed = ::Socket.gethostname + rand.to_s + Time.now.to_s + SecureRandom.hex
        digest.update(seed).to_s
      end
    end