U vi @sddlZddlmZmZmZmZddlmZmZddl m Z m Z ddl m Z mZddlmZedZedZd eeeeeegeeefd d d Zd gZdS) N)CallableListOptionalTypeVar) Observableabc)RefCountDisposableSingleAssignmentDisposable)ArgumentOutOfRangeExceptionadd_ref)SubjectZRx_T)countskipreturncsRdkrt|dk r|ndkr,ttttttdfdd }|S)aProjects each element of an observable sequence into zero or more windows which are produced based on element count information. Examples: >>> window_with_count(10) >>> window_with_count(10, 1) Args: count: Length of each window. skip: [Optional] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count. Returns: An observable sequence of windows. rN)sourcercs2dtjttttjdfdd }t|S)N)observer schedulercst}t|dggfddtddfdd }tddfdd }dd fd d }j||||d |_S)Nrcs$t}|t|dS)N)r appendon_nextr )s)rqrefCountDisposableU/opt/alt/python38/lib/python3.8/site-packages/reactivex/operators/_windowwithcount.py create_window4s zWwindow_with_count_..window_with_count..subscribe..create_window)xrcstD]}||qdd}|dkrJ|dkrJd}|dd7<ddkrpdS)Nr)rpop on_completed)ritemcr)rrnrskip_rrr;s  zQwindow_with_count_..window_with_count..subscribe..on_next) exceptionrcs$rd|q|dSNr)ron_error)r$rrrrr&HszRwindow_with_count_..window_with_count..subscribe..on_error)rcs rdqdSr%)rrrr'rrrMszVwindow_with_count_..window_with_count..subscribe..on_completed)r)r rr Exception subscribeZ disposable)rrmrr&r)rr#r)rr"rrrrr)+s  z@window_with_count_..window_with_count..subscribe)N)rZ ObserverBaserr rZ SchedulerBase)rr)rr#)rrwindow_with_count*s  ,z-window_with_count_..window_with_count)r rr )rrr,rr+rwindow_with_count_s"/r-)N)loggingtypingrrrrZ reactivexrrZreactivex.disposablerr Zreactivex.internalr r Zreactivex.subjectr getLoggerlogr intr-__all__rrrrs   N