forked from ScoDoc/ScoDoc
removed old mxDateTime
This commit is contained in:
parent
66be2a41c9
commit
6d17f030e2
17
ZAbsences.py
17
ZAbsences.py
@ -44,17 +44,16 @@ L'API de plus bas niveau est en gros:
|
||||
|
||||
"""
|
||||
|
||||
import urllib
|
||||
import datetime
|
||||
import jaxml
|
||||
import cgi
|
||||
import string
|
||||
import re
|
||||
import time
|
||||
import datetime
|
||||
import dateutil
|
||||
import dateutil.parser
|
||||
import calendar
|
||||
|
||||
from mx.DateTime import DateTime as mxDateTime
|
||||
from mx.DateTime.ISO import ParseDateTimeUTC
|
||||
import urllib
|
||||
import cgi
|
||||
import jaxml
|
||||
|
||||
# ---------------
|
||||
from sco_zope import *
|
||||
@ -1542,8 +1541,8 @@ ou entrez une date pour visualiser les absents un jour donné :
|
||||
return scu.log_unknown_etud(self, REQUEST=REQUEST)
|
||||
etud = etuds[0]
|
||||
# check dates
|
||||
begin_date = ParseDateTimeUTC(begin) # may raises ValueError
|
||||
end_date = ParseDateTimeUTC(end)
|
||||
begin_date = dateutil.parser.isoparse(begin) # may raises ValueError
|
||||
end_date = dateutil.parser.isoparse(end)
|
||||
if begin_date > end_date:
|
||||
raise ValueError("invalid dates")
|
||||
#
|
||||
|
@ -96,8 +96,6 @@ apt-get -y install python-cracklib # was python-crack
|
||||
apt-get -y install python-icalendar
|
||||
apt-get -y install python-requests
|
||||
|
||||
apt-get -y install python-egenix-mxtools python-egenix-mxdatetime
|
||||
|
||||
|
||||
# ------------
|
||||
SVNVERSION=$(cd ..; svnversion)
|
||||
|
@ -226,10 +226,8 @@ def user_nbdays_since_last_notif(context, email_addr, etudid):
|
||||
)
|
||||
res = cursor.dictfetchone()
|
||||
if res:
|
||||
mxd = res["notification_date"] # mx.DateTime instance
|
||||
lastdate = datetime.datetime(mxd.year, mxd.month, mxd.day)
|
||||
now = datetime.datetime.now()
|
||||
return (now - lastdate).days
|
||||
now = datetime.datetime.now(res["notification_date"].tzinfo)
|
||||
return (now - res["notification_date"]).days
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -47,8 +47,7 @@
|
||||
"""
|
||||
import os
|
||||
import time
|
||||
from mx.DateTime import DateTime as mxDateTime
|
||||
import mx.DateTime
|
||||
import datetime
|
||||
import re
|
||||
import shutil
|
||||
import glob
|
||||
@ -140,7 +139,7 @@ class BaseArchiver:
|
||||
def get_archive_date(self, archive_id):
|
||||
"""Returns date (as a DateTime object) of an archive"""
|
||||
dt = [int(x) for x in os.path.split(archive_id)[1].split("-")]
|
||||
return mxDateTime(*dt)
|
||||
return datetime.datetime(*dt)
|
||||
|
||||
def list_archive(self, archive_id):
|
||||
"""Return list of filenames (without path) in archive"""
|
||||
|
@ -29,7 +29,6 @@
|
||||
"""
|
||||
|
||||
# Rewritten from ancient DTML code
|
||||
from mx.DateTime import DateTime as mxDateTime
|
||||
|
||||
from notes_log import log
|
||||
import sco_utils as scu
|
||||
|
@ -601,13 +601,13 @@ def _add_eval_columns(
|
||||
|
||||
coefs[evaluation_id] = "coef. %s" % e["coefficient"]
|
||||
if note_sur_20:
|
||||
nmx = 20.0
|
||||
nmax = 20.0
|
||||
else:
|
||||
nmx = e["note_max"]
|
||||
nmax = e["note_max"]
|
||||
if keep_numeric:
|
||||
note_max[evaluation_id] = nmx
|
||||
note_max[evaluation_id] = nmax
|
||||
else:
|
||||
note_max[evaluation_id] = "/ %s" % nmx
|
||||
note_max[evaluation_id] = "/ %s" % nmax
|
||||
|
||||
if nb_notes > 0:
|
||||
moys[evaluation_id] = "%.3g" % (sum_notes / nb_notes)
|
||||
|
@ -34,9 +34,7 @@ import tempfile
|
||||
import urllib
|
||||
import re
|
||||
import time
|
||||
import mx
|
||||
import mx.DateTime
|
||||
from mx.DateTime import DateTime as mxDateTime
|
||||
import datetime
|
||||
|
||||
import sco_utils as scu
|
||||
import VERSION
|
||||
@ -435,8 +433,8 @@ def table_suivi_cohorte(
|
||||
# tri les semestres par date de debut
|
||||
for s in sems:
|
||||
d, m, y = [int(x) for x in s["date_debut"].split("/")]
|
||||
s["date_debut_mx"] = mxDateTime(y, m, d) # pylint: disable=not-callable
|
||||
sems.sort(lambda x, y: cmp(x["date_debut_mx"], y["date_debut_mx"]))
|
||||
s["date_debut_dt"] = datetime.datetime(y, m, d)
|
||||
sems.sort(lambda x, y: cmp(x["date_debut_dt"], y["date_debut_dt"]))
|
||||
|
||||
# 2-- Pour chaque semestre, trouve l'ensemble des etudiants venant de sem
|
||||
logt("B: etuds sets")
|
||||
@ -467,21 +465,21 @@ def table_suivi_cohorte(
|
||||
# semestre de depart:
|
||||
porigin = periodsem()
|
||||
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
|
||||
porigin.datedebut = mxDateTime(y, m, d) # pylint: disable=not-callable
|
||||
porigin.datedebut = datetime.datetime(y, m, d)
|
||||
porigin.sems = [sem]
|
||||
|
||||
#
|
||||
tolerance = mx.DateTime.DateTimeDelta(45) # 45 days
|
||||
tolerance = datetime.timedelta(days=45)
|
||||
for s in sems:
|
||||
merged = False
|
||||
for p in P:
|
||||
if abs(s["date_debut_mx"] - p.datedebut) < tolerance:
|
||||
if abs(s["date_debut_dt"] - p.datedebut) < tolerance:
|
||||
p.sems.append(s)
|
||||
merged = True
|
||||
break
|
||||
if not merged:
|
||||
p = periodsem()
|
||||
p.datedebut = s["date_debut_mx"]
|
||||
p.datedebut = s["date_debut_dt"]
|
||||
p.sems = [s]
|
||||
P.append(p)
|
||||
|
||||
|
@ -543,15 +543,15 @@ class ScoDocJSONEncoder(json.JSONEncoder):
|
||||
def default(self, o): # pylint: disable=E0202
|
||||
import sco_formsemestre
|
||||
|
||||
# horrible hack pour encoder les dates mx
|
||||
# ScoDoc 7.22 n'utilise plus mx:
|
||||
if str(type(o)) == "<type 'mx.DateTime.DateTime'>":
|
||||
log("Warning: mx.DateTime object detected !")
|
||||
return o.strftime("%Y-%m-%dT%H:%M:%S")
|
||||
if isinstance(o, (datetime.date, datetime.datetime)):
|
||||
return o.isoformat()
|
||||
elif isinstance(o, sco_formsemestre.ApoEtapeVDI):
|
||||
return str(o)
|
||||
else:
|
||||
log("not mx: %s" % type(o))
|
||||
return json.JSONEncoder.default(self, o)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user