grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026ó ¤) yàìãóê•SrSSKJrJrJr SSKJr SSKr/SQr "SS\RR5r "SS \RR5r "S S \ 5r"S S \ 5rSSjrg)a˜ Manage shelves of pickled objects. A "shelf" is a persistent, dictionary-like object. The difference with dbm databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects -- anything that the "pickle" module can handle. This includes most class instances, recursive data types, and objects containing lots of shared sub-objects. The keys are ordinary strings. To summarize the interface (key is a string, data is an arbitrary object): import shelve d = shelve.open(filename) # open, with (g)dbm filename -- no suffix d[key] = data # store data at key (overwrites old data if # using an existing key) data = d[key] # retrieve a COPY of the data at key (raise # KeyError if no such key) -- NOTE that this # access returns a *copy* of the entry! del d[key] # delete data stored at key (raises KeyError # if no such key) flag = key in d # true if the key exists list = d.keys() # a list of all existing keys (slow!) d.close() # close it Dependent on the implementation, closing a persistent dictionary may or may not be necessary to flush changes to disk. Normally, d[key] returns a COPY of the entry. This needs care when mutable entries are mutated: for example, if d[key] is a list, d[key].append(anitem) does NOT modify the entry d[key] itself, as stored in the persistent mapping -- it only modifies the copy, which is then immediately discarded, so that the append has NO effect whatsoever. To append an item to d[key] in a way that will affect the persistent mapping, use: data = d[key] data.append(anitem) d[key] = data To avoid the problem with mutable entries, you may pass the keyword argument writeback=True in the call to shelve.open. When you use: d = shelve.open(filename, writeback=True) then d keeps a cache of all entries you access, and writes them all back to the persistent mapping when you call d.close(). This ensures that such usage as d[key].append(anitem) works as intended. However, using keyword argument writeback=True may consume vast amount of memory for the cache, and it may make d.close() very slow, if you access many of d's entries after opening it in this way: d has no way to check which of the entries you access are mutable and/or which ones you actually mutate, so it must cache, and write back at close, all of the entries that you access. You can call d.sync() to write back all the entries in the cache, and empty the cache (d.sync() also synchronizes the persistent dictionary on disk, if feasible). é)ÚDEFAULT_PROTOCOLÚPicklerÚ Unpickler)ÚBytesION)ÚShelfÚ BsdDbShelfÚDbfilenameShelfÚopencó<•\rSrSrSrSr\=r=r=r=r =r r Sr Sr g)Ú _ClosedDictéBz>Marker for a closed dict. Access attempts raise a ValueError.có•[S5e)Nz!invalid operation on closed shelf)Ú ValueError)ÚselfÚargss Ú-/opt/alt/python313/lib64/python3.13/shelve.pyÚclosedÚ_ClosedDict.closedEs€ÜÐ<Ó=Ð=ócó•g)Nz©©rs rÚ__repr__Ú_ClosedDict.__repr__Is€Ø$rrN)Ú__name__Ú __module__Ú __qualname__Ú__firstlineno__Ú__doc__rÚ__iter__Ú__len__Ú __getitem__Ú __setitem__Ú __delitem__ÚkeysrÚ__static_attributes__rrrr r Bs-†ÙDò>àJPÐP€HÐPˆwÐP˜ÐP {ÐP°[À4õ%rr cór•\rSrSrSrSSjrSrSrSrSSjr S r S r S r S r S rSrSrSrSrg)réMzœBase class for shelf implementations. This is initialized with a dictionary-like object. See the module's __doc__ string for an overview of the interface. NcóT•XlUc[nX lX0l0UlX@lg©N)ÚdictrÚ _protocolÚ writebackÚcacheÚ keyencoding©rr+Úprotocolr-r/s rÚ__init__ÚShelf.__init__Ts)€àŒ Ø Ñ Ü'ˆHØ!ŒØ"ŒØˆŒ Ø&Õrc#óˆ# •URR5H nURUR5v• M" g7fr*)r+r%Údecoder/)rÚks rr ÚShelf.__iter__^s/逨—‘—‘Ö!ˆAØ—(‘(˜4×+Ñ+Ó,Ô ,ò"ùs‚AAcó,•[UR5$r*)Úlenr+rs rr!Ú Shelf.__len__bs€Ü�4—9‘9‹~ÐrcóR•URUR5UR;$r*©Úencoder/r+©rÚkeys rÚ __contains__ÚShelf.__contains__es €Ø�z‰z˜$×*Ñ*Ó+¨t¯y©yÑ8Ð8rcó`•URUR5UR;aX$U$r*r<)rr?Údefaults rÚgetÚ Shelf.geths*€Ø �:‰:�d×&Ñ&Ó '¨4¯9©9Ó 4Ø‘9Р؈rcó•URUnU$![am [URUR UR 55n[ U5R5nUR(aX RU'U$f=fr*) r.ÚKeyErrorrr+r=r/rÚloadr-©rr?ÚvalueÚfs rr"ÚShelf.__getitem__msx€ð (Ø—J‘J˜s‘OˆEð ˆ øô ó (ܘŸ ™  #§*¡*¨T×-=Ñ-=Ó">Ñ?Ó@ˆAܘa“L×%Ñ%Ó'ˆEØ�~�~Ø"'— ‘ ˜3‘øØˆ ð  (ús‚“A3B  B có•UR(aX RU'[5n[X0R5nUR U5 UR 5URURUR5'gr*) r-r.rrr,ÚdumpÚgetvaluer+r=r/)rr?rJrKÚps rr#ÚShelf.__setitem__wsW€Ø �>�>Ø#�J‰J�s‰OÜ ‹IˆÜ �A—~‘~Ó &ˆØ �‰ˆuŒ Ø23·*±*³,ˆ� ‰ �#—*‘*˜T×-Ñ-Ó.Ò/rcóŒ•URURUR5 URU g![a gf=fr*)r+r=r/r.rGr>s rr$ÚShelf.__delitem__s?€Ø �I‰I�c—j‘j ×!1Ñ!1Ó2Ð 3ð Ø— ‘ ˜3‘øÜó Ù ð ús¨ 6¶ AÁAcó•U$r*rrs rÚ __enter__ÚShelf.__enter__†s€Øˆ rcó$•UR5 gr*)Úclose)rÚtyperJÚ tracebacks rÚ__exit__ÚShelf.__exit__‰s €Ø � ‰ � rcó•URcgUR5 URR5 [ 5Ulg![a Nf=f! SUlg=f![ 5Ulf! SUlf=f=fr*)r+ÚsyncrXÚAttributeErrorr rs rrXÚ Shelf.closeŒs{€Ø �9‰9Ñ Ø ð !Ø �I‰IŒKð Ø— ‘ —‘Ô!ð  !Ü'›M�• øô "ó Ùð ûð !Ø �– ûð !Ü'›M�• øð !Ø �– ýsK�A*¡A ¼AÁ AÁA*ÁAÁA*Á A'Á*B Á,A<Á;B Á< BÂB cóH•[US5(dgUR5 g)Nr-)ÚhasattrrXrs rÚ__del__Ú Shelf.__del__�s€Ü�t˜[×)Ñ)ð Ø � ‰ � rcó,•UR(aMUR(a<SUlURR5H upX U'M SUl0Ul[URS5(aURR 5 gg)NFTr^)r-r.Úitemsrbr+r^)rr?Úentrys rr^Ú Shelf.sync¤sh€Ø �>�>˜dŸjŸjØ"ˆDŒNØ"Ÿj™j×.Ñ.Ö0‘ �Ø!�S“ ñ1à!ˆDŒN؈DŒJÜ �4—9‘9˜f× %Ñ %Ø �I‰I�N‰NÕ ð &r)r,r.r+r/r-©NFzutf-8r*)rrrrrr2r r!r@rDr"r#r$rUr[rXrcr^r&rrrrrMsP†ñð 7<Ø$ô'ò-òò9ôò ò?òòòò!ò"õrrcóD•\rSrSrSrS SjrSrSrSrSr S r S r g) ré¯a–Shelf implementation using the "BSD" db interface. This adds methods first(), next(), previous(), last() and set_location() that have no counterpart in [g]dbm databases. The actual database must be opened using one of the "bsddb" modules "open" routines (i.e. bsddb.hashopen, bsddb.btopen or bsddb.rnopen) and passed to the constructor. See the module's __doc__ string for an overview of the interface. Ncó2•[RXX#U5 gr*)rr2r0s rr2ÚBsdDbShelf.__init__¼s€ä �‰�t 8¸ ÕDrcóº•URRU5up[U5nURUR5[ U5R 54$r*)r+Ú set_locationrr5r/rrHrIs rroÚBsdDbShelf.set_locationÀsH€Ø—y‘y×-Ñ-¨cÓ2‰ ˆÜ �E‹NˆØ— ‘ ˜4×+Ñ+Ó,¬i¸«l×.?Ñ.?Ó.AÐBÐBrcó®•[UR5up[U5nURUR5[ U5R 54$r*)Únextr+rr5r/rrHrIs rrrÚBsdDbShelf.nextÅsA€Ü˜DŸI™I“‰ ˆÜ �E‹NˆØ— ‘ ˜4×+Ñ+Ó,¬i¸«l×.?Ñ.?Ó.AÐBÐBrcó¸•URR5up[U5nURUR5[ U5R 54$r*)r+Úpreviousrr5r/rrHrIs rruÚBsdDbShelf.previousÊsF€Ø—y‘y×)Ñ)Ó+‰ ˆÜ �E‹NˆØ— ‘ ˜4×+Ñ+Ó,¬i¸«l×.?Ñ.?Ó.AÐBÐBrcó¸•URR5up[U5nURUR5[ U5R 54$r*)r+Úfirstrr5r/rrHrIs rrxÚBsdDbShelf.firstÏsD€Ø—y‘y—‘Ó(‰ ˆÜ �E‹NˆØ— ‘ ˜4×+Ñ+Ó,¬i¸«l×.?Ñ.?Ó.AÐBÐBrcó¸•URR5up[U5nURUR5[ U5R 54$r*)r+Úlastrr5r/rrHrIs rr{ÚBsdDbShelf.lastÔsD€Ø—y‘y—~‘~Ó'‰ ˆÜ �E‹NˆØ— ‘ ˜4×+Ñ+Ó,¬i¸«l×.?Ñ.?Ó.AÐBÐBrrri) rrrrrr2rorrrurxr{r&rrrrr¯s3†ñ ð7<Ø$ôEòCò Cò Cò Cõ Crrcó(•\rSrSrSrSSjrSrSrg)r éÚz»Shelf implementation using the "dbm" generic dbm interface. This is initialized with the filename for the dbm database. See the module's __doc__ string for an overview of the interface. NcóV•SSKn[RXRX5X45 g)Nr)Údbmrr2r )rÚfilenameÚflagr1r-r€s rr2ÚDbfilenameShelf.__init__ás€ÛÜ �‰�tŸX™X hÓ5°xÕKrcól•URR5 URR5 g)z Remove all items from the shelf.N)r.Úclearr+rs rr…ÚDbfilenameShelf.clearås"€ð � ‰ ×ÑÔØ � ‰ �‰Õrr©ÚcNF)rrrrrr2r…r&rrrr r Ús†ñô Lõrr có•[XX#5$)aÓOpen a persistent dictionary for reading and writing. The filename parameter is the base filename for the underlying database. As a side-effect, an extension may be added to the filename and more than one file may be created. The optional flag parameter has the same interpretation as the flag parameter of dbm.open(). The optional protocol parameter specifies the version of the pickle protocol. See the module's __doc__ string for an overview of the interface. )r )r�r‚r1r-s rr r ís€ô ˜8¨8Ó ?Ð?rr‡)rÚpicklerrrÚiorÚcollections.abcÚ collectionsÚ__all__ÚabcÚMutableMappingr rrr r rrrÚr‘snðñ8÷t8Ñ7Ýãâ <€ô%�+—/‘/×0Ñ0ô%ô_ˆK�O‰O× *Ñ *ô_ôD(C�ô(CôV�eôõ& @r