equal
deleted
inserted
replaced
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from logilab.mtconverter import xml_escape |
10 from logilab.mtconverter import xml_escape |
11 |
11 |
12 import locale |
12 import locale |
|
13 import sys |
|
14 import decimal |
|
15 import datetime as pydatetime |
13 from md5 import md5 |
16 from md5 import md5 |
14 import datetime as pydatetime |
|
15 from datetime import datetime, timedelta, date |
17 from datetime import datetime, timedelta, date |
16 from time import time, mktime |
18 from time import time, mktime |
17 from random import randint, seed |
19 from random import randint, seed |
18 from calendar import monthrange |
20 from calendar import monthrange |
19 import decimal |
|
20 |
21 |
21 import simplejson |
22 import simplejson |
22 |
23 |
23 # initialize random seed from current time |
24 # initialize random seed from current time |
24 seed() |
25 seed() |
105 """ |
106 """ |
106 # date format may depend on the locale |
107 # date format may depend on the locale |
107 encoding = locale.getpreferredencoding(do_setlocale=False) or 'UTF-8' |
108 encoding = locale.getpreferredencoding(do_setlocale=False) or 'UTF-8' |
108 return unicode(date.strftime(str(fmt)), encoding) |
109 return unicode(date.strftime(str(fmt)), encoding) |
109 |
110 |
110 def make_uid(key): |
111 |
111 """forge a unique identifier""" |
112 if sys.version_info[:2] < (2, 5): |
112 msg = str(key) + "%.10f" % time() + str(randint(0, 1000000)) |
113 def make_uid(key): |
113 return md5(msg).hexdigest() |
114 """forge a unique identifier |
114 |
115 not that unique on win32""" |
|
116 msg = str(key) + "%.10f" % time() + str(randint(0, 1000000)) |
|
117 return md5(msg).hexdigest() |
|
118 else: |
|
119 from uuid import uuid4 |
|
120 def make_uid(key): |
|
121 return str(key) + str(uuid4()) |
115 |
122 |
116 def dump_class(cls, clsname): |
123 def dump_class(cls, clsname): |
117 """create copy of a class by creating an empty class inheriting |
124 """create copy of a class by creating an empty class inheriting |
118 from the given cls. |
125 from the given cls. |
119 |
126 |