original_docstring: 
          Replace all email-based entries matching the user's email
          addresses with user-based entries.
  
          If the user is already in the ACL, the two entries are merged.
  
          :param user: A User object.
          :param relationship_attr: The name of the relationship pointing
                                    to the object associated with the ACL
                                    entry.
          :return: The set of objects where the user has been added to
                   the ACL.
          
docstring: Replace all email-based entries matching the user's email
  addresses with user-based entries.
  
  If the user is already in the ACL, the two entries are merged.
docstring_tokens: Replace all email - based entries matching the user ' s email addresses with user - based entries . If the user is already in the ACL the two entries are merged .
code: def replace_email_with_user(cls, user, relationship_attr):
          """
          Replace all email-based entries matching the user's email
          addresses with user-based entries.
  
          If the user is already in the ACL, the two entries are merged.
  
          :param user: A User object.
          :param relationship_attr: The name of the relationship pointing
                                    to the object associated with the ACL
                                    entry.
          :return: The set of objects where the user has been added to
                   the ACL.
          """
          assert cls.allow_emails
          updated = set()
          query = (cls
                   .find(cls.email.in_(user.all_emails))
                   .options(noload('user'), noload('local_group'), joinedload(relationship_attr).load_only('id')))
          for entry in query:
              parent = getattr(entry, relationship_attr)
              existing = (cls.query
                          .with_parent(parent, 'acl_entries')
                          .options(noload('user'), noload('local_group'))
                          .filter_by(principal=user)
                          .first())
              if existing is None:
                  entry.principal = user
              else:
                  existing.merge_privs(entry)
                  parent.acl_entries.remove(entry)
              updated.add(parent)
          db.session.flush()
          return updated
code_tokens: def replace_email_with_user ( cls , user , relationship_attr ) : assert cls . allow_emails updated = set ( ) query = ( cls . find ( cls . email . in_ ( user . all_emails ) ) . options ( noload ( 'user' ) , noload ( 'local_group' ) , joinedload ( relationship_attr ) . load_only ( 'id' ) ) ) for entry in query : parent = getattr ( entry , relationship_attr ) existing = ( cls . query . with_parent ( parent , 'acl_entries' ) . options ( noload ( 'user' ) , noload ( 'local_group' ) ) . filter_by ( principal = user ) . first ( ) ) if existing is None : entry . principal = user else : existing . merge_privs ( entry ) parent . acl_entries . remove ( entry ) updated . add ( parent ) db . session . flush ( ) return updated
short_docstring: Replace all email-based entries matching the user's email
  addresses with user-based entries.
short_docstring_tokens: Replace all email - based entries matching the user ' s email addresses with user - based entries .
comment: """
          Replace all email-based entries matching the user's email
          addresses with user-based entries.
  
          If the user is already in the ACL, the two entries are merged.
  
          :param user: A User object.
          :param relationship_attr: The name of the relationship pointing
                                    to the object associated with the ACL
                                    entry.
          :return: The set of objects where the user has been added to
                   the ACL.
          """