def sync_permissions()

in ees_sharepoint/permission_sync_command.py [0:0]


    def sync_permissions(self):
        """This method when invoked, checks the permission of SharePoint users and update those user
        permissions in the Workplace Search."""
        rows = {}
        if os.path.exists(self.mapping_sheet_path) and os.path.getsize(self.mapping_sheet_path) > 0:
            with open(self.mapping_sheet_path) as file:
                csvreader = csv.reader(file)
                for row in csvreader:
                    rows[row[0]] = row[1]

        users = self.get_users_id()
        user_names = {}
        user_groups = {}
        if users:
            for collection in self.site_collections:
                user_name_collection = {}
                for user, user_id in users[collection].items():
                    user_name_collection.update({rows.get(user, user): user_id})
                user_names.update({collection: user_name_collection})
            user_groups = self.get_user_groups(user_names)
            # delete all the permissions present in workplace search
            self.permissions.remove_all_permissions()
            if user_groups:
                # add all the updated permissions
                self.workplace_add_permission(user_groups)