5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from logilab.mtconverter import xml_escape |
|
11 |
|
12 import locale |
|
13 import sys |
10 import sys |
14 import decimal |
11 import decimal |
15 import datetime |
12 import datetime |
16 from md5 import md5 |
13 import random |
17 from time import time |
14 |
18 from random import randint, seed |
15 from logilab.mtconverter import xml_escape |
|
16 from logilab.common.deprecation import deprecated |
19 |
17 |
20 # initialize random seed from current time |
18 # initialize random seed from current time |
21 seed() |
19 random.seed() |
22 |
20 |
23 if sys.version_info[:2] < (2, 5): |
21 if sys.version_info[:2] < (2, 5): |
|
22 |
|
23 from time import time |
|
24 from md5 import md5 |
|
25 from random import randint |
|
26 |
24 def make_uid(key): |
27 def make_uid(key): |
25 """forge a unique identifier |
28 """forge a unique identifier |
26 not that unique on win32""" |
29 not that unique on win32""" |
27 msg = str(key) + "%.10f" % time() + str(randint(0, 1000000)) |
30 msg = str(key) + "%.10f" % time() + str(randint(0, 1000000)) |
28 return md5(msg).hexdigest() |
31 return md5(msg).hexdigest() |
|
32 |
29 else: |
33 else: |
|
34 |
30 from uuid import uuid4 |
35 from uuid import uuid4 |
|
36 |
31 def make_uid(key): |
37 def make_uid(key): |
32 # remove dash, generated uid are used as identifier sometimes (sql table |
38 # remove dash, generated uid are used as identifier sometimes (sql table |
33 # names at least) |
39 # names at least) |
34 return str(key) + str(uuid4()).replace('-', '') |
40 return str(key) + str(uuid4()).replace('-', '') |
35 |
41 |