[lc_ldap] Corrections de bugs, et cohérence de code.
This commit is contained in:
parent
6d4d56db72
commit
7ed1874d62
4 changed files with 26 additions and 14 deletions
|
@ -243,7 +243,7 @@ def hash_password(password, salt=None, longueur=4):
|
|||
raise ValueError("salt devrait faire au moins 4 octets")
|
||||
if salt is None:
|
||||
salt = os.urandom(longueur)
|
||||
elif len(salt)<4:
|
||||
elif len(salt) < 4:
|
||||
raise ValueError("salt devrait faire au moins 4 octets")
|
||||
|
||||
return '{SSHA}' + base64.b64encode(hashlib.sha1(password + salt).digest() + salt)
|
||||
|
@ -306,14 +306,14 @@ def ip4_addresses():
|
|||
ip_list.append(link['addr'])
|
||||
return ip_list
|
||||
|
||||
def extractTz(thetz):
|
||||
def extract_tz(thetz):
|
||||
abstz = 100*abs(thetz)
|
||||
if thetz == 0:
|
||||
return u"Z"
|
||||
else:
|
||||
return u"%s%04d" % ("+"*(thetz < 0) + "-"*(thetz > 0), abstz)
|
||||
|
||||
def toGeneralizedTimeFormat(stamp):
|
||||
def to_generalized_time_format(stamp):
|
||||
"""Converts a timestamp (local) in a generalized time format
|
||||
for LDAP.
|
||||
|
||||
|
@ -322,9 +322,9 @@ def toGeneralizedTimeFormat(stamp):
|
|||
|
||||
"""
|
||||
|
||||
return u"%s%s" % (time.strftime("%Y%m%d%H%M%S", time.localtime(stamp)), extractTz(time.altzone/3600))
|
||||
return u"%s%s" % (time.strftime("%Y%m%d%H%M%S", time.localtime(stamp)), extract_tz(time.altzone/3600))
|
||||
|
||||
def fromGeneralizedTimeFormat(gtf):
|
||||
def from_generalized_time_format(gtf):
|
||||
"""Converts a GTF stamp to unix timestamp
|
||||
|
||||
* gtf : a generalized time format resource without dotsecond
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue