#NEWLINE# def pop( self , * args , **kwargs ) : #NEWLINE# #INDENT# "Populates a member of the set.\n\n        If ``key`` keyword argument or one or more positional\n        arguments have present, it behaves like :meth:`dict.pop()`\n        method:\n\n        :param key: the member to populate.  it will be removed if\n                    it exists\n        :param default: the default value returned instead of the\n                        member (``key``) when it doesn't exist.\n                        default is ``None``\n        :returns: the score of the member before the operation\n                  has been committed\n        :rtype: :class:`numbers.Real`\n\n        .. note::\n\n           It internally uses :redis:`ZSCORE`, :redis:`ZREM` or\n           :redis:`ZINCRBY` (total 2 commands) in a transaction.\n\n        If no positional arguments or no ``key`` keyword argument,\n        it behaves like :meth:`set.pop()` method.  Basically it\n        does the same thing with :meth:`popitem()` except it\n        returns just a popped value (while :meth:`popitem()`\n        returns a pair of popped value and its score).\n\n        :param desc: keyword only.  by default, it populates\n                     the member of the lowest score, but if you\n                     pass ``True`` to this it will populates\n                     the highest instead.  default is ``False``\n        :type desc: :class:`bool`\n        :returns: the populated member.  it will be the lowest\n                  scored member or the highest scored member\n                  if ``desc`` is ``True``\n        :raises exceptions.KeyError: when the set is empty\n\n        .. note::\n\n           It internally uses :redis:`ZRANGE` or :redis:`ZREVRANGE`,\n           :redis:`ZREM` or :redis:`ZINCRBY` (total 2 commands)\n           in a transaction.\n\n        .. seealso::\n\n           Method :meth:`popitem()`\n\n        If any case there are common keyword-only parameters:\n\n        :param score: keyword only.  the amount to decrease\n                      the score.  default is 1\n        :type score: :class:`numbers.Real`\n        :param remove: keyword only.\n                       the threshold score to be removed.\n                       if ``None`` is passed, it doesn't remove\n                       the member but only decreases its score\n                       (it makes ``score`` argument meaningless).\n                       default is 0.\n        :type remove: :class:`numbers.Real`\n\n        " #NEWLINE# score = kwargs . pop ( 'score' , 1 ) #NEWLINE# remove = kwargs . pop ( 'remove' , 0 ) #NEWLINE# ar_len = len ( args ) #NEWLINE# kw_len = len ( kwargs ) #NEWLINE# kw_desc = ( 'desc' in kwargs ) #NEWLINE# kw_key = ( 'key' in kwargs ) #NEWLINE# kw_default = ( 'default' in kwargs ) #NEWLINE# if ( ( not kw_default ) and ( ( not kwargs ) or ( ( kw_len == 1 ) and kw_desc ) ) ) : #NEWLINE# #INDENT# pair = self . popitem ( * args , score = score , remove = remove , ** kwargs ) #NEWLINE# return pair [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( ( not args ) and ( kw_len == 2 ) and kw_key and kw_default ) or ( ( ar_len == 1 ) and ( ( not kwargs ) or ( ( kw_len == 1 ) and kw_default ) ) ) or ( ar_len == 2 ) ) : #NEWLINE# #INDENT# if ( ar_len == 2 ) : #NEWLINE# #INDENT# ( key , default ) = args #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ar_len == 1 ) : #NEWLINE# #INDENT# key = args [ 0 ] #NEWLINE# default = kwargs . get ( 'default' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# key = kwargs [ 'key' ] #NEWLINE# default = kwargs . get ( 'default' ) #NEWLINE# #UNINDENT# #UNINDENT# element = self . value_type . encode ( key ) #NEWLINE# current = [ None ] #NEWLINE# def block( trial , transaction ) : #NEWLINE# #INDENT# pipe = self . session . client #NEWLINE# self . session . mark_query ( ) #NEWLINE# current [ 0 ] = pipe . zscore ( self . key , element ) #NEWLINE# if ( current [ 0 ] is not None ) : #NEWLINE# #INDENT# self . session . mark_manipulative ( ) #NEWLINE# if ( ( remove is None ) or ( ( current [ 0 ] - score ) <= remove ) ) : #NEWLINE# #INDENT# pipe . zrem ( self . key , element ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pipe . zincrby ( self . key , value = element , amount = ( - score ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . session . transaction ( block , [ self . key ] , ignore_double = True ) #NEWLINE# if ( current [ 0 ] is None ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# return current [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( kw_desc and ( args or kw_key ) ) : #NEWLINE# #INDENT# raise TypeError ( 'desc option cannot be applied with key parameter at a time' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not args ) and ( not kw_key ) and kw_default ) : #NEWLINE# #INDENT# raise TypeError ( 'default option must be used with key argument' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( 'invalid argument(s)' )