Create an atom from a Term or term handle.
353488
def fromTerm(cls, term):
        """"""

        if isinstance(term, Term):
            term = term.handle
        elif not isinstance(term, (c_void_p, int)):
            raise ArgumentTypeError((str(Term), str(c_void_p)), str(type(term)))

        a = atom_t()
        if PL_get_atom(term, byref(a)):
            return cls(a.value)
37682
function createAbbreviationModel(abbreviation, editor) {
	try {
		const ast = parseAbbreviation(abbreviation, editor);
		return {
			ast,
			abbreviation,
			snippet: expandAbbreviation(abbreviation, editor)
		};
	} catch (err) {
		return null;
	}
}
731470
def from_es(self, hit):
        """"""
        doc = hit.copy()
        klass = shallow_class_factory(self.model)

        # We can pass in the entire source, except when we have a non-indexable many-to-many
        for field in self.model._meta.get_fields():

            if not field.auto_created and field.many_to_many:
                if not issubclass(field.rel.to, Indexable):
                    if field.name in doc["_source"]:
                        del doc["_source"][field.name]

            # if field.one_to_many:
            #     if field.name in doc["_source"]:
            #         del doc["_source"][field.name]

        # Now let's go ahead and parse all the fields
        fields = self.mapping.properties.properties
        for key in fields:
            # TODO: What if we've mapped the property to a different name? Will we allow that?
            field = fields[key]

            # if isinstance(field, InnerObject):
            #     import pdb; pdb.set_trace()
            #     continue

            if doc["_source"].get(key):
                attribute_value = doc["_source"][key]

                doc["_source"][key] = field.to_python(attribute_value)

        return klass(**doc["_source"])
100938
def unpack(self, s):
        """"""
        return self._create(super(NamedStruct, self).unpack(s))
1372993
def _add_nested(self, rec, name, value):
        """"""
        # Remove comments and split term into typedef / target term.
        (typedef, target_term) = value.split('!')[0].rstrip().split(' ')

        # Save the nested term.
        getattr(rec, name)[typedef].append(target_term)
134330
def getAtomChars(t):
    
    s = c_char_p()
    if PL_get_atom_chars(t, byref(s)):
        return s.value
    else:
        raise InvalidTypeError("atom")
245201
def attrgetter_atom_handle(loc, tokens):
    """"""
    name, args = attrgetter_atom_split(tokens)
    if args is None:
        return '_coconut.operator.attrgetter("' + name + '")'
    elif "." in name:
        raise CoconutDeferredSyntaxError("cannot have attribute access in implicit methodcaller partial", loc)
    elif args == "":
        return '_coconut.operator.methodcaller("' + tokens[0] + '")'
    else:
        return '_coconut.operator.methodcaller("' + tokens[0] + '", ' + tokens[2] + ")"
259043
def yield_from_handle(self, tokens):
        """"""
        internal_assert(len(tokens) == 1, "invalid yield from tokens", tokens)
        if self.target_info < (3, 3):
            return (
                yield_from_var + " = " + tokens[0]
                + "\nfor " + yield_item_var + " in " + yield_from_var + ":\n"
                + openindent + "yield " + yield_item_var + "\n" + closeindent
            )
        else:
            return "yield from " + tokens[0]
522718
private int prepare(IAtom atom, IBond prev) {
        int count = 0;
        amap[atom.getIndex()] = 1;
        for (IBond bond : atom.bonds()) {
            if (bond == prev)
                continue;
            IAtom nbr = bond.getOther(atom);
            if (amap[nbr.getIndex()] == 0) {
                qbonds[numBonds++] = (IQueryBond) bond;
                count += prepare(nbr, bond) + 1;
            } else if (nbr.getIndex() < atom.getIndex()) {
                ++count; // ring closure
                qbonds[numBonds++] = (IQueryBond) bond;
            }
        }
        return count;
    }
544016
def parse_atom(tokens, options):
    
    token = tokens.current()
    result = []
    if token == '(':
        tokens.move()
        result = [Required(*parse_expr(tokens, options))]
        if tokens.move() != ')':
            raise tokens.error("Unmatched '('")
        return result
    elif token == '[':
        tokens.move()
        result = [Optional(*parse_expr(tokens, options))]
        if tokens.move() != ']':
            raise tokens.error("Unmatched '['")
        return result
    elif token == 'options':
        tokens.move()
        return [AnyOptions()]
    elif token.startswith('--') and token != '--':
        return parse_long(tokens, options)
    elif token.startswith('-') and token not in ('-', '--'):
        return parse_shorts(tokens, options)
    elif token.startswith('<') and token.endswith('>') or token.isupper():
        return [Argument(tokens.move())]
    else:
        return [Command(tokens.move())]
169007
def _generate_atom_feed(self, feed):
        
        atom_feed = self.init_atom_feed(feed)
        atom_feed.title("Feed")
        return atom_feed
353855
def from_Z(z: int):
        
        for sym, data in _pt_data.items():
            if data["Atomic no"] == z:
                return Element(sym)
        raise ValueError("No element with this atomic number %s" % z)
31559
def create(self):
        """"""
        pk = CRTPPacket()
        pk.set_header(5, CHAN_SETTINGS)
        if self.useV2:
            pk.data = (CMD_CREATE_BLOCK_V2, self.id)
        else:
            pk.data = (CMD_CREATE_BLOCK, self.id)
        for var in self.variables:
            if (var.is_toc_variable() is False):  # Memory location
                logger.debug('Logging to raw memory %d, 0x%04X',
                             var.get_storage_and_fetch_byte(), var.address)
                pk.data.append(struct.pack('<B',
                                           var.get_storage_and_fetch_byte()))
                pk.data.append(struct.pack('<I', var.address))
            else:  # Item in TOC
                logger.debug('Adding %s with id=%d and type=0x%02X',
                             var.name,
                             self.cf.log.toc.get_element_id(
                                 var.name), var.get_storage_and_fetch_byte())
                pk.data.append(var.get_storage_and_fetch_byte())
                if self.useV2:
                    ident = self.cf.log.toc.get_element_id(var.name)
                    pk.data.append(ident & 0x0ff)
                    pk.data.append((ident >> 8) & 0x0ff)
                else:
                    pk.data.append(self.cf.log.toc.get_element_id(var.name))
        logger.debug('Adding log block id {}'.format(self.id))
        if self.useV2:
            self.cf.send_packet(pk, expected_reply=(
                CMD_CREATE_BLOCK_V2, self.id))
        else:
            self.cf.send_packet(pk, expected_reply=(CMD_CREATE_BLOCK, self.id))
655130
def registerAtomType(self, parameters):
        
        name = parameters['name']
        if name in self._atomTypes:
            raise ValueError('Found multiple definitions for atom type: ' + name)
        atom_class = parameters['class']
        mass = _convertParameterToNumber(parameters['mass'])
        element = None
        if 'element' in parameters:
            element, custom = self._create_element(parameters['element'], mass)
            if custom:
                self.non_element_types[element.symbol] = element

        self._atomTypes[name] = self.__class__._AtomType(name, atom_class, mass, element)
        if atom_class in self._atomClasses:
            type_set = self._atomClasses[atom_class]
        else:
            type_set = set()
            self._atomClasses[atom_class] = type_set
        type_set.add(name)
        self._atomClasses[''].add(name)

        name = parameters['name']
        if 'def' in parameters:
            self.atomTypeDefinitions[name] = parameters['def']
        if 'overrides' in parameters:
            overrides = set(atype.strip() for atype
                            in parameters['overrides'].split(","))
            if overrides:
                self.atomTypeOverrides[name] = overrides
        if 'des' in parameters:
            self.atomTypeDesc[name] = parameters['desc']
        if 'doi' in parameters:
            dois = set(doi.strip() for doi in parameters['doi'].split(','))
            self.atomTypeRefs[name] = dois
135636
def xatom(self, atom):
        """"""
        handle = atom.handle
        
        if handle == self.atoms[0].handle:
            return self.atoms[1]
        elif handle == self.atoms[1].handle:
            return self.atoms[0]
        return None
429316
protected void newAtomData() {
        atomCounter = 0;
        elsym = new ArrayList<String>();
        elid = new ArrayList<String>();
        eltitles = new ArrayList<String>();
        formalCharges = new ArrayList<String>();
        partialCharges = new ArrayList<String>();
        isotope = new ArrayList<String>();
        atomicNumbers = new ArrayList<String>();
        exactMasses = new ArrayList<String>();
        x3 = new ArrayList<String>();
        y3 = new ArrayList<String>();
        z3 = new ArrayList<String>();
        x2 = new ArrayList<String>();
        y2 = new ArrayList<String>();
        xfract = new ArrayList<String>();
        yfract = new ArrayList<String>();
        zfract = new ArrayList<String>();
        hCounts = new ArrayList<String>();
        atomParities = new ArrayList<String>();
        parityARef1 = new ArrayList<String>();
        parityARef2 = new ArrayList<String>();
        parityARef3 = new ArrayList<String>();
        parityARef4 = new ArrayList<String>();
        atomAromaticities = new ArrayList<String>();
        atomDictRefs = new ArrayList<String>();
        spinMultiplicities = new ArrayList<String>();
        occupancies = new ArrayList<String>();
        atomCustomProperty = new HashMap<Integer, List<String>>();
    }
384802
def _in(self, *lst):
        """"""
        self.terms.append('in (%s)' % ', '.join(['"%s"' % x for x in lst]))
        return self