Autocomplete unique identities profiles.

        Autocomplete unique identities profiles using the information
        of their identities. The selection of the data used to fill
        the profile is prioritized using a list of sources.
19369
def autocomplete(self, sources):
        
        email_pattern = re.compile(EMAIL_ADDRESS_REGEX)

        identities = self.__select_autocomplete_identities(sources)

        for uuid, ids in identities.items():
            # Among the identities (with the same priority) selected
            # to complete the profile, it will choose the longest 'name'.
            # If no name is available, it will use the field 'username'.
            name = None
            email = None

            for identity in ids:
                oldname = name

                if not name:
                    name = identity.name or identity.username
                elif identity.name and len(identity.name) > len(name):
                    name = identity.name

                # Do not set email addresses on the name field
                if name and email_pattern.match(name):
                    name = oldname

                if not email and identity.email:
                    email = identity.email

            kw = {
                'name': name,
                'email': email
            }

            try:
                api.edit_profile(self.db, uuid, **kw)
                self.display('autoprofile.tmpl', identity=identity)
            except (NotFoundError, InvalidValueError) as e:
                self.error(str(e))
                return e.code

        return CMD_SUCCESS
863566
def __load_unique_identities(self, uidentities, matcher, match_new,
                                 reset, verbose):
        """"""

        self.new_uids.clear()

        n = 0

        if reset:
            self.__reset_unique_identities()

        self.log("Loading unique identities...")

        for uidentity in uidentities:
            self.log("\n=====", verbose)
            self.log("+ Processing %s" % uidentity.uuid, verbose)

            try:
                stored_uuid = self.__load_unique_identity(uidentity, verbose)
            except LoadError as e:
                self.error("%s Skipping." % str(e))
                self.log("=====", verbose)
                continue

            stored_uuid = self.__load_identities(uidentity.identities, stored_uuid,
                                                 verbose)

            try:
                self.__load_profile(uidentity.profile, stored_uuid, verbose)
            except Exception as e:
                self.error("%s. Loading %s profile. Skipping profile." %
                           (str(e), stored_uuid))

            self.__load_enrollments(uidentity.enrollments, stored_uuid,
                                    verbose)

            if matcher and (not match_new or stored_uuid in self.new_uids):
                stored_uuid = self._merge_on_matching(stored_uuid, matcher,
                                                      verbose)

            self.log("+ %s (old %s) loaded" % (stored_uuid, uidentity.uuid),
                     verbose)
            self.log("=====", verbose)
            n += 1

        self.log("%d/%d unique identities loaded" % (n, len(uidentities)))
117686
function linkAutoComplete() {
    return listFiles('autocomplete')
        .then(filter(endsWith('.js')) & map(path.join('autocomplete', _)))
        .tap(files => all(files.map(file => fs.readFileAsync(file)
            .then(ensureNoImports(file)))));
}
302016
public Set<Profile> getProfiles()
    {
        final Set<Profile> ret = new HashSet<Profile>();
        if (this.profileNames.isEmpty()) {
            ret.add(Profile.getDefaultProfile());
        } else {
            for (final String name : this.profileNames) {
                ret.add(Profile.getProfile(name));
            }
        }
        return ret;
    }
462990
def validate_profile_exists(self):
        """"""

        if self.args.profile_name not in self.profiles:
            self.handle_error('Could not find profile "{}"'.format(self.args.profile_name))
1086760
def complete(self, request, response):
        
        extra = self.get_extra_data(response)
        data = {}
        for form_field, backend_field in self.PROFILE_MAPPING.items():
            data[form_field] = self.extract_data(extra, backend_field)
        request.session['extra'] = data

        if settings.ACCEPT_EXTRA_FORM:
            self.fill_extra_fields(request, data)

        request.session['identity'] = self.identity
        return redirect('netauth-extra', self.provider)
394482
def complete_profile(f, credentials, session_token_written, mfa_serial_written):
    
    session_token = credentials['SessionToken'] if 'SessionToken' in credentials else None
    mfa_serial = credentials['SerialNumber'] if 'SerialNumber' in credentials else None
    if session_token and not session_token_written:
        f.write('aws_session_token = %s\n' % session_token)
    if mfa_serial and not mfa_serial_written:
        f.write('aws_mfa_serial = %s\n' % mfa_serial)
800466
def get_identities(self, item):
        

        message = item['data']['message']
        identity = self.get_sh_identity(message['from'])

        yield identity
262025
def __load_profile(self, profile, uuid, verbose):
        """"""

        def is_empty_profile(prf):
            return not (prf.name or prf.email or
                        prf.gender or prf.gender_acc or
                        prf.is_bot or prf.country_code)

        uid = api.unique_identities(self.db, uuid)[0]

        if profile:
            self.__create_profile(profile, uuid, verbose)
        elif is_empty_profile(uid.profile):
            self.__create_profile_from_identities(uid.identities, uuid, verbose)
        else:
            self.log("-- empty profile given for %s. Not updated" % uuid, verbose)
252516
def get_identities(self, item):
        

        item = item['data']

        for identity in ['creator']:
            # Todo: questions has also involved and solved_by
            if identity in item and item[identity]:
                user = self.get_sh_identity(item[identity])
                yield user
            if 'answers_data' in item:
                for answer in item['answers_data']:
                    user = self.get_sh_identity(answer[identity])
                    yield user
1233605
def push_identity(self, identifiers):
        
        if (not identifiers):
            msg = ("Specified Subject identifiers cannot be None or empty "
                   "for 'run as' functionality.")
            raise ValueError(msg)

        stack = self.get_run_as_identifiers_stack()

        if (not stack):
            stack = []

        stack.append(identifiers)
        session = self.get_session()
        session.set_internal_attribute(self.run_as_identifiers_session_key, stack)
1354226
protected function autocomplete()
    {
        $question = new Question(static::PLEASE_SELECT_A_USER);
        $question->setAutocompleterValues($this->userEditor->getChoicesAsSeparateEmailUsername($this->choices));
        $selectedUser = $this->ask($question);
        // nem választott usert, vége
        if ('' === $selectedUser) {
            return;
        }
        $user = $this->getChoiceByUsernameOrEmail($selectedUser);
        // kiválasztott egy usert
        if (!is_null($user)) {
            $this->editor($user);
            // nem választott konkrét usert
        } else {
            $choices = $this->userEditor->getChoices($selectedUser, $selectedUser, true, static::MAX_USER_CHOICES);
            $this->selector($choices);
        }
    }
440652
def profile_list(self, provider, lookup='all'):
        '''
        
        '''
        data = {}
        lookups = self.lookup_profiles(provider, lookup)

        if not lookups:
            return data

        for alias, driver in lookups:
            if alias not in data:
                data[alias] = {}
            if driver not in data[alias]:
                data[alias][driver] = {}
        return data
333968
def get_identities(self, item):
        """"""

        user = self.get_sh_identity(item, self.get_field_author())
        yield user
466643
def autocomplete(self):
        
        params = self.set_lay_params()
        logging.info("PARAMS="+str(params))
        results = self.solr.search(**params)
        logging.info("Docs found: {}".format(results.hits))
        return self._process_layperson_results(results)
1189375
def users_autocomplete(self, name=None, **kwargs):
        ""
        api_path = "/api/v2/users/autocomplete.json"
        api_query = {}
        if "query" in kwargs.keys():
            api_query.update(kwargs["query"])
            del kwargs["query"]
        if name:
            api_query.update({
                "name": name,
            })
        return self.call(api_path, query=api_query, **kwargs)
476081
def __merge(self, matched, interactive):
        """"""

        for m in matched:
            identities = m['identities']
            uuid = identities[0]

            try:
                for c in identities[1:]:
                    if self.__merge_unique_identities(c, uuid, interactive):
                        self.matched += 1

                        # Retrieve unique identity to show updated info
                        if interactive:
                            uuid = api.unique_identities(self.db, uuid=uuid)[0]
            except Exception as e:
                if self.recovery:
                    self.recovery_file.save_matches(matched)
                raise e

            m['processed'] = True