def test_get_list(): l = courses.get_list() assert 6000 < len(l) < 9000 assert isinstance(l, dict) assert all([isinstance(x, Slug) for x in l.keys()]) assert l[Slug('info', 'f', '101')] == "Programmation"
def get_from_slug(cls, slug, year): slug = Slug.match_all(slug) response = cls._query_ulb(year, slug) if not response.ok: raise Exception("Error with ulb") soup = BeautifulSoup(response.text, "html.parser") table = soup.find('table', 'bordertable') tr_list = table('tr') infos = {} for line in tr_list: if len(line('td')) != 2: continue key, val = line('td') key = key.text.strip().strip("*").strip() val = val.text.strip().strip("*").strip() infos[key] = val slug = "{}-{}-{}".format(slug.domain, slug.faculty, slug.number).lower() return cls(slug, year, infos)
def get_list(): txt = requests.get("http://gehol.ulb.ac.be/gehol/Vue/HoraireCours.php").text courses = json.loads(re.search(r'<script>\s\n\svar data =(.*);\s\n', txt).groups()[0]) ret = {} for course in courses: mnemo = course['label'] name = course['value'] name = name.replace("[{}]".format(mnemo), "").strip() slug = Slug.from_gehol(mnemo) ret[slug] = name return ret
def prettify_event(course): course['days'] = course['Date(s)'].split(', ') del course['Date(s)'] course['groups'] = course['Groupe(s)'].split(', ') del course['Groupe(s)'] course['weeks'] = course['Semaine(s)'].split('; ') del course['Semaine(s)'] # 'title' looks like 'Programmation [INFOF101]' course['name'], course['slug'] = re.match(r"^(.*)\[([A-Z]{5}\d{3,4})\]$", course['title']).groups() del course['title'] course['name'] = course['name'].strip() course['slug'] = Slug.from_gehol(course['slug']) return course
def get_list(): txt = requests.get( "http://gehol.ulb.ac.be/gehol/Vue/HoraireCours.php").text courses = json.loads( re.search(r'<script>\s\n\svar data =(.*);\s\n', txt).groups()[0]) ret = {} for course in courses: mnemo = course['label'] name = course['value'] name = name.replace("[{}]".format(mnemo), "").strip() slug = Slug.from_gehol(mnemo) ret[slug] = name return ret
def slug1(): return Slug('info', 'f', '101')
def test_2_digit(): Slug('info', 'y', '56')