original_docstring: 
      Add an attribute for the given account name.
  
      :param key: the key for the new attribute.
      :param value: the value for the new attribute.
      :param account: the account to add the attribute to.
      :param session: The database session in use.
      
docstring: Add an attribute for the given account name.
docstring_tokens: Add an attribute for the given account name .
code: def add_account_attribute(account, key, value, session=None):
      """
      Add an attribute for the given account name.
  
      :param key: the key for the new attribute.
      :param value: the value for the new attribute.
      :param account: the account to add the attribute to.
      :param session: The database session in use.
      """
  
      query = session.query(models.Account).filter_by(account=account, status=AccountStatus.ACTIVE)
  
      try:
          query.one()
      except exc.NoResultFound:
          raise exception.AccountNotFound("Account ID '{0}' does not exist".format(account))
  
      new_attr = models.AccountAttrAssociation(account=account, key=key, value=value)
      try:
          new_attr.save(session=session)
      except IntegrityError as error:
          if match('.*IntegrityError.*ORA-00001: unique constraint.*ACCOUNT_ATTR_MAP_PK.*violated.*', error.args[0]) \
             or match('.*IntegrityError.*1062, "Duplicate entry.*for key.*', error.args[0]) \
             or error.args[0] == "(IntegrityError) column account/key is not unique" \
             or match('.*IntegrityError.*duplicate key value violates unique constraint.*', error.args[0]):
              raise exception.Duplicate('Key {0} already exist for account {1}!'.format(key, account))
      except Exception:
          raise exception.RucioException(str(format_exc()))
code_tokens: def add_account_attribute ( account , key , value , session = None ) : query = session . query ( models . Account ) . filter_by ( account = account , status = AccountStatus . ACTIVE ) try : query . one ( ) except exc . NoResultFound : raise exception . AccountNotFound ( "Account ID '{0}' does not exist" . format ( account ) ) new_attr = models . AccountAttrAssociation ( account = account , key = key , value = value ) try : new_attr . save ( session = session ) except IntegrityError as error : if match ( '.*IntegrityError.*ORA-00001: unique constraint.*ACCOUNT_ATTR_MAP_PK.*violated.*' , error . args [ 0 ] ) or match ( '.*IntegrityError.*1062, "Duplicate entry.*for key.*' , error . args [ 0 ] ) or error . args [ 0 ] == "(IntegrityError) column account/key is not unique" or match ( '.*IntegrityError.*duplicate key value violates unique constraint.*' , error . args [ 0 ] ) : raise exception . Duplicate ( 'Key {0} already exist for account {1}!' . format ( key , account ) ) except Exception : raise exception . RucioException ( str ( format_exc ( ) ) )
short_docstring: Add an attribute for the given account name.
short_docstring_tokens: Add an attribute for the given account name .
comment: """
      Add an attribute for the given account name.
  
      :param key: the key for the new attribute.
      :param value: the value for the new attribute.
      :param account: the account to add the attribute to.
      :param session: The database session in use.
      """