|
@@ -81,9 +81,37 @@ def delete_contacts(delete_candidates):
|
|
|
personal_contacts[c].delete()
|
|
|
|
|
|
|
|
|
+def normalize_phone_number(phone_number: str):
|
|
|
+ if phone_number is None:
|
|
|
+ return None
|
|
|
+ if phone_number.startswith('0'):
|
|
|
+ phone_number = '+49 ' + phone_number[1:]
|
|
|
+ for c in '()/?':
|
|
|
+ phone_number = phone_number.replace(c, '')
|
|
|
+ return phone_number.replace(' -', '-').replace('- ', '-').replace(' ', ' ')
|
|
|
+
|
|
|
+
|
|
|
+def cleanup_contacts():
|
|
|
+ account.authenticate()
|
|
|
+ shared = account.address_book(resource='adressbuch@global-cube.net', address_book='personal')
|
|
|
+
|
|
|
+ for p in shared.get_contacts(limit=None):
|
|
|
+ business = [normalize_phone_number(no) for no in p.business_phones]
|
|
|
+ if p.business_phones != business:
|
|
|
+ p.business_phones = business
|
|
|
+ home = [normalize_phone_number(no) for no in p.home_phones]
|
|
|
+ if p.home_phones != home:
|
|
|
+ p.home_phones = home
|
|
|
+ mobile = normalize_phone_number(p.mobile_phone)
|
|
|
+ if p.mobile_phone != mobile:
|
|
|
+ p.mobile_phone = mobile
|
|
|
+ p.save()
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
- # sync_contacts()
|
|
|
- delete_contacts(['Kia Kia Hotline', 'Marcel J.G. Kamps', 'Kevin Baumann (next motion)', 'Marius kling', 'Herr Haase', 'Birgit Dingfeldt'])
|
|
|
+ sync_contacts()
|
|
|
+ # delete_contacts({'Peugeot Peugeot / Citroen - Hotline'})
|
|
|
+ # cleanup_contacts()
|
|
|
# gal = account.directory()
|
|
|
# mails = [p.mail for p in gal.get_users()]
|
|
|
# print(mails)
|