1
0
forked from ScoDoc/ScoDoc

fix some divisions for py3

This commit is contained in:
Emmanuel Viennet 2021-07-09 19:50:40 +02:00
parent 9199a01f94
commit 79b8b3c180
9 changed files with 18 additions and 14 deletions

View File

@ -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"]

View File

@ -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)

View File

@ -941,7 +941,9 @@ def MonthTableBody(
if legend or d == 1:
n = 3 - len(legend) # pad to 3 cars
if n > 0:
legend = "&nbsp;" * (n / 2) + legend + "&nbsp;" * ((n + 1) / 2)
legend = (
"&nbsp;" * (n // 2) + legend + "&nbsp;" * ((n + 1) // 2)
)
else:
legend = "&nbsp;&nbsp;&nbsp;" # empty cell
cc.append(legend)

View File

@ -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)

View File

@ -141,7 +141,7 @@ def etud_upload_file_form(context, REQUEST, etudid):
% etud,
"""<p>Le fichier ne doit pas dépasser %sMo.</p>
"""
% (scu.CONFIG.ETUD_MAX_FILE_SIZE / (1024 * 1024)),
% (scu.CONFIG.ETUD_MAX_FILE_SIZE // (1024 * 1024)),
]
tf = TrivialFormulator(
REQUEST.URL0,

View File

@ -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"],

View File

@ -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
# --------------------------------------------------------------------

View File

@ -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()))

View File

@ -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