f&8ddlmZddlZddlmZddlmZddlmZddlmZddl m Z dd l m Z dd l mZdd l mZdd l mZ dd lmZej&Z ddlmZegdZdZGddeZy#e$rej&ZY3wxYw#e$r ddlmZY=wxYw))versionN)CollectionInvalid) InvalidName)OperationFailure) Collection)filter_applies) codec_options)helpers)read_preferences)store)ReadPreference) ReadConcern)z$regex$eqz$necft|tz rtdj|ty)Nzglist collection names filter operator {0} is not implemented yet in mongomock allowed operators are {1})set)_LIST_COLLECTION_FILTER_ALLOWED_OPERATORSNotImplementedErrorformat)keyss [/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/mongomock/database.py$_verify_list_collection_supported_oprs5 4y<<! ((.t5^(_a a=cNeZdZ ddZdZdZdZdZeje jdk\rdZ e d Ze d Ze d Ze d Zd Zeje jdkrddZddZddZ ddZddZdZdZd dZddZdZ ddZy)!DatabaseNcJ||_||_i|_|xstj|_|xst |_tj||xstj|_ |rt|ts td|xs t|_y)NzDread_concern must be an instance of pymongo.read_concern.ReadConcern)name_client_collection_accessesr DatabaseStore_store_READ_PREFERENCE_PRIMARY_read_preferencemongomock_codec_options is_supported CodecOptions_codec_options isinstancer TypeError _read_concern)selfclientrr!read_preferencer read_concerns r__init__zDatabase.__init__%s  $&!5 3 3 5 / K3K,,];+U/F/S/S/U  < Ebc c):[]rc$|j|SN)get_collection)r+ coll_names r __getitem__zDatabase.__getitem__3s""9--rc |jdr+t|jjd|d|d|d||S)N_z has no attribute 'z'. To access the z collection, use database['z'].) startswithAttributeError __class____name__)r+attrs r __getattr__zDatabase.__getattr__6s? ??3  (($d<= =DzrcNdj|j|jS)NzDatabase({0}, '{1}'))rrrr+s r__repr__zDatabase.__repr__=s%,,T\\499EErct||jr4|j|jk(xr|j|jk(StSr1)r(r9rrNotImplemented)r+others r__eq__zDatabase.__eq__@s; eT^^ ,<<5==0LTYY%**5L Lrz3.12cDt|j|jfSr1)hashrrr>s r__hash__zDatabase.__hash__Fstyy12 2rc|jSr1)rr>s rr,zDatabase.clientIs ||rc|jSr1)r#r>s rr-zDatabase.read_preferenceMs$$$rc|jSr1)r'r>s rr zDatabase.codec_optionsQs"""rc|jSr1)r*r>s rr.zDatabase.read_concernUs!!!rc6|jjSr1)r!list_created_collection_namesr>s r_get_created_collectionsz!Database._get_created_collectionsYs{{88::rz4.0ctjd|rt|jS|j |S)NzBcollection_names is deprecated. Use list_collection_names instead.)session)warningswarnlistrMlist_collection_names)r+include_system_collectionsrOs rcollection_nameszDatabase.collection_names]s: MM^ _)D99;<<--g-> >rctd)Nz]list_collections is a valid method of Database but has not been implemented in mongomock yet.)r)r+filterrOnameOnlys rlist_collectionszDatabase.list_collectionscs!  rc@d}|r td|r|jdstdj|t|j|tr|d|j|iin|}t |j|j t|jjDcgc]#}t|||ir|jds|%c}S|jDcgc]}|jds|c}Scc}wcc}w)zfilter: only name field type with eq,ne or regex operator session: not supported for supported operator please see _LIST_COLLECTION_FILTER_ALLOWED_OPERATORS r&Mongomock does not handle sessions yetzJlist collection {0} might be valid but is not implemented yet in mongomockrzsystem.) rgetrr(strrrrRr! _collectionsr r7rM)r+rWrO field_namers rrSzDatabase.list_collection_nameshs  %&NO O ::f%)+IIOPVYYfjj4c:!5&**Z*@"AB@F  1J1G1L1L1N O"&dkk&>&>!?!&:t*<=dooV_F`  "::< ??9-     s <(D9Dc |tjd|tj| |j|j |xs |j |xs |j||S#t$r]|j|t|||||xs |j|xs |j |jx}|j|<|cYSwxYw)Nr-)r r-r. write_concern)rr.rar-r _db_store) r ensure_read_preference_typer$r%r with_optionsr'r-KeyError_ensure_valid_collection_namerr!)r+rr r-rar. collections rr2zDatabase.get_collections  &  8 89JO \,,]; ,,T2??+Bt/B/B / G43G3G)@H H   . .t 4;E4l- / G43G3G+Bt/B/Bdkk<] ]J2248   s=A--A#CCc|r tdt|tr|jj y|j|j y)Nr[)rr(rr!drop)r+name_or_collectionrOs rdrop_collectionzDatabase.drop_collectionsD %&NO O (* 5  % % * * , KK* + 0 0 2rct|ts td|rd|vr td|ddk(s|ddk(r tdd|vr td d |vr td y) Nzname must be an instance of strz..z collection names cannot be emptyr.z/collection names must not start or end with '.'$z%collection names must not contain '$'z4collection names must not contain the null character)r(r]r)r)r+rs rrfz&Database._ensure_valid_collection_namesy$$=> >tt|@A A 7c>T"X_OP P $;EF F T>TU U rc |j|||jvrtd|z|r td|jj |||S)Nzcollection %s already existszSpecial options not supported)rfrSrrr!create_collection)r+rkwargss rrrzDatabase.create_collections] **40 4--/ /#$BT$IJ J %&EF F %%d+DzrcF|j||j|jstdj |d||jvr/|r|j |ntdj |d|jj ||ddiS)z+Changes the name of an existing collection.z$The collection "{0}" does not exist.i*'z*The target collection "{0}" already existsi+'okr)rfr! is_createdrrrkrename)r+rnew_name dropTargets rrename_collectionzDatabase.rename_collections **84{{4 ++"6==dCUL L t{{ "$$X.&@GGQ 4*ayrcd|r tdt|dr t|dstdt|z|j?|j|j k7r&t d|jd|j d||jjd|jiS) Nr[rgidzcannot dereference a %sz?trying to dereference a DBRef that points to another database (z not )_id) rhasattrr)typedatabaser ValueErrorrgfind_oner|)r+dbrefrOs r dereferencezDatabase.dereferences %&NO Oul+75$3G5U CD D >> %%..DII*E?D~~?CyyJK KE$$%..uxx/@AArc Pt|tr|di}d|vrddiStd)Nrpingrug?zJcommand is a valid Database method but is not implemented in Mongomock yet)r(r]r)r+command unused_kwargss rrzDatabase.commands; gs #lG W ": " XZ Zrc tj||r td|||jk(r|St |j |j |j|xs |j|xs |j|xs |jS)Nz[write_concern is a valid parameter for with_options but is not implemented yet in mongomock)r-r r.) r$r%rr#rrrr!r'r*)r+r r-rar.s rrdzDatabase.with_optionss ,,]; %   "o9N9N&NK LL$))T[[+Dt/D/D'>4+>+>%;););   r)NNN)TN)NNF)NN)NNNNr1)F)r: __module__ __qualname__r/r4r<r?rCr PYMONGO_VERSIONrparserFpropertyr,r-r r.rMrUrYrSr2rkrfrrrzrrrdrrrr#s\` ;.F -'--"77 3%%##"";u!55 ?   >HL8<$3 V & BZ^b rr) packagingrrPrrrrgr filteringr mongomockr r$r r r pymongorPRIMARYr" ImportErrorpymongo.read_concernrr. frozensetrrobjectrrrrrs"%>&8&-55*0-66N,O)aQ vQ %8/778 *)*s$A4B 4BB BB