-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.py
More file actions
36 lines (32 loc) · 707 Bytes
/
common.py
File metadata and controls
36 lines (32 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import bs4
from common import *
from enum import IntEnum
import requests
import sys
DEBUG = False
class Kind(IntEnum):
NORMAL = 1
EVENING = 2
OPL = 3
RBO = 4
NOVICE = 5
TRAINING = 6
class Company(IntEnum):
MSV = 0
NO_LIMITS = 1
FOCUSED = 2
TRACKDAYS = 3
# All from uktrackdays -- a subset of trackdays.co.uk.
# CASTLE_COMBE = 4
# SILVERSTONE = 5
# PHIL_BEVAN = 6
# BIKEDAYS_CO = 7
def fetch_soup(filename, url):
if DEBUG:
with open(filename) as fd:
return bs4.BeautifulSoup(fd.read(), 'html.parser')
else:
r = requests.get(url)
if r.status_code != 200:
raise Exception('uh oh, server returned sadness')
return bs4.BeautifulSoup(r.text, 'html.parser')