fu$2dZddlmZddlmZmZmZddlmZm Z m Z m Z ddl m Z ddlmZddlmZddlmZmZer2dd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!ddl"m#Z#m$Z$GddZ%Gdde%Z&Gdde&Z'Gdde%Z(y)z;Perform aggregation operations on a collection or database.) annotations)CallableMappingMutableMapping) TYPE_CHECKINGAnyOptionalUnion)common)validate_collation_or_none)ConfigurationError)ReadPreference _AggWritePref) ClientSession) Collection) CommandCursor)Database) Connection) _ServerMode)Server) _DocumentType _PipelineceZdZdZ d d dZed dZed dZddZeddZ ddZ dd Z y)_AggregationCommandzThe internal abstract base class for aggregation cursors. Should not be called directly by application developers. Use :meth:`pymongo.collection.Collection.aggregate`, or :meth:`pymongo.database.Database.aggregate` instead. Nc d|vr td||_tjd|}||_d|_|rd|dvsd|dvrd|_tj d ||tj d |||d <| | |d <||_tjd |jjd d|_ |jjd i|j(|j s|j|jd d <||_ ||_ ||_||_t!|jdd|_|jdd|_d|_y)NexplainzBThe explain option is not supported. Use Database.command instead.pipelineFz$outz$mergeToptionsletcomment batchSizecursor collationmaxAwaitTimeMS)r _targetr validate_list _pipeline_performs_writevalidate_is_mapping_options%validate_non_negative_integer_or_nonepop _batch_size setdefault _cursor_class_explicit_session _user_fields_result_processorr _collation_max_await_time_ms_write_preference) selftarget cursor_classrrexplicit_sessionr user_fieldsresult_processorr!s \/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/pymongo/aggregation.py__init__z_AggregationCommand.__init__-so  $T  '' H=!$ 8B</8x|3K#'D ""9g6 ?  & &uc 2 GEN  !(GI  "GG **;=    2.    '0D0D373C3CDMM( #K 0)!1'!14W[[d5ST")++.>"E:>ct)z.The argument to pass to the aggregate command.NotImplementedErrorr7s r=_aggregation_targetz'_AggregationCommand._aggregation_targetf "!r?ct)z4The namespace in which the aggregate command is run.rArCs r=_cursor_namespacez%_AggregationCommand._cursor_namespacekrEr?ct5The Collection used for the aggregate command cursor.rA)r7 cursor_docs r=_cursor_collectionz&_AggregationCommand._cursor_collectionps!!r?ct)z:The database against which the aggregation command is run.rArCs r= _databasez_AggregationCommand._databasetrEr?c|jr |jS|jj|}|jr%|tj k7rt |x|_}|SN)r6r&_read_preference_forr)rPRIMARYr)r7sessionprefs r=get_read_preferencez'_AggregationCommand.get_read_preferenceysZ  ! !)) )||009   DN,B,B$B,9$,? ?D "T r?c |j|jd}|j|jd|vr2|jr|j dk\r|j j}nd}d|vr(|jr|j j|}nd}|j|jj|||j jd|||j||jj|j }|j r|j!||d|vr|d} n d|j#d g|j$d } |j'|j)| | |j*|j,xsd|j.||j0|jj#d  } | j3|| S) N) aggregater readConcern writeConcernT)parse_write_concern_error read_concern write_concernr$rSclientr;r#rresult)id firstBatchnsr!) batch_sizemax_await_time_msrSr:r!)rDr(updater+r)max_wire_versionr&r\_write_concern_forcommandrNname codec_optionsr4r^r2r3getrGr0rLaddressr.r5r1_maybe_pin_connection) r7rSserverconnread_preferencecmdr\r]r_r# cmd_cursors r= get_cursorz_AggregationCommand.get_cursors!44$..Q 4==!  $$$)>)>!)C<<44LL  $)=)= LL;;GDM M NN     LL & &&*%'oo>>(())    ! !  " "64 0 v H%F$jj26,,F''  # #F +  LL'',1"55!33MM%%i0(   ((.r?)NNNN)r8zUnion[Database, Collection]r9ztype[CommandCursor]rrrzMutableMapping[str, Any]r:boolr zOptional[Mapping[str, Any]]r;z"Optional[MutableMapping[str, Any]]r<z9Optional[Callable[[Mapping[str, Any], Connection], None]]r!rreturnNone)ruzUnion[str, int]rustr)rKMapping[str, Any]rurrur)rSOptional[ClientSession]ruz!Union[_AggWritePref, _ServerMode]) rSr{rnrrorrprruzCommandCursor[_DocumentType]) __name__ __module__ __qualname____doc__r>propertyrDrGrLrNrUrsr?r=rr%s,0:>VZ7?+7?*7? 7? * 7?  7?)7?87?T7?7? 7?r""""""". *G(GG G % G & Gr?rcVeZdZUded<eddZeddZd dZed dZy) _CollectionAggregationCommandrr&c.|jjSrPr&rirCs r=rDz1_CollectionAggregationCommand._aggregation_targets||   r?c.|jjSrP)r& full_namerCs r=rGz/_CollectionAggregationCommand._cursor_namespaces||%%%r?c|jSrIr&)r7r#s r=rLz0_CollectionAggregationCommand._cursor_collection ||r?c.|jjSrP)r&databaserCs r=rNz'_CollectionAggregationCommand._databases||$$$r?Nrwr#ryrurrz) r|r}r~__annotations__rrDrGrLrNrr?r=rrsG  !!&&%%r?rc eZdZdfd ZxZS) _CollectionRawAggregationCommandcbt||i||jsd|jdd<yy)Nrr#r")superr>r)r+)r7argskwargs __class__s r=r>z)_CollectionRawAggregationCommand.__init__s8 $)&)##34DMM( #K 0$r?)rrrrrurv)r|r}r~r> __classcell__)rs@r=rrs 55r?rcVeZdZUded<eddZed dZed dZd dZy) _DatabaseAggregationCommandrr&cy)NrrCs r=rDz/_DatabaseAggregationCommand._aggregation_targetsr?c4|jjdS)Nz.$cmd.aggregaterrCs r=rGz-_DatabaseAggregationCommand._cursor_namespaces,,##$O44r?c|jSrPrrCs r=rNz%_DatabaseAggregationCommand._databaserr?c~|jd|jjdd\}}|j|S)rJrb.r)rkrGsplitrN)r7r#_collnames r=rLz._DatabaseAggregationCommand._cursor_collections: jjt'='=>DDS!L 8~~h''r?N)ruintrwrzr) r|r}r~rrrDrGrNrLrr?r=rrsG  55(r?rN))r __future__rcollections.abcrrrtypingrrr r pymongor pymongo.collationr pymongo.errorsr pymongo.read_preferencesrrpymongo.client_sessionrpymongo.collectionrpymongo.command_cursorrpymongo.databaser pymongo.poolrrpymongo.serverrpymongo.typingsrrrrrrrr?r=rsuB"==668-B4-4)'4%8eeP%$7%(5'D5("5(r?