import time from random import randint def uid(prefixe = ""): """construit un identifiant unique de 10 caracteres""" #representation de la date (annee/mois/jour/heure/min/seconde) base = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n", \ "o","p","q","r","s","t","u","v","w","x","y","z", \ "A","B","C","D","E","F","G","H","I","J","K","L", \ "M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", \ "2","3","4","5","6","7","8","9"] dat = time.gmtime() a = dat[0] ; m = dat[1] ; j = dat[2] ; h = dat[3] ; mn = dat[4] ; s = dat[5] a_, m_, j_, h_, mn_, s_ = base[(int(a)-2000)], base[int(m)], base[int(j)], base[int(h)], base[int(mn)], base[int(s)] #ajout de 2 caracteres aleatoires c1 = base[randint(0,59)] ; c2 = base[randint(0,59)] #concatenation if len(prefixe) >= 2: p_ = prefixe[0:2] else: while len(prefixe) < 2: prefixe += "-" p_ = prefixe retour = "{}{}{}{}{}{}{}{}{}".format(p_, a_, m_, j_, h_, mn_, s_, c1, c2) return retour