Filter and export the user profiles.
496035
def _export_profiles(self, profile_name, user_pageviews, user_downloads,
                         ip_user=False):
        """"""
        views_min = self.config.get('user_views_min')
        views_max = self.config.get('user_views_max')
        ip_user_id = 500000000000
        add_user_id = 100000000000
        stat_records = 0
        with self.storage.get_user_profiles(profile_name) as store:
            store.clear()
            for user in user_pageviews:
                # Only users with unique pageviews.
                unique_views = len(set(user_pageviews[user]))
                if views_max > unique_views >= views_min:
                    nodes, weight = self._calculate_user_record_weights(
                            record_list=user_pageviews[user],
                            download_list=user_downloads.get(user))
                    if ip_user:
                        store.add_user(ip_user_id, nodes, weight)
                        ip_user_id += 1
                    else:
                        user = str(add_user_id + int(user))
                        store.add_user(user, nodes, weight)
                    self.stat_long['User_num_records'].append(len(nodes))
                    stat_records += len(nodes)

                elif unique_views >= views_min:
                    # TODO: Add stat for to many views.
                    print("Drop user {} with {} views".format(user,
                                                              unique_views))
        self.stat['user_profiles'] = len(self.stat_long.get(
                                                        'User_num_records'))
        self.stat['user_profiles_records'] = stat_records

        print("Stats: {}".format(self.stat))
843328
def filter_by_user(self, user):
        """"""

        return self.filter(Q(users=user) | Q(groups__in=user.groups.all()))
435781
function (req, res, next) {
    var profile = req.profile;
    var filter = { or: [{ yahoo: profile.guid }, { email: profile.email }] };

    User.find({ where: filter }, function(err, users) {
      var user = users[0];

      if (user) {
        if (!user.yahoo) {
          user.yahoo = body.profile.guid;
          user.displayName = user.displayName || body.profile.name;
          user.save(function() {
            req.user = user;
            next();
          });
          return;
        }

        req.user = user;
        next();
        return;
      }

      User.create({
        displayName: body.profile.name,
        yahoo: body.profile.guid,
        email: body.profile.email,
        password: body.profile.guid
      }, function (err, user) {
        req.user = user;
        next();
      });

    });
  }
793289
def profile(curr_step, start_step, end_step, profile_name='profile.json',
            early_exit=True):
    """"""
    if curr_step == start_step:
        mx.nd.waitall()
        mx.profiler.set_config(profile_memory=False, profile_symbolic=True,
                               profile_imperative=True, filename=profile_name,
                               aggregate_stats=True)
        mx.profiler.set_state('run')
    elif curr_step == end_step:
        mx.nd.waitall()
        mx.profiler.set_state('stop')
        logging.info(mx.profiler.dumps())
        mx.profiler.dump()
        if early_exit:
            exit()
224329
def export_users(path_prefix='/', region=None, key=None, keyid=None,
                 profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if not conn:
        return None
    results = odict.OrderedDict()
    users = get_all_users(path_prefix, region, key, keyid, profile)
    for user in users:
        name = user.user_name
        _policies = conn.get_all_user_policies(name, max_items=100)
        _policies = _policies.list_user_policies_response.list_user_policies_result.policy_names
        policies = {}
        for policy_name in _policies:
            _policy = conn.get_user_policy(name, policy_name)
            _policy = salt.utils.json.loads(_unquote(
                    _policy.get_user_policy_response.get_user_policy_result.policy_document
            ))
            policies[policy_name] = _policy
        user_sls = []
        user_sls.append({"name": name})
        user_sls.append({"policies": policies})
        user_sls.append({"path": user.path})
        results["manage user " + name] = {"boto_iam.user_present": user_sls}
    return __utils__['yaml.safe_dump'](
        results,
        default_flow_style=False,
        indent=2)
434576
def show(self, username):
        """"""
        filter = ['(objectclass=posixAccount)', "(uid={})".format(username)]
        return self.client.search(filter)
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
499515
public function index()
    {
        // Setup default profile summary sections
        $sections = ArrayList::create();

        $sections->push(
            ArrayData::create(
                array(
                "Title" => "",
                "Content" => $this->renderWith(
                    "UsersProfileSummary",
                    array("CurrentUser" => Member::currentUser())
                )
                )
            )
        );

        // Allow users to add extra content sections to the
        // summary
        $this->extend("updateIndexSections", $sections);

        $this->customise(
            array(
            "Title" => _t('Users.ProfileSummary', 'Profile Summary'),
            "MetaTitle" => _t('Users.ProfileSummary', 'Profile Summary'),
            "Content" => $this->renderWith(
                "UsersAccountSections",
                array("Sections" => $sections)
            )
            )
        );

        $this->extend("onBeforeIndex");

        return $this->renderWith(
            array(
            "UserAccount",
            "Page"
            )
        );
    }
555893
def _filter_queryset(self, perms, queryset):
        """"""
        user = self.request.user if self.request else AnonymousUser()
        return get_objects_for_user(user, perms, queryset)
1009342
def dump_profiles(self, path):
        
        for id, profiler, _ in self.profilers:
            profiler.dump(id, path)
        self.profilers = []
249305
def create_profiles(self, prefix, weeks, ip_user=False):
        """"""
        # Future: Add a time range in weeks for how long a user is considered
        #         as the same user.

        # Count accessed records
        record_counter = {}
        for year, week in weeks:
            file = self.storage.get(prefix, year, week)
            self.count_records(record_counter, file)

        # TODO: Statistics, count records
        print("Records read all: {}".format(self.stat))

        # Filter records with to less/much views.
        records_valid = self.filter_counter(record_counter)

        # Create user profiles
        profiles = defaultdict(list)
        for year, week in weeks:
            file = self.storage.get(prefix, year, week)
            self._create_user_profiles(profiles, file, records_valid, ip_user,
                                       year, week)

        return profiles
96558
def profile(self, username):
        """"""
        if not username and g.user:
            username = g.user.username

        payload = {
            'user': bootstrap_user_data(username, include_perms=True),
            'common': self.common_bootsrap_payload(),
        }

        return self.render_template(
            'superset/basic.html',
            title=_("%(user)s's profile", user=username),
            entry='profile',
            bootstrap_data=json.dumps(payload, default=utils.json_iso_dttm_ser),
        )
1052603
def browseprofile(profilelog):
    '''
    
    '''
    print('Starting the pstats profile browser...\n')
    try:
            browser = ProfileBrowser(profilelog)
            print >> browser.stream, "Welcome to the profile statistics browser. Type help to get started."
            browser.cmdloop()
            print >> browser.stream, "Goodbye."
    except KeyboardInterrupt:
            pass
582221
def analyze_profile(self):
        """"""
        profile_parser = ProfileParser()
        databases = self._get_requested_databases()
        connection = pymongo.MongoClient(self._db_uri,
                                         document_class=OrderedDict,
                                         read_preference=pymongo.ReadPreference.PRIMARY_PREFERRED)

        if databases == []:
            try:
                databases = connection.database_names()
            except:
                message = "Error: Could not list databases on server. Please " \
                          +         "check the auth components of your URI or provide " \
                          +         "a namespace filter with -n.\n"
                sys.stderr.write(message)
                databases = []

            for ignore_db in IGNORE_DBS:
                if ignore_db in databases:
                    databases.remove(ignore_db)

        for database in databases:

            db = connection[database]

            profile_entries = db['system.profile'].find()

            for profile_entry in profile_entries:
                self._process_query(profile_entry,
                                    profile_parser)

        self._output_aggregated_report(sys.stdout)

        return 0
350742
function getProfile()
    {
        $pclass = Pluf::f('user_profile_class', false);
        if (false === $pclass) {
            throw new Pluf_Exception_SettingError('"user_profile_class" setting not defined.');
        }
        $db = $this->getDbConnection();
        $sql = new Pluf_SQL(sprintf('%s=%%s', $db->qn('user')), array(
            $this->id
        ));
        $users = Pluf::factory($pclass)->getList(array(
            'filter' => $sql->gen()
        ));
        if ($users->count() != 1) {
            throw new Pluf_Exception_DoesNotExist(sprintf('No profiles available for user: %s', (string) $this));
        }
        return $users[0];
    }
386290
def profiles(self):
        '''
        
        '''
        limit = []

        if self.is_admin():
            limit.append(_("Administrator"))
        limit.sort()

        return limit
146321
def ListProfilers(self):
    """"""
    table_view = views.ViewsFactory.GetTableView(
        self._views_format_type, column_names=['Name', 'Description'],
        title='Profilers')

    profilers_information = sorted(
        profiling.ProfilingArgumentsHelper.PROFILERS_INFORMATION.items())
    for name, description in profilers_information:
      table_view.AddRow([name, description])
    table_view.Write(self._output_writer)