root / snf-astakos-app / astakos / quotaholder / utils / newname.py @ e03ccd07
History | View | Annotate | Download (1.7 kB)
1 | b0727daf | Giorgos Korfiatis | # Copyright 2012, 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | b0727daf | Giorgos Korfiatis | #
|
3 | b0727daf | Giorgos Korfiatis | # Redistribution and use in source and binary forms, with or
|
4 | b0727daf | Giorgos Korfiatis | # without modification, are permitted provided that the following
|
5 | b0727daf | Giorgos Korfiatis | # conditions are met:
|
6 | b0727daf | Giorgos Korfiatis | #
|
7 | b0727daf | Giorgos Korfiatis | # 1. Redistributions of source code must retain the above
|
8 | b0727daf | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
9 | b0727daf | Giorgos Korfiatis | # disclaimer.
|
10 | b0727daf | Giorgos Korfiatis | #
|
11 | b0727daf | Giorgos Korfiatis | # 2. Redistributions in binary form must reproduce the above
|
12 | b0727daf | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
13 | b0727daf | Giorgos Korfiatis | # disclaimer in the documentation and/or other materials
|
14 | b0727daf | Giorgos Korfiatis | # provided with the distribution.
|
15 | b0727daf | Giorgos Korfiatis | #
|
16 | b0727daf | Giorgos Korfiatis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | b0727daf | Giorgos Korfiatis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | b0727daf | Giorgos Korfiatis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | b0727daf | Giorgos Korfiatis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | b0727daf | Giorgos Korfiatis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | b0727daf | Giorgos Korfiatis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | b0727daf | Giorgos Korfiatis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | b0727daf | Giorgos Korfiatis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | b0727daf | Giorgos Korfiatis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | b0727daf | Giorgos Korfiatis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | b0727daf | Giorgos Korfiatis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | b0727daf | Giorgos Korfiatis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | b0727daf | Giorgos Korfiatis | #
|
29 | b0727daf | Giorgos Korfiatis | # The views and conclusions contained in the software and
|
30 | b0727daf | Giorgos Korfiatis | # documentation are those of the authors and should not be
|
31 | b0727daf | Giorgos Korfiatis | # interpreted as representing official policies, either expressed
|
32 | b0727daf | Giorgos Korfiatis | # or implied, of GRNET S.A.
|
33 | b0727daf | Giorgos Korfiatis | |
34 | b0727daf | Giorgos Korfiatis | from time import time |
35 | b0727daf | Giorgos Korfiatis | |
36 | b0727daf | Giorgos Korfiatis | _counter = 0
|
37 | b0727daf | Giorgos Korfiatis | |
38 | b0727daf | Giorgos Korfiatis | def newname(prefix): |
39 | b0727daf | Giorgos Korfiatis | global _counter;
|
40 | b0727daf | Giorgos Korfiatis | _counter += 1
|
41 | b0727daf | Giorgos Korfiatis | ident = id(locals()) |
42 | b0727daf | Giorgos Korfiatis | nonce = int(time() * 1000) + _counter |
43 | b0727daf | Giorgos Korfiatis | return "%s%x%x" % (prefix, ident, nonce) |