Convert a LdapChanges object to a modlist for add operation.
327297
def _python_to_mod_new(changes: Changeset) -> Dict[str, List[List[bytes]]]:
    
    table: LdapObjectClass = type(changes.src)
    fields = table.get_fields()

    result: Dict[str, List[List[bytes]]] = {}

    for name, field in fields.items():
        if field.db_field:
            try:
                value = field.to_db(changes.get_value_as_list(name))
                if len(value) > 0:
                    result[name] = value
            except ValidationError as e:
                raise ValidationError(f"{name}: {e}.")

    return result
1136545
def set_attrs(self, username, attrs):
        
        ldap_client = self._bind()
        tmp = self._get_user(self._byte_p2(username), ALL_ATTRS)
        if tmp is None:
            raise UserDoesntExist(username, self.backend_name)
        dn = self._byte_p2(tmp[0])
        old_attrs = tmp[1]
        for attr in attrs:
            bcontent = self._byte_p2(attrs[attr])
            battr = self._byte_p2(attr)
            new = {battr: self._modlist(self._byte_p3(bcontent))}
            # if attr is dn entry, use rename
            if attr.lower() == self.dn_user_attr.lower():
                ldap_client.rename_s(
                    dn,
                    ldap.dn.dn2str([[(battr, bcontent, 1)]])
                    )
                dn = ldap.dn.dn2str(
                    [[(battr, bcontent, 1)]] + ldap.dn.str2dn(dn)[1:]
                    )
            else:
                # if attr is already set, replace the value
                # (see dict old passed to modifyModlist)
                if attr in old_attrs:
                    if type(old_attrs[attr]) is list:
                        tmp = []
                        for value in old_attrs[attr]:
                            tmp.append(self._byte_p2(value))
                        bold_value = tmp
                    else:
                        bold_value = self._modlist(
                            self._byte_p3(old_attrs[attr])
                        )
                    old = {battr: bold_value}
                # attribute is not set, just add it
                else:
                    old = {}
                ldif = modlist.modifyModlist(old, new)
                if ldif:
                    try:
                        ldap_client.modify_s(dn, ldif)
                    except Exception as e:
                        ldap_client.unbind_s()
                        self._exception_handler(e)

        ldap_client.unbind_s()
1361483
public MergeObservableList<T> insertItem(T object) {
        lists.add(Collections.singletonList(object));
        modCount += 1;
        listeners.notifyInserted(this, size() - 1, 1);
        return this;
    }
299354
def registerAddonModule(cls, module):
        
        prop = '_{0}__addon_modules'.format(cls.__name__)
        mods = getattr(cls, prop, set())
        mods.add(module)
        setattr(cls, prop, mods)
114031
def insert(python_data: LdapObject, database: Optional[Database] = None) -> LdapObject:
    
    assert isinstance(python_data, LdapObject)

    table: LdapObjectClass = type(python_data)

    # ADD NEW ENTRY
    empty_data = table()
    changes = changeset(empty_data, python_data.to_dict())

    return save(changes, database)
312606
def add(self, dn: str, mod_list: dict) -> None:
        

        _debug("add", self, dn, mod_list)

        # if rollback of add required, delete it
        def on_commit(obj):
            obj.add(dn, None, mod_list)

        def on_rollback(obj):
            obj.delete(dn)

        # process this action
        return self._process(on_commit, on_rollback)
970815
private void addNewObjects(List<EDBObject> tempList) {
        for (EDBObject b : tempList) {
            String oid = b.getOID();
            ObjectDiff odiff = new ObjectDiff(this.startCommit, this.endCommit, null, b);
            if (odiff.getDifferenceCount() > 0) {
                diff.put(oid, odiff);
            }
        }
    }
580038
def addDataModels(self, mods):
        '''
        
        '''
        # Load all the universal properties
        for _, mdef in mods:
            for univname, _, _ in mdef.get('univs', ()):
                self.addUnivName(univname)

        # Load all the forms
        for _, mdef in mods:
            for formname, formopts, propdefs in mdef.get('forms', ()):

                self.formnames.add(formname)
                self.propnames.add(formname)

                for univname in self.univnames:
                    full = f'{formname}{univname}'
                    self.propnames.add(full)

                for propname, _, _ in propdefs:
                    full = f'{formname}:{propname}'
                    self.propnames.add(full)
576992
private ModelNode addNewAliasToList(ModelNode list, String alias) {

        // check for empty string
        if (alias == null || alias.equals(""))
            return list ;

        // check for undefined list (AS7-3476)
        if (!list.isDefined()) {
            list.setEmptyList();
        }

        ModelNode newList = list.clone() ;
        List<ModelNode> listElements = list.asList();

        boolean found = false;
        for (ModelNode listElement : listElements) {
            if (listElement.asString().equals(alias)) {
                found = true;
            }
        }
        if (!found) {
            newList.add().set(alias);
        }
        return newList ;
    }
1277429
function (runtime, modNames) {
            S.each(modNames, function (m) {
                Utils.createModuleInfo(runtime, m);
            });
        }
606830
def add(config, username, filename):
        """"""
        try:
            client = Client()
            client.prepare_connection()
            user_api = UserApi(client)
            key_api = API(client)
            key_api.add(username, user_api, filename)
        except (ldap3.core.exceptions.LDAPNoSuchAttributeResult,
                ldap_tools.exceptions.InvalidResult,
                ldap3.core.exceptions.LDAPAttributeOrValueExistsResult
                ) as err:  # pragma: no cover
            print('{}: {}'.format(type(err), err.args[0]))
        except Exception as err:  # pragma: no cover
            raise err from None
161783
private static List<Object> toObjectList(List<ModelNode> nodeList) throws ProtocolException {
        if (nodeList.isEmpty()) {
            return Collections.emptyList();
        } else {
            ArrayList<Object> result = new ArrayList<>(nodeList.size());
            for (ModelNode node : nodeList) {
                if (node.hasDefined(JBossASClient.RESULT)) {
                    result.add(toObject(node.get(JBossASClient.RESULT)));
                } else {
                    throw new IllegalStateException("No 'result' in a nodeList item [" + node + "]");
                }
            }
            return Collections.unmodifiableList(result);
        }
    }
678402
def importobj(modpath, attrname):
    """"""
    module = __import__(modpath, None, None, ['__doc__'])
    if not attrname:
        return module

    retval = module
    names = attrname.split(".")
    for x in names:
        retval = getattr(retval, x)
    return retval
941765
private static List<Object> convertToList(ParameterBinding binding, Iterable<?> params) {
        return StreamSupport.stream(params.spliterator(), false).map(binding::toColumnValue).collect(Collectors.toList());
    }
231120
def merge_domaindata(self, docnames, otherdata):
        
        for fullname, (fn, objtype) in otherdata['objects'].items():
            if fn in docnames:
                self.data['objects'][fullname] = (fn, objtype)
        for modname, data in otherdata['modules'].items():
            if data[0] in docnames:
                self.data['modules'][modname] = data
        for labelname, data in otherdata['labels'].items():
            if data[0] in docnames:
                self.data['labels'][labelname] = data
        for anonlabelname, data in otherdata['anonlabels'].items():
            if data[0] in docnames:
                self.data['anonlabels'][anonlabelname] = data
31782
private List<String> convertEDBObjectList(List<EDBObject> objects) {
        List<String> oids = new ArrayList<>();
        for (EDBObject object : objects) {
            oids.add(object.getOID());
        }
        return oids;
    }
1227024
def transform_dot(self, node, results):
        """"""
        module_dot = results.get("bare_with_attr")
        member = results.get("member")
        new_name = None
        if isinstance(member, list):
            member = member[0]
        for change in MAPPING[module_dot.value]:
            if member.value in change[1]:
                new_name = change[0]
                break
        if new_name:
            module_dot.replace(Name(new_name,
                                    prefix=module_dot.prefix))
        else:
            self.cannot_convert(node, "This is an invalid module element")