3 # searches and displays any local orphan account (not attached to a site)
4 # remote accounts with identical emails are displayed as well
8 # sort filters look broken
9 def sort_email (p1,p2):
10 if p1['email'] == p2['email']: return 0
11 if p1['email'] < p2['email'] : return -1
15 orphans = [p for p in GetPersons({'peer_id':None,'-SORT':'email'}) if not p['site_ids'] ]
16 orphans.sort(sort_email)
19 def list_person (margin,p):
20 print margin,'%6d'%p['person_id'], time.asctime(time.gmtime(p['date_created'])),
21 if not p['peer_id']: print 'LOCAL',
22 else: print 'pr=',p['peer_id'],
23 if p['enabled']: print 'ENB',
27 def get_related(email):
28 return GetPersons ({'email':email,'~peer_id':None})
31 print '--------------------'
33 print time.asctime(time.gmtime())
34 print 'Listing orphan accounts and any similar remote'
35 print '--------------------'
38 orphans = get_orphans()
39 header ('Listing %d local accounts with no site - and similar remote accounts'%len(orphans))
42 list_person ("%3d"%index,p)
43 for related in get_related(p['email']):
44 list_person("dup",related)
47 def main_duplicates():
49 header ('Listing all duplicate accounts')
50 locals = GetPersons({'peer_id':None,'-SORT':'email'})
51 locals.sort(sort_email)
53 remotes=GetPersons({'email':local['email'],'~peer_id':None})
55 list_person('---',local)
56 for remote in remotes:
57 list_person('dup',remote)
63 if __name__ == '__main__':