U
vi @ s d dl mZmZmZmZ d dlmZmZmZ d dlm Z
d dlmZ d dl
mZ edZdeee eee gee f d d
dZdeee eeee gee f dd
dZddgZdS ) )CallableOptionalTypeVarcast)
Observableabccompose) operators)SequenceContainsNoElementsError) Predicate_TFN)has_default
default_valuereturnc s" t t t t d fdd}|S )N)sourcer c s. dt jt tt j d fdd
}t|S )N)observer schedulerc sJ t tdtd fdd} fdd}j| j||dS )NFxc s r td n| dd S )Nz'Sequence contains more than one elementT)on_error Exceptionr r
seen_valuevalue U/opt/alt/python38/lib/python3.8/site-packages/reactivex/operators/_singleordefault.pyon_next s z]single_or_default_async_..single_or_default_async..subscribe..on_nextc s, s s t n d S )N)r r
r on_completedr )r
r r r r r r ! s
zbsingle_or_default_async_..single_or_default_async..subscribe..on_completed)r )r r subscriber )r r r r )r r
r r r r s
zLsingle_or_default_async_..single_or_default_async..subscribe)N)r ZObserverBaser r Z
SchedulerBaser )r r r r
)r r single_or_default_async s z9single_or_default_async_..single_or_default_async)r r )r
r r r r r single_or_default_async_ s r! ) predicater r c C s* | rt t| td|S td|S dS )a Returns the only element of an observable sequence that matches
the predicate, or a default value if no such element exists this
method reports an exception if there is more than one element in the
observable sequence.
Examples:
>>> res = single_or_default()
>>> res = single_or_default(lambda x: x == 42)
>>> res = single_or_default(lambda x: x == 42, 0)
>>> res = single_or_default(None, 0)
Args:
predicate -- [Optional] A predicate function to evaluate for
elements in the source sequence.
default_value -- [Optional] The default value if the index is
outside the bounds of the source sequence.
Returns:
An observable Sequence containing the single element in the
observable sequence that satisfies the condition in the predicate,
or a default value if no such element exists.
NT)r opsfilterZsingle_or_defaultr! )r" r r r r single_or_default_1 s
r% )FN)NN)typingr r r r Z reactivexr r r r r# Zreactivex.internal.exceptionsr
Zreactivex.typingr r boolr! r% __all__r r r r s( '
"