equal
deleted
inserted
replaced
9 |
9 |
10 import sys |
10 import sys |
11 import decimal |
11 import decimal |
12 import datetime |
12 import datetime |
13 import random |
13 import random |
|
14 from uuid import uuid4 |
14 |
15 |
15 from logilab.mtconverter import xml_escape |
16 from logilab.mtconverter import xml_escape |
16 from logilab.common.deprecation import deprecated |
17 from logilab.common.deprecation import deprecated |
17 |
18 |
18 # initialize random seed from current time |
19 # initialize random seed from current time |
19 random.seed() |
20 random.seed() |
20 |
21 |
21 if sys.version_info[:2] < (2, 5): |
22 def make_uid(key): |
22 |
23 # remove dash, generated uid are used as identifier sometimes (sql table |
23 from time import time |
24 # names at least) |
24 from md5 import md5 |
25 return str(key) + str(uuid4()).replace('-', '') |
25 from random import randint |
|
26 |
|
27 def make_uid(key): |
|
28 """forge a unique identifier |
|
29 XXX not that unique on win32 |
|
30 """ |
|
31 key = str(key) |
|
32 msg = key + "%.10f" % time() + str(randint(0, 1000000)) |
|
33 return key + md5(msg).hexdigest() |
|
34 |
|
35 else: |
|
36 |
|
37 from uuid import uuid4 |
|
38 |
|
39 def make_uid(key): |
|
40 # remove dash, generated uid are used as identifier sometimes (sql table |
|
41 # names at least) |
|
42 return str(key) + str(uuid4()).replace('-', '') |
|
43 |
26 |
44 |
27 |
45 def dump_class(cls, clsname): |
28 def dump_class(cls, clsname): |
46 """create copy of a class by creating an empty class inheriting |
29 """create copy of a class by creating an empty class inheriting |
47 from the given cls. |
30 from the given cls. |