Пример #1
0
        print("{}. {}\t".format(i, pkl.course))
    while True:
        prompt = input('Enter the course number you\'d like to load, or "q" to quit: ')
        if prompt == 'q' or int(prompt) in range(0, i+1):
            break
    if prompt == 'q':
        sys.exit()
    else:
        email, password, url = prompts(pkl_files[int(prompt)].url)
        saved_list = pkl_files[int(prompt)]
else:
    if len(sys.argv) < 2:
        email, password, url = prompts()
    else:
        email, password, url = sys.argv[1:]

    # check cached DownloadLists
    for pkl in pkl_files:
        if url == pkl.url or DownloadList.course_name(url) == pkl.course:
            print("\nA list of download links already exits for this course."
                  "\nDo you want to use it?")
            prompt = None
            while prompt not in ['y', 'n']:
                prompt = input("    Enter 'y' if yes, 'n' if you'd like to scrape all links again: ")
                if prompt == 'y':
                    saved_list = pkl
            break

# push the red button
run(email, password, url, saved_list)
Пример #2
0
            'Enter the course number you\'d like to load, or "q" to quit: ')
        if prompt == 'q' or int(prompt) in range(0, i + 1):
            break
    if prompt == 'q':
        sys.exit()
    else:
        email, password, url = prompts(pkl_files[int(prompt)].url)
        saved_list = pkl_files[int(prompt)]
else:
    if len(sys.argv) < 2:
        email, password, url = prompts()
    else:
        email, password, url = sys.argv[1:]

    # check cached DownloadLists
    for pkl in pkl_files:
        if url == pkl.url or DownloadList.course_name(url) == pkl.course:
            print("\nA list of download links already exits for this course."
                  "\nDo you want to use it?")
            prompt = None
            while prompt not in ['y', 'n']:
                prompt = input(
                    "    Enter 'y' if yes, 'n' if you'd like to scrape all links again: "
                )
                if prompt == 'y':
                    saved_list = pkl
            break

# push the red button
run(email, password, url, saved_list)
Пример #3
0
 def test_course_name(self):
     self.assertEqual('course-v1-MITx-6-00-2x_4-3T2015',
                     DownloadList.course_name('https://courses.edx.org/courses/course-v1:MITx+6.00.2x_4+3T2015/courseware/8d9a47872ed641a1ace050f1c1ba7ac7/'))