22 lines
632 B
Python
22 lines
632 B
Python
from functools import reduce
|
|
from math import cos, radians, sqrt
|
|
|
|
def choices_length (choices):
|
|
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
|
|
|
|
def en_scolarite(user):
|
|
return user.profil.en_scolarite
|
|
|
|
def approximate_distance(a, b):
|
|
lat_a = radians(a.y)
|
|
lat_b = radians(b.y)
|
|
dlon = radians(b.x - a.x)
|
|
dlon = dlon * cos((lat_a + lat_b)/2)
|
|
dlat = (lat_a - lat_b)
|
|
distance = 6371000 * sqrt(dlon*dlon + dlat*dlat)
|
|
return distance
|
|
|
|
def is_email_ens(mail, none=False):
|
|
if mail is None:
|
|
return none
|
|
return mail.endswith(".ens.fr") or mail.endswith(".ens.psl.eu")
|