f/UdZddlmZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZddlmZddlmZmZmZmZmZmZmZmZmZddl m!Z!erdd l"m#Z#dd l$m%Z%dd l&m'Z'e(d d gZ)de*d<e(gde)zZ+de*d<e+e(gdzZ,de*d<dZ-de*d<dZ.de*d<hdZ/de*d<d+dZ0 d, d-dZ1d.dZ2d/dZ3 d0 d1d Z4d2d!Z5d3d"Z6d4d#Z7d5d$Z8 d6d%Z9d7d&Z:ed'e d(e f)Z;d8d*Z copydbgetnonce saslstart createuser updateuser authenticate saslcontinuecopydbgetnoncecopydbsaslstartset_SENSITIVE_COMMANDScddj|Dcgc]}dj|c}Scc}w)z9Generate an index name from the set of fields it is over._z{}_{})joinformat)keysitems X/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/pymongo/helpers.py_gen_index_namer?ps* 88t _index_listrLus+s+?@ @i()) k3 ' ),- -  S]] 3 $ $  S[[ 1 ))+, ,K$7cd d(*D$$i( MM$   ct|tttjfst dt |zt|s tdi}t|tjr|D]}||}t|||||<|S|D]0}t|tr|tf}|\}}t|||||<2|S)zbHelper to generate an index specifying document. Takes a list of (key, direction) pairs. z@must use a dictionary or a list of (key, direction) pairs, not: zkey_or_list must not be empty) rArErGrr rCreprlen ValueError_validate_index_key_pairrBr) index_listindexkeyvaluer=s r>_index_documentrWs j4 "< = NQUV`Qa a   z?899E*ckk*CsOE $S% 0E#J L D$$i(JC $S% 0E#J  LrMct|ts tdt|tttj fs tdy)Nz6first item in each key pair must be an instance of strz[second item in each key pair must be 1, -1, '2d', or another valid MongoDB index specifier.)rArBrCr)rr )rUrVs r>rRrRsD c3 PQQ ec3 4 5 >   6rMcd|vr,t|jd|jd|||r:d|vr6|d}|jd}|r|jd|it||dry|}d|vr?|dj D])}|jds|jdr'|}n|d}|jd} |r | | |vry||vry| | t vr.t ||tj|vsd |vr t ||| d vrt|| ||| d k(rt|| ||| d k(rt|| ||t|| ||) z+Check the response to a command for errors.okz$errcodewriteConcernError errorLabelsNrawerrmsgznode is recovering)*i*i&12+) rgetupdate_raise_write_concern_errorrKr#rr LEGACY_ERRORrrr) responsemax_wire_versionallowable_errorsparse_write_concern_error_error_labelsdetailsshardr_r[s r>_check_command_responseros 8 LL LL     !%8H%D-.,,}-  MM='2 3"6*~G e_++-Eyy"599T? . X F ;;v D  '' ' '   % %!&(3 3  ! !V +/Cv/Mfh// $$h8HII vtX7GHH VT85EFF 643C DDrMc|d}|jddk(rt|jdd|t|jd|jd|)Nr[r`r_)rcrr) write_errorserrors r>_raise_last_write_errorrtsX  E yyE! ( 3UEBB UYYx(%))F*;U CCrMct|r+t|jd|jd|t|jd|jd|)Nr_r[)rrrcr)rss r>reresLuEIIh/61BEJJ EIIh/61BE JJrMc||jd}|r(|jd}|r|j}||d<|S)z%Return the writeConcernError or None.r\r])rccopy)resultwce error_labelss r> _get_wce_docr{ sA **( )C zz-0 ((*C!-C  JrMcr|jd}|r t|t|}|r t|yy)z?Backward compatibility helper for write command error handling. writeErrorsN)rcrtr{re)rxrrrys r>_check_write_command_responser~s7::m,L - v C "3' rMct|tjr|St|tjtjfr6t d|Dst |dtj|dSt |d)zTakes a sequence of field names and returns a matching dictionary. ["a", "b"] becomes {"a": 1, "b": 1} and ["a.b.c", "d", "a.c"] becomes {"a.b.c": 1, "d": 1, "a.c": 1} c3<K|]}t|tywN)rArB).0fields r> z'_fields_list_to_dict..4s>e:eS)>sz5 must be a list of key names, each an instance of strz' must be a mapping or list of key names) rArr r SetallrCdictfromkeys)fields option_names r>_fields_list_to_dictr%ss&#++& &3<<12>v>>{m+`ab b}}VQ'' {m#JK LLrMctjrGtj} tj|d|d|ddtj~yy#t $rY~ywxYw#~wxYw)z1Print exceptions raised by subscribers to stderr.rrN)sysstderrexc_info tracebackprint_exceptionOSError)einfos r>_handle_exceptionr;sh  zz    % %eAha%(D#** U   s#0A A&"A)%A&&A))A,F.)boundc0dfd }tt|S)NcN|jdd}ddlm}ddlm} |i|S#t $rr}|r|j tk(rVd}|D],}t||r|}nt||s |j}n|r|jdn|i|cYd}~Sd}~wwxYw)N no_reauthFr)_BulkWriteContext) ConnectionT)reauthenticate) poppymongo.messager pymongo.poolrrr[r*rAconnr2) argskwargsrrrexcrargfuncs r>innerz_handle_reauth..innerPsJJ{E2 5+ (( ( xx::C!#z2"!#'89"xx  %%T%:T,V,, ) s&) B$9B,,BB$BB$)rrrrreturnr)rr)rrs` r>_handle_reauthrOs: 5>rM)r<rrrBr)rIrrJzOptional[Union[int, str]]rz8Sequence[tuple[str, Union[int, str, Mapping[str, Any]]]])rSrrzdict[str, Any])rUrrVrrNone)NF) rgrrhz Optional[int]riz$Optional[Container[Union[int, str]]]rjboolrr)rrz list[Any]rr )rsrrr )rxMapping[str, Any]rzOptional[Mapping[str, Any]])rxrrr)rz'Union[Mapping[str, Any], Iterable[str]]rrBrr)rr)rrrr)=__doc__ __future__rrr collectionsrtypingrrrrr r r r r rrrpymongorpymongo.errorsrrrrrrrrr pymongo.hellorpymongo.cursorrpymongo.operationsrpymongo.typingsrr r!__annotations__r#r(r*r,r7r?rLrWrRrortrer{r~rrrrrMr>rsJ"        &$-,'     I %7 : % (+*%'c& S > @D#<=8: >B&+ @E@E#@E;@E $ @E  @EFDK  (M 3MBEMM, " CxS)*rM