ó
    F\h¿-  ã                   ó€   • S r SSKrSSKrSSKrSSKrSS/r	Sr
\r " S S\R                  R                  5      rS	S jrg)
a­  A dumb and slow but simple dbm clone.

For database spam, spam.dir contains the index (a text file),
spam.bak *may* contain a backup of the index (also a text file),
while spam.dat contains the data (a binary file).

XXX TO DO:

- seems to contain a bug when updating...

- reclaim free space (currently, space once occupied by deleted or expanded
items is never reused)

- support concurrent access (currently, if two processes take turns making
updates, they can mess up the index)

- support efficient access to large databases (currently, the whole index
is read when the database is opened, and some updates rewrite the whole index)

- support opening for read-only (flag = 'm')

é    NÚerrorÚopeni   c                   ó¤   • \ rS rSr\r\rSS jrS rS rS r	\	r
S rS rS rS	 rS
 rS rS rS rS rS rS r\rS rS r\rS rS rS rSrg)Ú	_Databaseé#   c                 óè   • U R                   R                  U5      nX l        US:H  U l        US-   U l        US-   U l        US-   U l        S U l        U R                  U5        U R                  U5        g )NÚrs   .dirs   .dats   .bak)
Ú_osÚfsencodeÚ_modeÚ	_readonlyÚ_dirfileÚ_datfileÚ_bakfileÚ_indexÚ_createÚ_update)ÚselfÚfilebasenameÚmodeÚflags       Ú/usr/lib/python3.13/dbm/dumb.pyÚ__init__Ú_Database.__init__0   sq   € Ø—x‘x×(Ñ(¨Ó6ˆØŒ
Ø #™+ˆŒð % wÑ.ˆŒð % wÑ.ˆŒØ$ wÑ.ˆŒð ˆŒð 	�‰�TÔØ�‰�TÕó    c                 óð  • US:X  aA  U R                   U R                  U R                  4 H  n [        R                  " U5        M      [        R                  " U R                   SSS9nUR                  5         g ! [
         a     M]  f = f! [
         a`    US;  a  e [        R                  " U R                   SSS9 nU R                  U R                   5        S S S 5         g ! , (       d  f        g = ff = f)NÚnr	   úLatin-1©Úencoding©Úcr   Úw)
r   r   r   r
   ÚremoveÚOSErrorÚ_ior   ÚcloseÚ_chmod)r   r   ÚfilenameÚfs       r   r   Ú_Database._createJ   sÃ   € Ø�3‹;Ø!Ÿ]™]¨D¯M©M¸4¿=¹=ÓI�ðÜ—J’J˜xÖ(ñ Jð	Ü—’˜Ÿ™¨°iÑ@ˆAð �G‰G�Iøô ó Úðûô
 ó 	+Ø˜:Ó%ØÜ—’˜$Ÿ-™-¨°yÒAÀQØ—‘˜DŸM™MÔ*÷ B×A×AÐAúð	+ús;   ®A:Á	 B Á:
BÂBÂ1C5Â<C"ÃC5Ã"
C1	Ã,C5Ã1C5c                 ó  • SU l         0 U l         [        R                  " U R                  SSS9nU   U HJ  nUR                  5       n[        R                  " U5      u  pEUR                  S5      nXPR                  U'   ML     S S S 5        g ! , (       d  f       g = f! [         ae    US;  a  e U R                  R                  U R                  SSS9 nU R                  U R                  5        S S S 5         g ! , (       d  f        g = ff = f)NFr	   r   r   r!   r#   )Ú	_modifiedr   r&   r   r   ÚrstripÚ_astÚliteral_evalÚencoder%   r(   )r   r   r*   ÚlineÚkeyÚpos_and_siz_pairs         r   r   Ú_Database._update]   sÓ   € ØˆŒØˆŒð	8Ü—’˜Ÿ™¨°iÑ@ˆAò Û�DØŸ;™;›=�DÜ,0×,=Ò,=¸dÓ,CÑ)�CØŸ*™* YÓ/�CØ'7—K‘K Ó$ñ	 ÷ —–ûô ó 	+Ø˜:Ó%ØØ—‘—‘˜tŸ}™}¨c¸I�ÑFÈ!Ø—‘˜DŸM™MÔ*÷ G×F×FÐFúð	+ús5   � B ²ABÂ
BÂ6DÃC9Ã/DÃ9
D	ÄDÄDc                 óŒ  • U R                   b  U R                  (       d  g  U R                  R                  U R                  5         U R                  R                  U R                  U R                  5        U R                  R                  U R                  SSS9 nU R                  U R                  5        U R                   R                  5        H/  u  p#UR                  S5      < SU< S3nUR                  U5        M1     S S S 5        SU l        g ! [
         a     NÛf = f! [
         a     Nºf = f! , (       d  f       N6= f)Nr#   r   r   ú, Ú
F)r   r-   r
   Úunlinkr   r%   Úrenamer   r&   r   r(   ÚitemsÚdecodeÚwrite)r   r*   r3   r4   Úentrys        r   Ú_commitÚ_Database._commitr   sø   € ð �;‰;Ñ d§n§nØð	Ø�H‰H�O‰O˜DŸM™MÔ*ð	Ø�H‰H�O‰O˜DŸM™M¨4¯=©=Ô9ð �X‰X�]‰]˜4Ÿ=™=¨#¸	ˆ]ÑBÀaØ�K‰K˜Ÿ™Ô&Ø)-¯©×):Ñ):Ö)<Ñ%�ð '*§j¡j°Ö&;Ó=MÐN�Ø—‘˜–ñ	 *=÷ Cð ˆ�øô ó 	Ùð	ûô
 ó 	Ùð	ú÷ CÕBús0   ¡%D Á0D% ÂA)D5Ä
D"Ä!D"Ä%
D2Ä1D2Ä5
Ec                 ó4   • U R                   c  [        S5      eg ©Nú"DBM object has already been closed)r   r   ©r   s    r   Ú_verify_openÚ_Database._verify_openŽ   s   € Ø�;‰;ÑÜÐ<Ó=Ð=ð r   c                 óP  • [        U[        5      (       a  UR                  S5      nU R                  5         U R                  U   u  p#[
        R                  " U R                  S5       nUR                  U5        UR                  U5      nS S S 5        U$ ! , (       d  f       W$ = f)Núutf-8Úrb)
Ú
isinstanceÚstrr1   rE   r   r&   r   r   ÚseekÚread)r   r3   ÚposÚsizr*   Údats         r   Ú__getitem__Ú_Database.__getitem__’   s�   € Ü�cœ3×ÑØ—*‘*˜WÓ%ˆCØ×ÑÔØ—;‘;˜sÑ#‰ˆÜ�XŠX�d—m‘m TÔ*¨aØ�F‰F�3ŒKØ—&‘&˜“+ˆC÷ +ð ˆ
÷ +Ô*ð ˆ
ús   Á)#BÂ
B%c                 ón  • [         R                  " U R                  S5       nUR                  SS5        [	        UR                  5       5      nU[        -   S-
  [        -  [        -  nUR                  SXC-
  -  5        UnUR                  U5        S S S 5        W[        U5      4$ ! , (       d  f       N= f)Núrb+r   é   é   ó    )	r&   r   r   rL   ÚintÚtellÚ
_BLOCKSIZEr=   Úlen)r   Úvalr*   rN   Únposs        r   Ú_addvalÚ_Database._addval    sŒ   € Ü�XŠX�d—m‘m UÔ+¨qØ�F‰F�1�aŒLÜ�a—f‘f“h“-ˆCØœ:Ñ%¨Ñ)¬jÑ8¼JÑFˆDØ�G‰G�E˜4™8Ñ$Ô%ØˆCØ�G‰G�CŒL÷ ,ð ”S˜“XˆÐ÷ ,Õ+ús   ¢A/B&Â&
B4c                 óÖ   • [         R                  " U R                  S5       nUR                  U5        UR	                  U5        S S S 5        U[        U5      4$ ! , (       d  f       N= f)NrT   )r&   r   r   rL   r=   r[   )r   rN   r\   r*   s       r   Ú_setvalÚ_Database._setval®   sJ   € Ü�XŠX�d—m‘m UÔ+¨qØ�F‰F�3ŒKØ�G‰G�CŒL÷ ,ð ”S˜“XˆÐ÷ ,Õ+ús   ¢#AÁ
A(c                 ó  • X R                   U'   [        R                  " U R                  SSS9 nU R	                  U R                  5        UR                  UR                  S5      < SU< S35        S S S 5        g ! , (       d  f       g = f)NÚar   r   r7   r8   )r   r&   r   r   r(   r=   r<   )r   r3   r4   r*   s       r   Ú_addkeyÚ_Database._addkey·   s[   € Ø+�‰�CÑÜ�XŠX�d—m‘m S°9Ò=ÀØ�K‰K˜Ÿ™Ô&Ø�G‰G #§*¡*¨YÖ"7Ó9IÐJÔK÷ >×=Ö=ús   ¯AA<Á<
B
c                 ó  • U R                   (       a  [        S5      e[        U[        5      (       a  UR	                  S5      nO&[        U[
        [        45      (       d  [        S5      e[        U[        5      (       a  UR	                  S5      nO&[        U[
        [        45      (       d  [        S5      eU R                  5         SU l	        XR                  ;  a!  U R                  XR                  U5      5        g U R                  U   u  p4U[        -   S-
  [        -  n[        U5      [        -   S-
  [        -  nXe::  a  U R                  X25      U R                  U'   g U R                  U5      U R                  U'   g )Nú'The database is opened for reading onlyrH   zkeys must be bytes or stringszvalues must be bytes or stringsTrV   )r   r   rJ   rK   r1   ÚbytesÚ	bytearrayÚ	TypeErrorrE   r-   r   re   r^   rZ   r[   ra   )r   r3   r\   rN   rO   Ú	oldblocksÚ	newblockss          r   Ú__setitem__Ú_Database.__setitem__½   s-  € Ø�>�>ÜÐAÓBÐBÜ�cœ3×ÑØ—*‘*˜WÓ%‰CÜ˜C¤%¬Ð!3×4Ñ4ÜÐ;Ó<Ð<Ü�cœ3×ÑØ—*‘*˜WÓ%‰CÜ˜C¤%¬Ð!3×4Ñ4ÜÐ=Ó>Ð>Ø×ÑÔØˆŒØ—k‘kÓ!Ø�L‰L˜Ÿl™l¨3Ó/Õ0ð —{‘{ 3Ñ'‰HˆCØœzÑ)¨AÑ-´*Ñ<ˆIÜ˜S›¤JÑ.°Ñ2´zÑAˆIØÓ%Ø#'§<¡<°Ó#9�—‘˜CÒ ð
 $(§<¡<°Ó#4�—‘˜CÒ r   c                 óð   • U R                   (       a  [        S5      e[        U[        5      (       a  UR	                  S5      nU R                  5         SU l        U R                  U	 U R                  5         g )Nrh   rH   T)	r   r   rJ   rK   r1   rE   r-   r   r?   ©r   r3   s     r   Ú__delitem__Ú_Database.__delitem__â   sZ   € Ø�>�>ÜÐAÓBÐBÜ�cœ3×ÑØ—*‘*˜WÓ%ˆCØ×ÑÔØˆŒà�K‰K˜Ðð
 	�‰�r   c                 ób   •  [        U R                  5      $ ! [         a    [        S5      S ef = frB   )Úlistr   rk   r   rD   s    r   ÚkeysÚ_Database.keysñ   ó6   € ð	HÜ˜Ÿ™Ó$Ð$øÜó 	HÜÐ<Ó=À4ÐGð	Húó   ‚ —.c                 óˆ   • U R                  5         U R                  R                  5        Vs/ s H  oX   4PM
     sn$ s  snf ©N)rE   r   rv   rq   s     r   r;   Ú_Database.items÷   s:   € Ø×ÑÔØ,0¯K©K×,<Ñ,<Ô,>Ó?Ò,> S�d‘iÓ Ñ,>Ñ?Ð?ùÒ?s   ­?c                 ó¼   • [        U[        5      (       a  UR                  S5      n XR                  ;   $ ! [         a    U R                  c  [        S5      S ee f = f)NrH   rC   )rJ   rK   r1   r   rk   r   rq   s     r   Ú__contains__Ú_Database.__contains__û   sY   € Ü�cœ3×ÑØ—*‘*˜WÓ%ˆCð	ØŸ+™+Ñ%Ð%øÜó 	Ø�{‰{Ñ"ÜÐ@ÓAÀtÐKàð		ús	   ¨6 ¶%Ac                 ób   •  [        U R                  5      $ ! [         a    [        S5      S ef = frB   )Úiterr   rk   r   rD   s    r   ÚiterkeysÚ_Database.iterkeys  rx   ry   c                 ób   •  [        U R                  5      $ ! [         a    [        S5      S ef = frB   )r[   r   rk   r   rD   s    r   Ú__len__Ú_Database.__len__  s6   € ð	HÜ�t—{‘{Ó#Ð#øÜó 	HÜÐ<Ó=À4ÐGð	Húry   c                 ó    •  U R                  5         S =U l        =U l        =U l        U l        g ! S =U l        =U l        =U l        U l        f = fr{   )r?   r   r   r   r   rD   s    r   r'   Ú_Database.close  sJ   € ð	OØ�L‰LŒNàJNÐNˆDŒKÐN˜$œ-ÐN¨$¬-¸$½-øÈ$ÐNˆDŒKÐN˜$œ-ÐN¨$¬-¸$½-ús	   ‚/ ¯Ac                 óN   • U R                   R                  XR                  5        g r{   )r
   Úchmodr   )r   Úfiles     r   r(   Ú_Database._chmod  s   € Ø�‰�‰�tŸZ™ZÕ(r   c                 ó   • U $ r{   © rD   s    r   Ú	__enter__Ú_Database.__enter__  s   € Øˆr   c                 ó$   • U R                  5         g r{   )r'   )r   Úargss     r   Ú__exit__Ú_Database.__exit__!  s   € Ø�
‰
�r   )r   r   r   r   r   r-   r   N)r"   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r
   r&   r   r   r   r?   ÚsyncrE   rQ   r^   ra   re   rn   rr   rv   r;   r~   r‚   Ú__iter__r…   r'   Ú__del__r(   r�   r“   Ú__static_attributes__rŽ   r   r   r   r   #   sŽ   † ð €CØ
€Côò4ò&8ò*ð4 €Dò>òòòòLò5òJòHò@ò	òHð
 €HòHòOð €Gò)òõr   r   c                 ó¼   •  [         R                  " S5      n[         R                  " U5        X#) -  nUS;  a  [        S5      e[	        XUS9$ ! [         a     N'f = f)a!  Open the database file, filename, and return corresponding object.

The flag argument, used to control how the database is opened in the
other DBM implementations, supports only the semantics of 'c' and 'n'
values.  Other values will default to the semantics of 'c' value:
the database will always opened for update and will be created if it
does not exist.

The optional mode argument is the UNIX mode of the file, used only when
the database has to be created.  It defaults to octal code 0o666 (and
will be modified by the prevailing umask).

r   )r	   r#   r"   r   z)Flag must be one of 'r', 'w', 'c', or 'n')r   )r
   ÚumaskÚAttributeErrorÚ
ValueErrorr   )r‹   r   r   Úums       r   r   r   %  s`   € ð Ü�YŠY�q‹\ˆÜ�	Š	�"Œð
 �s‰|ˆØÐ'Ó'ÜÐDÓEÐEÜ�T dÑ+Ð+øô ó Ùðús   ‚,A Á
AÁA)r"   i¶  )Ú__doc__Úastr/   Úior&   Úosr
   Úcollections.abcÚcollectionsÚ__all__rZ   r%   r   ÚabcÚMutableMappingr   r   rŽ   r   r   Ú<module>r«      sJ   ðñó. Û Û Û à�FÐ
€à€
à€ô�—‘×.Ñ.ô õD,r   