aboutsummaryrefslogtreecommitdiff
path: root/management/commands/_private.py
diff options
context:
space:
mode:
authorAlban Gruin2017-09-09 16:39:30 +0200
committerAlban Gruin2017-09-09 16:39:30 +0200
commit5c96538dfe708c4429d13397caedeb0b84a65b5a (patch)
tree855a9f31cb40a35805129d4f9edd3eac274cc11f /management/commands/_private.py
parentab9df7a174e2debbf9c644c8ec3e2127eeeaa3cf (diff)
parent60ea5a0e2a5f61f7f764bcf01aafb362781c16da (diff)
Merge branch 'stable/0.9.z' into prod/pa1ch/0.y.z
Diffstat (limited to 'management/commands/_private.py')
-rw-r--r--management/commands/_private.py39
1 files changed, 32 insertions, 7 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py
index c31eb34..17896c4 100644
--- a/management/commands/_private.py
+++ b/management/commands/_private.py
@@ -1,18 +1,17 @@
# Copyright (C) 2017 Alban Gruin
#
-# celcatsanitizer is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# celcatsanitizer is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# celcatsanitizer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with celcatsanitizer; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU Affero General Public License
+# along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>.
from bs4 import BeautifulSoup
from django.utils import timezone
@@ -21,6 +20,8 @@ from edt.models import Group, Room, Course
from edt.utils import get_week
import datetime
+import re
+
import requests
@@ -122,6 +123,30 @@ def get_events(timetable, year, week, soup, weeks_in_soup):
yield title, type_, groups, rooms, notes, begin, end
+def get_update_date(soup):
+ # Explication de la regex
+ #
+ # (\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+)
+ # (\d+) au moins un nombre
+ # / un slash
+ # (\d+) au moins un nombre
+ # / un slash
+ # (\d+) au moins un nombre
+ # \s+ au moins un espace
+ # (\d+) au moins un nombre
+ # : un deux-points
+ # (\d+) au moins un nombre
+ # : un deux-points
+ # (\d+) au moins un nombre
+ datetime_regex = re.compile("(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+)")
+ search = datetime_regex.search(soup.footer.text)
+ if search is None:
+ return None
+
+ day, month, year, hour, minute, second = [int(v) for v in search.groups()]
+ date = datetime.datetime(year, month, day, hour, minute, second)
+ return timezone.make_aware(date)
+
def get_weeks(soup):
weeks = {}
for span in soup.find_all("span"):