Project

General

Profile

« Previous | Next » 

Revision 99b661d3

Added by Jérôme Schneider over 10 years ago

anonimize.py: improve anonymization

View differences:

anonimize.py
18 18
last = []
19 19
first = []
20 20
random.seed()
21
l = -1
22 21
for p in People.objects.all():
23 22
    if p.last_name:
24 23
        last.append(p.last_name)
25 24
    if p.first_name:
26 25
        first.append(p.first_name)
27
    l += 1
26

  
27
len_first = len(first) - 1
28
len_last = len(last) - 1
29

  
28 30
for p in People.objects.all():
29
    i = random.randint(0, l)
31
    i = random.randint(0, len_last)
30 32
    p.last_name = last[i]
31
    if (p.last_name) > 5:
33
    if len(p.last_name) > 5:
32 34
        p.last_name = p.last_name[:-2] + 'zz'
33
    i = random.randint(0, l)
35
    i = random.randint(0, len_first)
34 36
    p.first_name = first[i]
35 37
    p.save()
36 38

  

Also available in: Unified diff