comparison src/tools/utils.py @ 2477:cae326e962c3

tool (utils): import directly parser from dateutil
author Goffi <goffi@goffi.org>
date Sun, 21 Jan 2018 13:04:16 +0100
parents 8084066ac95b
children 0046283a285d
comparison
equal deleted inserted replaced
2476:6607bb29ab7b 2477:cae326e962c3
22 import unicodedata 22 import unicodedata
23 import os.path 23 import os.path
24 from sat.core.log import getLogger 24 from sat.core.log import getLogger
25 log = getLogger(__name__) 25 log = getLogger(__name__)
26 import datetime 26 import datetime
27 import dateutil 27 from dateutil import parser as dateutil_parser
28 import calendar 28 import calendar
29 import time 29 import time
30 import sys 30 import sys
31 import random 31 import random
32 import inspect 32 import inspect
87 """Parse a date and return corresponding unix timestamp 87 """Parse a date and return corresponding unix timestamp
88 88
89 @param value(unicode): date to parse, in any format supported by dateutil.parser 89 @param value(unicode): date to parse, in any format supported by dateutil.parser
90 @return (int): timestamp 90 @return (int): timestamp
91 """ 91 """
92 return calendar.timegm(dateutil.parser.parse(unicode(value)).utctimetuple()) 92 return calendar.timegm(dateutil_parser.parse(unicode(value)).utctimetuple())
93 93
94 def generatePassword(vocabulary=None, size=20): 94 def generatePassword(vocabulary=None, size=20):
95 """Generate a password with random characters. 95 """Generate a password with random characters.
96 96
97 @param vocabulary(iterable): characters to use to create password 97 @param vocabulary(iterable): characters to use to create password