diff --git a/app/scodoc/bonus_sport.py b/app/scodoc/bonus_sport.py index aa5a92bfa..625d47193 100644 --- a/app/scodoc/bonus_sport.py +++ b/app/scodoc/bonus_sport.py @@ -224,9 +224,9 @@ def bonus_iutam(notes_sport, coefs, infos=None): # une seule note note_sport = notes_sport[0] if note_sport < 10.0: - return 0 + return 0.0 prc = min((int(2 * note_sport - 20.0) + 2) * 0.25, 5) - bonus = infos["moy"] * prc / 100 + bonus = infos["moy"] * prc / 100.0 return bonus @@ -332,8 +332,8 @@ def bonus_iuto(notes_sport, coefs, infos=None): infos["sem"]["date_debut_iso"] > "2013-08-01" ): # changement de regle en aout 2013. return bonus - coefs = 0 - coefs_total = 0 + coefs = 0.0 + coefs_total = 0.0 for ue_id in infos["moy_ues"]: ue_status = infos["moy_ues"][ue_id] coefs_total = coefs_total + ue_status["sum_coefs"] diff --git a/app/scodoc/imageresize.py b/app/scodoc/imageresize.py index 252a6f6dc..4afba9e64 100644 --- a/app/scodoc/imageresize.py +++ b/app/scodoc/imageresize.py @@ -19,7 +19,7 @@ def ImageScaleH(img_file, W=None, H=90): im = PILImage.open(img_file) if W is None: # keep aspect - W = (im.size[0] * H) / im.size[1] + W = int((im.size[0] * H) / float(im.size[1])) im.thumbnail((W, H), PILImage.ANTIALIAS) out_file_str = StringIO() im.save(out_file_str, im.format) diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index c05924a66..8b9afa010 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -941,7 +941,9 @@ def MonthTableBody( if legend or d == 1: n = 3 - len(legend) # pad to 3 cars if n > 0: - legend = " " * (n / 2) + legend + " " * ((n + 1) / 2) + legend = ( + " " * (n // 2) + legend + " " * ((n + 1) // 2) + ) else: legend = " " # empty cell cc.append(legend) diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index e75b6324c..540da23ce 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -553,7 +553,7 @@ class ApoEtud(dict): # print 'note=%s autre_note=%s' % (note, autre_note) try: moy_annuelle = (note + autre_note) / 2 - except: + except TypeError: moy_annuelle = "" note_str = _apo_fmt_note(moy_annuelle) diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index 282ed8704..9193c992b 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -141,7 +141,7 @@ def etud_upload_file_form(context, REQUEST, etudid): % etud, """
Le fichier ne doit pas dépasser %sMo.
""" - % (scu.CONFIG.ETUD_MAX_FILE_SIZE / (1024 * 1024)), + % (scu.CONFIG.ETUD_MAX_FILE_SIZE // (1024 * 1024)), ] tf = TrivialFormulator( REQUEST.URL0, diff --git a/app/scodoc/sco_bulletins_json.py b/app/scodoc/sco_bulletins_json.py index 42293bcc4..cdfed9c7c 100644 --- a/app/scodoc/sco_bulletins_json.py +++ b/app/scodoc/sco_bulletins_json.py @@ -203,7 +203,7 @@ def formsemestre_bulletinetud_published_dict( ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"]) try: ects_txt = str(int(ue["ects"])) - except: + except ValueError: ects_txt = "" u = dict( id=ue["ue_id"], diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 07a8968ca..e97d67d2f 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -84,9 +84,9 @@ def ListMedian(L): raise ValueError("empty list") L.sort() if n % 2: - return L[n / 2] + return L[n // 2] else: - return (L[n / 2] + L[n / 2 - 1]) / 2 + return (L[n // 2] + L[n // 2 - 1]) / 2 # -------------------------------------------------------------------- diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py index 0b2a7ae92..a8ade73e3 100644 --- a/app/scodoc/sco_photos.py +++ b/app/scodoc/sco_photos.py @@ -313,7 +313,7 @@ def save_image(context, etudid, data): def scale_height(img, W=None, H=REDUCED_HEIGHT): if W is None: # keep aspect - W = (img.size[0] * H) / img.size[1] + W = int((img.size[0] * H) / img.size[1]) img.thumbnail((W, H), PILImage.ANTIALIAS) return img @@ -355,7 +355,9 @@ def copy_portal_photo_to_fs(context, etud, REQUEST=None): f = None try: log("copy_portal_photo_to_fs: getting %s" % url) - f = six.moves.urllib.request.urlopen(url, timeout=portal_timeout) # python >= 2.7 + f = six.moves.urllib.request.urlopen( + url, timeout=portal_timeout + ) # python >= 2.7 except: log("download failed: exception:\n%s" % traceback.format_exc()) log("called from:\n" + "".join(traceback.format_stack())) diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index 21e928624..d3f91400e 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -465,7 +465,7 @@ def Excel_feuille_placement( # ajuste largeurs colonnes (unite inconnue, empirique) width = 4500 if nbcolumns > 5: - width = 22500 / nbcolumns + width = 22500 // nbcolumns for col in range(nbcolumns): ws0.col(col + 1).width = width