def resources_to_contacts(): # Get Calendar Resources calendars = calendar_resource(options=options()).get_resource_feed( uri=options().calendar_resource_feed).entry # Select Calendars by options filtered_calendars = filter(lambda cal: \ fnmatch(cal.resource_email, options().select_pattern), calendars) # Fetch all domain users all_users = exhaust( admin(options=options()).users().list, dict(domain=options().domain, maxResults=500), 'users') # Get opt-out lists optout_emails_set = set() if not options().undo else get_optout_set( options().optout_uri) # Select domain users by options filtered_users = filtermap(lambda user: fnmatch(user['primaryEmail'], options().user_pattern) and \ unicode(user['primaryEmail']).lower() not in optout_emails_set, iget('primaryEmail'), all_users) logging.info( 'Starting Calendar Resource to Contacts Group copy operation. Selection is "%s" (%d calendar(s)) and target is "%s" (%d user(s))', options().select_pattern, len(filtered_calendars), options().user_pattern, len(filtered_users)) process_users(filtered_users, filtered_calendars)
def main_logging(): if options().delete_old and options().rename_old: sys.exit("Conflicting options detected, aborting") optout_emails_set = get_optout_set(options().optout_uri) users_to_copy, target_user_emails = select_users() target_user_emails = filter(lambda email: email.lower() not in optout_emails_set, target_user_emails) user_to_copy_by_ldap_dict = dict(zip(map(get_ldap_id_json, users_to_copy), users_to_copy)) logging.info('Starting Directory to Contacts Group copy operation. Selection is "%s" (%d user(s)) and target is "%s" (%d user(s))', options().select_pattern, len(users_to_copy), options().user_pattern, len(target_user_emails)) for target_user_email in target_user_emails: process_target_user(target_user_email, users_to_copy, user_to_copy_by_ldap_dict)
def main_logging(): if options().delete_old and options().rename_old: sys.exit("Conflicting options detected, aborting") optout_emails_set = get_optout_set(options().optout_uri) users_to_copy, target_user_emails = select_users() target_user_emails = filter( lambda email: email.lower() not in optout_emails_set, target_user_emails) user_to_copy_by_ldap_dict = dict( zip(map(get_ldap_id_json, users_to_copy), users_to_copy)) logging.info( 'Starting Directory to Contacts Group copy operation. Selection is "%s" (%d user(s)) and target is "%s" (%d user(s))', options().select_pattern, len(users_to_copy), options().user_pattern, len(target_user_emails)) for target_user_email in target_user_emails: process_target_user(target_user_email, users_to_copy, user_to_copy_by_ldap_dict)
def resources_to_contacts(): # Get Calendar Resources calendars = calendar_resource(options=options()).get_resource_feed(uri=options().calendar_resource_feed).entry # Select Calendars by options filtered_calendars = filter(lambda cal: \ fnmatch(cal.resource_email, options().select_pattern), calendars) # Fetch all domain users all_users = exhaust(admin(options=options()).users().list, dict(domain=options().domain, maxResults=500), 'users') # Get opt-out lists optout_emails_set = set() if not options().undo else get_optout_set(options().optout_uri) # Select domain users by options filtered_users = filtermap(lambda user: fnmatch(user['primaryEmail'], options().user_pattern) and \ unicode(user['primaryEmail']).lower() not in optout_emails_set, iget('primaryEmail'), all_users) logging.info('Starting Calendar Resource to Contacts Group copy operation. Selection is "%s" (%d calendar(s)) and target is "%s" (%d user(s))', options().select_pattern, len(filtered_calendars), options().user_pattern, len(filtered_users)) process_users(filtered_users, filtered_calendars)