Created
March 8, 2018 10:48
-
-
Save fourohfour/c285c061e75320bce32bc743e9648306 to your computer and use it in GitHub Desktop.
Load papers from PMT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
def inp(prmpt): | |
result = input(prmpt) | |
if result == "redo": | |
raise IndexError # lol | |
elif result == "quit": | |
sys.exit(0) | |
return result | |
urlstr = "http://pmt.physicsandmathstutor.com/download/Maths/A-level/{module}/Papers-OCR/{month}%20{year}%20!DOC!%20-%20{module}%20OCR.pdf" | |
def paper_open(): | |
print("----") | |
module = inp("Module >>> ").upper() | |
year = inp("Year >>> ") | |
print("Jan: 1, Jun: 2") | |
month = {"1" : "January", | |
"2" : "June" }[inp("Month >>> ")] | |
paper = urlstr.format(module = module, year = year, month = month) | |
subprocess.call(["firefox", paper.replace("!DOC!", "QP"), paper.replace("!DOC!", "MS")]) | |
if __name__ == "__main__": | |
while True: | |
try: | |
paper_open() | |
except IndexError: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment