Skip to content

Instantly share code, notes, and snippets.

@fourohfour
Created March 8, 2018 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fourohfour/c285c061e75320bce32bc743e9648306 to your computer and use it in GitHub Desktop.
Save fourohfour/c285c061e75320bce32bc743e9648306 to your computer and use it in GitHub Desktop.
Load papers from PMT
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