Exemplo n.º 1
0
Arquivo: db.py Projeto: mydos/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester)
        groups = {}

        courses = Course.objects.filter(semester=self.semester)
        courses = {c.code: c for c in courses}

        query = ('SELECT aktkode, studieprogramkode FROM '
                 '%s_akt_studieprogram') % prefix

        for row in fetch.sql('ntnu', query):
            groups.setdefault(row.aktkode, set()).add(row.studieprogramkode)

        query = ('SELECT emnekode, typenavn, dag, start, slutt, uke, romnr, '
                 'romnavn, larer, aktkode FROM %s_timeplan ORDER BY emnekode, '
                 'dag, start, slutt, uke, romnavn, aktkode') % prefix

        for row in fetch.sql('ntnu', query):
            code, version = ntnu.parse_course(row.emnekode)
            if not code:
                logging.warning('Skipped invalid course name: %s',
                                row.emnekode)
                continue
            elif code not in courses:
                logging.debug("Unknown course %s.", code)
                continue
            elif not self.should_proccess_course(code):
                continue

            yield {
                'course':
                courses[code],
                'type':
                row.typenavn,
                'day':
                utils.parse_day_of_week(row.dag),
                'start':
                utils.parse_time(row.start),
                'end':
                utils.parse_time(row.slutt),
                'weeks':
                utils.parse_weeks(row.uke),
                'rooms':
                zip(utils.split(row.romnr, '#'), utils.split(row.romnavn,
                                                             '#')),
                'lecturers':
                utils.split(row.larer, '#'),
                'groups':
                groups.get(row.aktkode, set())
            }
Exemplo n.º 2
0
Arquivo: db.py Projeto: torstehu/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester)
        groups = {}

        courses = Course.objects.filter(semester=self.semester)
        courses = {c.code: c for c in courses}

        query = ("SELECT aktkode, studieprogramkode FROM " "%s_akt_studieprogram") % prefix

        for row in fetch.sql("ntnu", query):
            groups.setdefault(row.aktkode, set()).add(row.studieprogramkode)

        query = (
            "SELECT emnekode, typenavn, dag, start, slutt, uke, romnr, "
            "romnavn, larer, aktkode FROM %s_timeplan ORDER BY emnekode, "
            "dag, start, slutt, uke, romnavn, aktkode"
        ) % prefix

        for row in fetch.sql("ntnu", query):
            code, version = ntnu.parse_course(row.emnekode)
            if not code:
                logging.warning("Skipped invalid course name: %s", row.emnekode)
                continue
            elif code not in courses:
                logging.debug("Unknown course %s.", code)
                continue
            elif not self.should_proccess_course(code):
                continue

            yield {
                "course": courses[code],
                "type": row.typenavn,
                "day": utils.parse_day_of_week(row.dag),
                "start": utils.parse_time(row.start),
                "end": utils.parse_time(row.slutt),
                "weeks": utils.parse_weeks(row.uke),
                "rooms": zip(utils.split(row.romnr, "#"), utils.split(row.romnavn, "#")),
                "lecturers": utils.split(row.larer, "#"),
                "groups": groups.get(row.aktkode, set()),
            }
Exemplo n.º 3
0
Arquivo: db.py Projeto: Mattivc/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester)
        query = "SELECT emnekode, emnenavn FROM %s_fs_emne" % prefix

        for row in fetch.sql('ntnu', query):
            code, version = ntnu.parse_course(row.emnekode)
            if not code:
                logging.warning('Skipped invalid course name: %s', row.emnekode)
                continue

            yield {'code': code,
                   'name': row.emnenavn,
                   'version': version,
                   'url': 'http://www.ntnu.no/studier/emner/%s' % code}
Exemplo n.º 4
0
Arquivo: db.py Projeto: Mattivc/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester)
        groups = {}

        courses = Course.objects.filter(semester=self.semester)
        courses = dict((c.code, c) for c in courses)

        query = ('SELECT aktkode, studieprogramkode FROM '
                 '%s_akt_studieprogram') % prefix

        for row in fetch.sql('ntnu', query):
            groups.setdefault(row.aktkode, set()).add(row.studieprogramkode)

        query = ('SELECT emnekode, typenavn, dag, start, slutt, uke, romnr, '
                 'romnavn, larer, aktkode FROM %s_timeplan ORDER BY emnekode, '
                 'dag, start, slutt, uke, romnavn, aktkode') % prefix

        for row in fetch.sql('ntnu', query):
            code, version = ntnu.parse_course(row.emnekode)
            if not code:
                logging.warning('Skipped invalid course name: %s', row.emnekode)
                continue
            elif code not in courses:
                logging.debug("Unknown course %s.", code)
                continue

            yield {'course': courses[code],
                   'type': row.typenavn,
                   'day':  utils.parse_day_of_week(row.dag),
                   'start': utils.parse_time(row.start),
                   'end':  utils.parse_time(row.slutt),
                   'weeks': utils.parse_weeks(row.uke),
                   'rooms': zip(utils.split(row.romnr, '#'),
                                utils.split(row.romnavn, '#')),
                   'lecturers': utils.split(row.larer, '#'),
                   'groups': groups.get(row.aktkode, set())}
Exemplo n.º 5
0
Arquivo: db.py Projeto: torstehu/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester)
        query = "SELECT emnekode, emnenavn FROM %s_fs_emne" % prefix

        for row in fetch.sql("ntnu", query):
            code, version = ntnu.parse_course(row.emnekode)
            if not code:
                logging.warning("Skipped invalid course name: %s", row.emnekode)
                continue

            if not self.should_proccess_course(code):
                continue

            yield {
                "code": code,
                "name": row.emnenavn,
                "version": version,
                "url": "http://www.ntnu.no/studier/emner/%s" % code,
            }
Exemplo n.º 6
0
Arquivo: db.py Projeto: mydos/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester)
        query = "SELECT emnekode, emnenavn FROM %s_fs_emne" % prefix

        for row in fetch.sql('ntnu', query):
            code, version = ntnu.parse_course(row.emnekode)
            if not code:
                logging.warning('Skipped invalid course name: %s',
                                row.emnekode)
                continue

            if not self.should_proccess_course(code):
                continue

            yield {
                'code': code,
                'name': row.emnenavn,
                'version': version,
                'url': 'http://www.ntnu.no/studier/emner/%s' % code
            }