コード例 #1
0
ファイル: test_courses.py プロジェクト: hoh/libulb
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"
コード例 #2
0
ファイル: course.py プロジェクト: etnarek/libulb
    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)
コード例 #3
0
ファイル: courses.py プロジェクト: C4ptainCrunch/libulb
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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
ファイル: course.py プロジェクト: etnarek/libulb
    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)
コード例 #7
0
ファイル: test_slug.py プロジェクト: hoh/libulb
def slug1():
    return Slug('info', 'f', '101')
コード例 #8
0
ファイル: test_slug.py プロジェクト: hoh/libulb
def test_2_digit():
    Slug('info', 'y', '56')