Generate the flair, by user, for the subreddit.
768453
def current_flair(self):
        """"""
        if self._current_flair is None:
            self._current_flair = []
            if self.verbose:
                print('Fetching flair list for {}'.format(self.sub))
            for flair in self.sub.flair:
                self._current_flair.append(flair)
                yield flair
        else:
            for item in self._current_flair:
                yield item
1180764
def get_sticky(self, subreddit, bottom=False):
        
        url = self.config['sticky'].format(subreddit=six.text_type(subreddit))
        param = {'num': 2} if bottom else None
        return objects.Submission.from_json(self.request_json(url,
                                                              params=param))
162249
def set_stylesheet(self, subreddit, stylesheet):
        
        subreddit = six.text_type(subreddit)
        data = {'r': subreddit,
                'stylesheet_contents': stylesheet,
                'op': 'save'}  # Options: save / preview
        self.evict(self.config['stylesheet'].format(subreddit=subreddit))
        return self.request_json(self.config['subreddit_css'], data=data)
1014068
def main():
    """"""
    usage = 'Usage: %prog [options] KEYWORD...'
    parser = arg_parser(usage=usage)
    parser.add_option('-s', '--subreddit', action='append',
                      help=('When at least one `-s` option is provided '
                            '(multiple can be) only alert for comments in the '
                            'indicated subreddit(s).'))
    parser.add_option('-I', '--ignore-user', action='append', metavar='USER',
                      help=('Ignore comments from the provided user. Can be '
                            'supplied multiple times.'))
    parser.add_option('-m', '--message', metavar='USER',
                      help=('When set, send a reddit message to USER with the '
                            'alert.'))
    options, args = parser.parse_args()
    if not args:
        parser.error('At least one KEYWORD must be provided.')

    session = praw.Reddit(options.site, check_for_updates=False,
                          user_agent=AGENT)

    if options.message:
        msg_to = session.redditor(options.message)

    check_for_updates(options)

    # Build regex
    args = [x.lower() for x in args]
    reg_prefix = r'(?:^|[^a-z])'  # Any character (or start) can precede
    reg_suffix = r'(?:$|[^a-z])'  # Any character (or end) can follow
    regex = re.compile(r'{}({}){}'.format(reg_prefix, '|'.join(args),
                                          reg_suffix), re.IGNORECASE)

    # Determine subreddit or multireddit
    if options.subreddit:
        subreddit = '+'.join(sorted(options.subreddit))
    else:
        subreddit = 'all'

    print('Alerting on:')
    for item in sorted(args):
        print(' * {}'.format(item))
    print('using the comment stream: https://www.reddit.com/r/{}/comments'
          .format(subreddit))

    # Build ignore set
    if options.ignore_user:
        ignore_users = set(x.lower() for x in options.ignore_user)
    else:
        ignore_users = set()

    try:
        for comment in session.subreddit(subreddit).stream.comments():
            if comment.author and comment.author.name.lower() in ignore_users:
                continue
            match = regex.search(comment.body)
            if match:
                keyword = match.group(1).lower()
                url = quick_url(comment)
                print('{}: {}'.format(keyword, url))
                if options.message:
                    msg_to.message(
                        'Reddit Alert: {}'.format(keyword),
                        '{}\n\nby /u/{}\n\n---\n\n{}'.format(
                            url, comment.author, comment.body))
    except KeyboardInterrupt:
        sys.stderr.write('\n')
        print('Goodbye!\n')
872126
protected function generateSubmitButton()
	{
		$args = $this->args['submit'];

		is_array( $args ) ?: $args = ['text' => $args ];

		$args = shortcode_atts([
			'text' => __( 'Save Changes', 'site-reviews' ),
			'type' => 'primary',
			'name' => 'submit',
			'wrap' => true,
			'other_attributes' => null,
		], $args );

		if( is_admin() ) {
			ob_start();
			submit_button( $args['text'], $args['type'], $args['name'], $args['wrap'], $args['other_attributes'] );
			return ob_get_clean();
		}
	}
999979
def output_current_flair(self, as_json=False):
        """"""
        flair_list = sorted(self.current_flair(), key=lambda x: x['user'].name)
        if as_json:
            print(json.dumps(flair_list, sort_keys=True, indent=4))
            return

        for flair in flair_list:
            print(flair['user'])
            print('  Text: {}\n   CSS: {}'.format(flair['flair_text'],
                                                  flair['flair_css_class']))
164080
protected function submitAddUser()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->setSubmittedJson('data');

        $this->validateComponent('user');
        $this->addUser();
    }
814969
function joinFlairs(data) {
  let result = []
  for (let [ targetStringArray, ...rest ] of data) {
    // Raw flair containing only one flair don’t need to be modified.
    if (targetStringArray.length < 2) {
      result.push([ targetStringArray, ...rest ])
      continue
    }
    // Concatenate the flairs using one, two and three spaces.
    for (let i = 1; i <= 3; i++) {
      const SPACES = pad('', i)
      result.push([ targetStringArray.join(SPACES), ...rest ])
    }
  }
  return result
}
40949
def clear_empty(self):
        """"""
        for flair in self.current_flair():
            if not flair['flair_text'] and not flair['flair_css_class']:
                print(self.reddit.flair.update(flair['user']))
                print('Removed flair for {0}'.format(flair['user']))
561586
def _convert(reddit_session, data):
        """"""
        retval = Redditor(reddit_session, data['name'], fetch=False)
        retval.id = data['id'].split('_')[1]  # pylint: disable=C0103,W0201
        return retval
696503
def get_subreddit(self, subreddit_name, *args, **kwargs):
        
        sr_name_lower = subreddit_name.lower()
        if sr_name_lower == 'random':
            return self.get_random_subreddit()
        elif sr_name_lower == 'randnsfw':
            return self.get_random_subreddit(nsfw=True)
        return objects.Subreddit(self, subreddit_name, *args, **kwargs)
757206
def configure_flair(self, subreddit, flair_enabled=False,
                        flair_position='right',
                        flair_self_assign=False,
                        link_flair_enabled=False,
                        link_flair_position='left',
                        link_flair_self_assign=False):
        
        flair_enabled = 'on' if flair_enabled else 'off'
        flair_self_assign = 'on' if flair_self_assign else 'off'
        if not link_flair_enabled:
            link_flair_position = ''
        link_flair_self_assign = 'on' if link_flair_self_assign else 'off'
        data = {'r': six.text_type(subreddit),
                'flair_enabled': flair_enabled,
                'flair_position': flair_position,
                'flair_self_assign_enabled': flair_self_assign,
                'link_flair_position': link_flair_position,
                'link_flair_self_assign_enabled': link_flair_self_assign}
        return self.request_json(self.config['flairconfig'], data=data)
145938
def get_stylesheet(self, subreddit, **params):
        """"""
        url = self.config['stylesheet'].format(
            subreddit=six.text_type(subreddit))
        return self.request_json(url, params=params)['data']
121521
def clear_flair_templates(self, subreddit, is_link=False):
        
        data = {'r': six.text_type(subreddit),
                'flair_type': 'LINK_FLAIR' if is_link else 'USER_FLAIR'}
        return self.request_json(self.config['clearflairtemplates'], data=data)
1256299
def generate_submission_id():
    
    client = get_client()

    res = client.get_submission_id()
    formatted_print(res, text_format=FORMAT_TEXT_RAW, response_key="value")
625780
function combinedData(flairs, presenters) {
  let result = []
  for (let [ flairPattern, normalizedFlair ] of flairs) {
    for (let [ presenterPattern, presenter ] of presenters)
      result.push([ `${flairPattern}!${presenterPattern}`, normalizedFlair, presenter ])
  }
  return result
}
1163957
def set_post_flair post, link_flair_css_class, link_flair_text
      Module.nesting[1].logger.warn "setting flair '#{link_flair_css_class}' with text '#{link_flair_text}' to post '#{post["name"]}'"
      if {"error"=>403} == @flairselector_choices ||= json(:post, "/r/#{@subreddit}/api/flairselector", link: post["name"])
        Module.nesting[1].logger.error "possibly not enough permissions for /r/#{@subreddit}/api/flairselector"
        return
      end
      json :post, "/api/selectflair",
        link: post["name"],
        text: link_flair_text,
        flair_template_id: @flairselector_choices["choices"].find{ |i| i["flair_css_class"] == link_flair_css_class }.tap{ |flair|
          fail "can't find '#{link_flair_css_class}' flair class at https://www.reddit.com/r/#{@subreddit}/about/flair/#link_templates" unless flair
        }["flair_template_id"]
    end