Ejemplo n.º 1
0
def create_sidebar():
    """Get the static sidebar elements and callouts to dynamic sidebar
    elements from the /r/NBA wiki. 
    
    """
    #Initiate PRAW
    r = praw.Reddit(user_agent='NBA_MOD using praw')
    #Log in to Reddit using 
    r.login(os.environ['USER'],os.environ['PASS'])
    #Get the sidebar from the wiki
    sidebar_md = r.get_subreddit('NBA').get_wiki_page('edit_sidebar').content_md
    sidebar_md = sidebar_md.replace(">", ">")
    #Split the sidebar by individual lines. Each line is a different game
    sidebar_list = sidebar_md.split('\n')
    sidebar = ""
    for line in sidebar_list:
        if line.startswith("//")==False: 
            if line.startswith("$kill"):
                return "kill"
            elif line.startswith("$team_subreddits"):
                sidebar = sidebar + utils.get_team_subreddits(5)
            elif line.startswith("$schedule"):
                sidebar = sidebar + utils.get_schedule(1)
            elif line.startswith("$game_threads"):
                all_games = utils.get_game_threads()
                sidebar = sidebar + utils.create_scorebar(all_games)
            elif line.startswith("$game_thread_bar"):
                all_games = utils.get_game_threads()
                sidebar = sidebar + utils.create_game_thread_bar(all_games)
            elif line.startswith("$standings"):
                sidebar = sidebar + utils.get_standings_nba()
            else:
                sidebar = sidebar + line

    return sidebar
Ejemplo n.º 2
0
def create_sidebar():
    """Get the static sidebar elements and callouts to dynamic sidebar
    elements from the /r/NBA wiki. 
    
    """
    #Initiate PRAW
    r = praw.Reddit(user_agent='NBA_MOD using praw')
    #Log in to Reddit using
    #r.login(os.environ['USER'],os.environ['PASS'])
    o = OAuth2Util.OAuth2Util(r, print_log=True, configfile="conf.ini")
    #Get the sidebar from the wiki
    sidebar_md = r.get_subreddit('NBA').get_wiki_page(
        'edit_sidebar').content_md
    sidebar_md = sidebar_md.replace(">", ">")
    #Split the sidebar by individual lines. Each line is a different game
    sidebar_list = sidebar_md.split('\n')
    sidebar = ""
    for line in sidebar_list:
        if line.startswith("//") == False:
            if line.startswith("$kill"):
                return "kill"
            elif line.startswith("$team_subreddits"):
                sidebar = sidebar + utils.get_team_subreddits(5)
            elif line.startswith("$schedule"):
                sidebar = sidebar + utils.get_schedule_2(4)
            elif line.startswith("$game_threads"):
                all_games = utils.get_game_threads()
                sidebar = sidebar + utils.create_scorebar(all_games)
            elif line.startswith("$game_thread_bar"):
                all_games = utils.get_game_threads()
                sidebar = sidebar + utils.create_game_thread_bar(all_games)
            elif line.startswith("$standings"):
                sidebar = sidebar + utils.get_standings_nba()
            elif line.startswith("$playoffs"):
                sidebar = sidebar + utils.get_playoff_table()
            else:
                sidebar = sidebar + line

    return sidebar
Ejemplo n.º 3
0
 def test_get_team_subreddits(self):
     utils.get_team_subreddits(3)