From b2eaa3be85b30732c4e6c083c6f0413c02dbaec4 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Thu, 3 Jan 2019 01:11:23 +0100 Subject: UPS2018: ajout du champ celcat_id Les cours dans celcat ont un champ id. Ce changement permet de le stocker dans la base de données (sous la forme d’un entier) et de l’afficher dans l’interface d’administration. Pour l’instant, on ne sait pas si cette valeur est unique ou non. Il n’y a donc pas de contraintes sur ce champ pour le moment. Signed-off-by: Alban Gruin --- management/parsers/ups2018.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'management/parsers/ups2018.py') diff --git a/management/parsers/ups2018.py b/management/parsers/ups2018.py index f1da5bf..e3afbe5 100644 --- a/management/parsers/ups2018.py +++ b/management/parsers/ups2018.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Alban Gruin +# Copyright (C) 2018-2019 Alban Gruin # # celcatsanitizer is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published @@ -114,7 +114,8 @@ class Parser(AbstractParser): return course = Course.objects.create( - source=self.source, begin=begin, end=end + source=self.source, begin=begin, end=end, + celcat_id=int(event["id"]) ) min_i = 0 -- cgit v1.2.1 From 297632390e6ec051e315e6d9545d0110a41a8880 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Wed, 13 Feb 2019 22:02:09 +0100 Subject: UPS2018: récupération du module (UE) correspondant à un cours Il peut être intéressant de lister les cours par module (UE). Une table est donc rajoutée pour stocker cette information et permettre d’effectuer des recherches et des tris. Signed-off-by: Alban Gruin --- management/parsers/ups2018.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'management/parsers/ups2018.py') diff --git a/management/parsers/ups2018.py b/management/parsers/ups2018.py index e3afbe5..afbfc4b 100644 --- a/management/parsers/ups2018.py +++ b/management/parsers/ups2018.py @@ -26,7 +26,7 @@ from django.utils import timezone import lxml.html import requests -from ...models import Course, Group, Room +from ...models import Course, Group, Module, Room from ...utils import get_current_week, get_week from .abstractparser import AbstractParser, ParserError @@ -137,6 +137,13 @@ class Parser(AbstractParser): # par un dictionnaire classique. names = OrderedDict.fromkeys(data[i - 1].split(';')) course.name = ", ".join(names.keys()) + + module_names = [t for t in event["tag"] + if len(t) > 0 and + any(n.startswith(t) for n in names.keys())] + if len(module_names) > 0: + module, _ = Module.objects.get_or_create(name=module_names[0]) + course.module = module else: course.name = "Sans nom" if i - 2 >= min_i: -- cgit v1.2.1 From a235752368c6eff21400f6f8089ee3bf781cf36e Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 30 Aug 2019 12:27:00 +0200 Subject: ups2018: déplacement des préfixes de cours dans une constante Le parseur UPS2018 va se servir de cette liste aussi, elle est donc déplacée dans sa propre constante. Signed-off-by: Alban Gruin --- management/parsers/ups2018.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'management/parsers/ups2018.py') diff --git a/management/parsers/ups2018.py b/management/parsers/ups2018.py index afbfc4b..0d6d798 100644 --- a/management/parsers/ups2018.py +++ b/management/parsers/ups2018.py @@ -32,6 +32,10 @@ from .abstractparser import AbstractParser, ParserError VARNAME = "v.events.list = " +GROUP_PREFIXES = ("L1 ", "L2 ", "L3 ", "L3P ", "M1 ", "M2 ", "DEUST ", "MAG1 ", + "1ERE ANNEE ", "2EME ANNEE ", "3EME ANNEE ", + "MAT-Agreg Interne ") + def find_events_list(soup): res = [] @@ -123,11 +127,7 @@ class Parser(AbstractParser): min_i = 1 i = min_i - while i < len(data) and not data[i].startswith( - ("L1 ", "L2 ", "L3 ", "L3P ", "M1 ", "M2 ", "DEUST ", "MAG1 ", - "1ERE ANNEE ", "2EME ANNEE ", "3EME ANNEE ", - "MAT-Agreg Interne ") - ): + while i < len(data) and not data[i].startswith(GROUP_PREFIXES): i += 1 groups = data[i] -- cgit v1.2.1 From d1369ea3654b56e6a91335bd108035cd5eecbc76 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 30 Aug 2019 14:00:11 +0200 Subject: ups2018: correction d’une erreur de syntaxe avec Python 3.7 `async' est devenu un mot-clef avec Python 3.7. Or, un paramètre est appelé de cette manière dans le parseur UPS2018. Ceci le renome en `asynchronous' pour corriger ce problème Signed-off-by: Alban Gruin --- management/parsers/ups2018.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'management/parsers/ups2018.py') diff --git a/management/parsers/ups2018.py b/management/parsers/ups2018.py index 0d6d798..ad8322c 100644 --- a/management/parsers/ups2018.py +++ b/management/parsers/ups2018.py @@ -221,10 +221,10 @@ class Parser(AbstractParser): responses = yield from asyncio.gather(*futures) return responses - def get_source_from_months(self, async=True): + def get_source_from_months(self, asynchronous=True): events = [] - if async: + if asynchronous: loop = asyncio.get_event_loop() events = loop.run_until_complete(self.get_months_async()) else: -- cgit v1.2.1