示例#1
0
def read_more(service):
    utils.read_more(service)
    command = raw_input()

    if command == 'main':
        main()
    elif command == 'quit':
        utils.quit()

    if command == 'y':
        print '\n'
        # read more from cnn
        if service == 'cnn':
            cnn.cl_news_util(['cnn', '-h'], cache['cnn'])
        # read more from hackernews
        elif service == 'hn':
            hackernews.cl_news_util(['hn', '-h'], cache['hn'])
        # read more from ap
        elif service == 'ap':
            ap.cl_news_util(['ap', '-h'], cache['ap'])
        # read more from the guradian
        elif service == 'gu':
            guardian.cl_news_util(['gu', '-h'], cache['gu'])
        # read more from al jazeera
        elif service == 'aljaz':
            aljaz.cl_news_util(['aljaz', '-h'], cache['aljaz'])
        # read more from nyt
        elif service == 'nyt':
            nyt.cl_news_util(['nyt', '-h'], cache['nyt'])

        pick_article(service)

    else:
        print '\nCommand not recognized.\n'
        read_more(service)
示例#2
0
def pick_article(service):
    utils.command_prompt()
    command = raw_input()

    if command == 'quit':
        utils.quit()
    elif command == 'main':
        main()

    try:
        int(command)
    except:
        pick_article(service)

    if service == 'cnn':
        cnn.cl_news_util(['cnn', '-r', command], cache['cnn'])
    elif service == 'hn':
        # Hacker News is the only read action that opens the page
        hackernews.cl_news_util(['hn', '-o', command], cache['hn'])
    elif service == 'ap':
        ap.cl_news_util(['ap', '-r', command], cache['ap'])
    elif service == 'gu':
        guardian.cl_news_util(['gu', '-r', command], cache['gu'])
    elif service == 'aljaz':
        aljaz.cl_news_util(['aljaz', '-r', command], cache['aljaz'])
    elif service == 'nyt':
        nyt.cl_news_util(['nyt', '-r', command], cache['nyt'])

    read_more(service)
示例#3
0
def read_more(service):
    print '\nWould you like to read more from ' + service + '?(y/n)'
    print 'Type "main" to return to the Main Menu.\n'
    user_input = raw_input()
    if user_input == 'y':
        #read more from cnn
        if service == 'cnn':
            print '\n'
            cnn.cl_news_util(['cnn', '-h'], cache['cnn'])
            pick_article('cnn')
        #read more from hackernews
        elif service == 'hn':
            print '\n'
            hackernews.cl_news_util(['hn', '-h'], cache['hn'])
            pick_article('hn')
        #read more from ap
        elif service == 'ap':
            print '\n'
            ap.cl_news_util(['ap', '-h'], cache['ap'])
            pick_article('ap')
    #go back to main menu
    elif user_input == 'main':
        main()
    #handle quit
    elif user_input == 'n':
        quit()
    else:
        print '\nCommand not recognized.\n'
        read_more(service)
示例#4
0
def main():
    utils.cl_news_headline()
    service = raw_input()
    print '\n'

    if service == 'cnn':
        cache['cnn'] = cnn.cl_news_util([service, '-h'], cache['cnn'])
    elif service == 'hn':
        cache['hn'] = hackernews.cl_news_util([service, '-h'], cache['hn'])
    elif service == 'ap':
        cache['ap'] = ap.cl_news_util([service, '-h'], cache['ap'])
    elif service == 'gu':
        cache['gu'] = guardian.cl_news_util([service, '-h'], cache['gu'])
    elif service == 'aljaz':
        cache['aljaz'] = aljaz.cl_news_util([service, '-h'], cache['aljaz'])
    elif service == 'nyt':
        cache['nyt'] = nyt.cl_news_util([service, '-h'], cache['nyt'])
    elif service == 'wp':
        cache['wp'] = wp.cl_news_util([service, '-h'], cache['wp'])
    elif service == 'quit':
        utils.quit()
    else:
        print '\nCommand not recognized.\n'
        main()

    pick_article(service)
示例#5
0
def pick_article(service):
    command_prompt()
    command = raw_input()

    if command == 'quit':
        quit()
    elif command == 'main':
        main()

    try:
        int(command)
    except:
        pick_article(service)

    if service == 'cnn':
        cnn.cl_news_util(['cnn', '-r', command], cache['cnn'])
        read_more('cnn')
    elif service == 'hn':
        hackernews.cl_news_util(['hn', '-o', command], cache['hn'])
        read_more('hn')
    elif service == 'ap':
        ap.cl_news_util(['ap', '-r', command], cache['ap'])
        read_more('ap')
示例#6
0
def main():
    cl_news_headline()
    service = raw_input()
    if service == 'cnn':
        print '\n'
        cache['cnn'] = cnn.cl_news_util([service, '-h'], cache['cnn'])
        pick_article('cnn')
    elif service == 'hn':
        print '\n'
        cache['hn'] = hackernews.cl_news_util([service, '-h'], cache['hn'])
        pick_article('hn')
    elif service == 'ap':
        print '\n'
        cache['ap'] = ap.cl_news_util([service, '-h'], cache['ap'])
        pick_article('ap')
    elif service == 'quit':
        quit()
    else:
        print '\nCommand not recognized.\n'
        main()