def friend(self): """Friend the user. :returns: The json response from the server. """ return _modify_relationship('friend')(self.reddit_session.user, self)
def unfriend(self): """Unfriend the user. :returns: The json response from the server. """ return _modify_relationship('friend', unlink=True)( self.reddit_session.user, self)
def friend(self): """Friend the user. :returns: The json response from the server. """ _request.evict([self.reddit_session.config['friends']]) return _modify_relationship('friend')(self.reddit_session.user, self)
def unfriend(self): """Unfriend the user. :returns: The json response from the server. """ _request.evict([self.reddit_session.config["friends"]]) return _modify_relationship("friend", unlink=True)(self.reddit_session.user, self)
def unfriend(self): """Unfriend the user.""" return _modify_relationship('friend', unlink=True)( self.reddit_session.user, self)
def friend(self): """Friend the user.""" return _modify_relationship('friend')(self.reddit_session.user, self)
class Subreddit(Messageable, NSFWable, Refreshable): """A class for Subreddits.""" ban = _modify_relationship('banned', is_sub=True) unban = _modify_relationship('banned', unlink=True, is_sub=True) make_contributor = _modify_relationship('contributor', is_sub=True) remove_contributor = _modify_relationship('contributor', unlink=True, is_sub=True) make_moderator = _modify_relationship('moderator', is_sub=True) remove_moderator = _modify_relationship('moderator', unlink=True, is_sub=True) # Generic listing selectors get_comments = _get_section('comments') get_controversial = _get_sorter('controversial') get_hot = _get_sorter('') get_new = _get_sorter('new') get_top = _get_sorter('top') # Explicit listing selectors get_controversial_from_all = _get_sorter('controversial', t='all') get_controversial_from_day = _get_sorter('controversial', t='day') get_controversial_from_hour = _get_sorter('controversial', t='hour') get_controversial_from_month = _get_sorter('controversial', t='month') get_controversial_from_week = _get_sorter('controversial', t='week') get_controversial_from_year = _get_sorter('controversial', t='year') get_new_by_date = _get_sorter('new', sort='new') get_new_by_rising = _get_sorter('new', sort='rising') get_top_from_all = _get_sorter('top', t='all') get_top_from_day = _get_sorter('top', t='day') get_top_from_hour = _get_sorter('top', t='hour') get_top_from_month = _get_sorter('top', t='month') get_top_from_week = _get_sorter('top', t='week') get_top_from_year = _get_sorter('top', t='year') def __init__(self, reddit_session, subreddit_name=None, json_dict=None, fetch=False): # Special case for when my_reddits is called as no name is returned so # we have to extract the name from the URL. The URLs are returned as: # /r/reddit_name/ if not subreddit_name: subreddit_name = json_dict['url'].split('/')[2] info_url = reddit_session.config['subreddit_about'] % subreddit_name super(Subreddit, self).__init__(reddit_session, json_dict, fetch, info_url) self.display_name = subreddit_name self._url = reddit_session.config['subreddit'] % subreddit_name def __unicode__(self): """Return the subreddit's display name. E.g. python or askreddit.""" return self.display_name def add_flair_template(self, *args, **kwargs): """Add a flair template to this subreddit.""" return self.reddit_session.add_flair_template(self, *args, **kwargs) def clear_all_flair(self): """Remove all flair on this subreddit.""" csv = [{'user': x['user']} for x in self.flair_list()] if csv: return self.set_flair_csv(csv) else: return def clear_flair_templates(self, *args, **kwargs): """Clear flair templates for this subreddit.""" return self.reddit_session.clear_flair_templates(self, *args, **kwargs) def flair_list(self, *args, **kwargs): """Return a list of flair for this subreddit.""" return self.reddit_session.flair_list(self, *args, **kwargs) def get_banned(self, *args, **kwargs): """Get banned users for this subreddit.""" return self.reddit_session.get_banned(self, *args, **kwargs) def get_settings(self, *args, **kwargs): """Get the settings for this subreddit.""" return self.reddit_session.get_settings(self, *args, **kwargs) def get_contributors(self, *args, **kwargs): """Get contributors for this subreddit.""" return self.reddit_session.get_contributors(self, *args, **kwargs) def get_flair(self, *args, **kwargs): """Get the flair for a user on this subreddit.""" return self.reddit_session.get_flair(self, *args, **kwargs) def get_moderators(self, *args, **kwargs): """Get moderators for this subreddit.""" return self.reddit_session.get_moderators(self, *args, **kwargs) def get_modqueue(self, *args, **kwargs): """Get the modqueue on this subreddit.""" return self.reddit_session.get_modqueue(self, *args, **kwargs) def get_reports(self, *args, **kwargs): """Get the reported submissions on this subreddit.""" return self.reddit_session.get_reports(self, *args, **kwargs) def get_spam(self, *args, **kwargs): """Get the spam-filtered items on this subreddit.""" return self.reddit_session.get_spam(self, *args, **kwargs) def get_stylesheet(self, *args, **kwargs): """Get the stylesheet and associated images for this subreddit.""" return self.reddit_session.get_stylesheet(self, *args, **kwargs) def search(self, query, *args, **kwargs): """Search this subreddit.""" return self.reddit_session.search(query, self, *args, **kwargs) def set_flair(self, *args, **kwargs): """Set flair for a particular user or submission on this subreddit.""" return self.reddit_session.set_flair(self, *args, **kwargs) def set_flair_csv(self, *args, **kwargs): """Set flair for a group of users all at once on this subreddit.""" return self.reddit_session.set_flair_csv(self, *args, **kwargs) def set_settings(self, *args, **kwargs): """Set the settings for this subreddit.""" return self.reddit_session.set_settings(self, *args, **kwargs) def set_stylesheet(self, *args, **kwargs): """Set stylesheet for this sub-reddit.""" return self.reddit_session.set_stylesheet(self, *args, **kwargs) def submit(self, *args, **kwargs): """Submit a new link to this subreddit.""" return self.reddit_session.submit(self, *args, **kwargs) def subscribe(self): """Subscribe to this subreddit.""" # pylint: disable-msg=W0212 return self.reddit_session._subscribe(self.content_id) def unsubscribe(self): """Unsubscribe from this subreddit.""" # pylint: disable-msg=W0212 return self.reddit_session._subscribe(self.content_id, unsubscribe=True) def update_settings(self, *args, **kwargs): """Update only the settings provided for this subreddit.""" return self.reddit_session.update_settings(self, *args, **kwargs)
def unfriend(self): """Unfriend the user.""" return _modify_relationship('friend', unlink=True)(self.reddit_session.user, self)