+
    üÐj1)  ã                  ó®   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHtH	t	H
t
HtHt ^ RIHt ]! RRR7      t ! R R4      t ! R	 R
]4      tRR lt. ROtR# )aw  
A L{DirDBM} is a L{dbm}-style interface to a directory.

Each key is stored as a single file.  This is not expected to be very fast or
efficient, but it's good for easy debugging.

L{DirDBM}s are *not* thread-safe, they should only be accessed by one thread at
a time.

No files should be placed in the working directory of a DirDBM save those
created by the DirDBM itself!
)ÚannotationsN)ÚAnyStrÚIterableÚMappingÚTypeVarÚoverload)ÚFilePathÚ_T)Úboundc                  óF  € ] tR t^ tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R lt]R R l4       t]R  R! l4       tR2R# R$ lltR% R& ltR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1tR"# )3ÚDirDBMzž
A directory with a DBM interface.

This class presents a hash-like interface to a directory of small,
flat files. It can only use strings as keys or values.
c               ó    € V ^8„  d   QhRRRR/# )é   ÚnameÚbytesÚreturnÚNone© )Úformats   "Ú:/usr/lib/python3/dist-packages/twisted/persisted/dirdbm.pyÚ__annotate__ÚDirDBM.__annotate__(   s   € ÷ &ñ &˜Uð & tñ &ó    c                óÆ  € \         P                  P                  V4      V n        \	        V4      V n        V P
                  P                  4       '       g   V P
                  P                  4        R# \        P                  ! V P
                  P                  R4      P                  4       F  p\         P                  ! V4       K  	  \        P                  ! V P
                  P                  R4      P                  4      pV F[  pVRR p\         P                  P                  V4      '       d   \         P                  ! V4       KE  \         P                  ! W$4       K]  	  R# )z:
@param name: Base path to use for the directory storage.
z*.newz*.rplNéüÿÿÿ)ÚosÚpathÚabspathÚdnamer   Ú
_dnamePathÚisdirÚcreateDirectoryÚglobÚchildÚremoveÚexistsÚrename)Úselfr   ÚfÚreplacementsÚolds   &&   r   Ú__init__ÚDirDBM.__init__(   sÞ   € ô —W‘W—_‘_ TÓ*ˆŒ
Ü" 4›.ˆŒØ�‰×$Ñ$×&Ò&Ø�O‰O×+Ñ+Ö-ô —Y’Y˜tŸ™×4Ñ4°WÓ=×BÑBÖC�Ü—	’	˜!–ñ DäŸ9š9 T§_¡_×%:Ñ%:¸7Ó%C×%HÑ%HÓIˆLÛ!�Ø˜˜�f�Ü—7‘7—>‘> #×&Ò&Ü—I’I˜a–Lä—I’I˜aÖ%ó "r   c               ó    € V ^8„  d   QhRRRR/# ©r   Úkr   r   r   )r   s   "r   r   r   C   s   € ÷ Nñ N˜ð N 5ñ Nr   c                ón   € \         P                  ! V4      P                  RR4      P                  RR4      # )z/
Encode a key so it can be used as a filename.
ó   
ó   _ó   /ó   -)Úbase64ÚencodebytesÚreplace©r'   r/   s   &&r   Ú_encodeÚDirDBM._encodeC   s/   € ô
 ×!Ò! !Ó$×,Ñ,¨U°DÓ9×AÑAÀ$ÈÓMÐMr   c               ó    € V ^8„  d   QhRRRR/# r.   r   )r   s   "r   r   r   J   s   € ÷ Nñ N˜ð N 5ñ Nr   c                ón   € \         P                  ! VP                  RR4      P                  RR4      4      # )z#
Decode a filename to get the key.
r2   r1   r4   r3   )r5   Údecodebytesr7   r8   s   &&r   Ú_decodeÚDirDBM._decodeJ   s-   € ô ×!Ò! !§)¡)¨D°%Ó"8×"@Ñ"@ÀÀtÓ"LÓMÐMr   c               ó    € V ^8„  d   QhRRRR/# )r   r   úFilePath[AnyStr]r   r   r   )r   s   "r   r   r   P   s   € ÷ ñ Ð.ð °5ñ r   c                ó�   € VP                  4       ;_uu_ 4       pVP                  4       pRRR4       V#   + '       g   i     X# ; i)zi
Read in the contents of a file.

Override in subclasses to e.g. provide transparently encrypted dirdbm.
N)ÚopenÚread)r'   r   r(   Úss   &&  r   Ú	_readFileÚDirDBM._readFileP   s3   € ð �Y‰Y�[Œ[˜AØ—‘“ˆA÷ àˆ÷ Ž[àˆús	   ™4´A	c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   rA   Údatar   r   r   r   )r   s   "r   r   r   Z   s"   € ÷ ñ Ð/ð °uð Àñ r   c                ó´   € VP                  R4      ;_uu_ 4       pVP                  V4       VP                  4        RRR4       R#   + '       g   i     R# ; i)z_
Write data to a file.

Override in subclasses to e.g. provide transparently encrypted dirdbm.
ÚwN)rC   ÚwriteÚflush)r'   r   rI   r(   s   &&& r   Ú
_writeFileÚDirDBM._writeFileZ   s3   € ð �Y‰Y�s�^Œ^˜qØ�G‰G�DŒMØ�G‰GŒI÷ �^�^Š^ús   š"AÁA	c               ó   € V ^8„  d   QhRR/# )r   r   Úintr   )r   s   "r   r   r   d   s   € ÷ .ñ .˜ñ .r   c                óH   € \        V P                  P                  4       4      # )z6
@return: The number of key/value pairs in this Shelf
)Úlenr   Úlistdir©r'   s   &r   Ú__len__ÚDirDBM.__len__d   s   € ô �4—?‘?×*Ñ*Ó,Ó-Ð-r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r/   r   Úvr   r   r   )r   s   "r   r   r   j   s!   € ÷  ñ  ˜Uð   uð  °ñ  r   c                ó  € \        V4      \        8X  g   \        R4      h\        V4      \        8X  g   \        R4      hV P                  V4      pV P                  P                  V4      pVP                  4       '       d   VP                  R4      pMVP                  R4      p V P                  WB4       VP                  4       '       d   VP                  4        VP                  V4       R#   \         d    TP                  4        h i ; i)zœ
C{dirdbm[k] = v}
Create or modify a textfile in this directory

@type k: bytes
@param k: key to set

@type v: bytes
@param v: value to associate with C{k}
úDirDBM key must be byteszDirDBM value must be bytesz.rplz.newN)Útyper   Ú	TypeErrorr9   r   r#   r%   ÚsiblingExtensionrN   r$   ÚmoveToÚBaseException)r'   r/   rY   r*   Únews   &&&  r   Ú__setitem__ÚDirDBM.__setitem__j   sÑ   € ô �A‹wœ%ÔÜÐ6Ó7Ð7Ü�A‹wœ%ÔÜÐ8Ó9Ð9Ø�L‰L˜‹Oˆð �o‰o×#Ñ# AÓ&ˆØ�:‰:�<Š<Ø×&Ñ& vÓ.‰Cà×&Ñ& vÓ.ˆCð	Ø�O‰O˜CÔ#ð
 �z‰z�|Š|Ø—
‘
”Ø�J‰J�sŽOøô ô 	Ø�J‰JŒLØð	ús   Â%C/ Ã/Dc               ó    € V ^8„  d   QhRRRR/# r.   r   )r   s   "r   r   r   Œ   s   € ÷ ñ ˜Uð  uñ r   c                óì   € \        V4      \        8X  g   \        R4      hV P                  P	                  V P                  V4      4      p V P                  V4      #   \         d    \        T4      hi ; i)z½
C{dirdbm[k]} Get the contents of a file in this directory as a string.

@param k: key to lookup

@return: The value associated with C{k}

@raise KeyError: Raised when there is no such key
r[   )	r\   r   r]   r   r#   r9   rF   ÚOSErrorÚKeyError)r'   r/   r   s   && r   Ú__getitem__ÚDirDBM.__getitem__Œ   se   € ô �A‹wœ%ÔÜÐ6Ó7Ð7Ø�‰×$Ñ$ T§\¡\°!£_Ó5ˆð	Ø—>‘> $Ó'Ð'øÜô 	Ü˜1“+Ðð	ús   ÁA ÁA3c               ó    € V ^8„  d   QhRRRR/# )r   r/   r   r   r   r   )r   s   "r   r   r   ž   s   € ÷ ,ñ ,˜Uð , tñ ,r   c                ó  € \        V4      \        8X  g   \        R4      hV P                  V4      p V P                  P                  V4      P                  4        R#   \         d    \        T P                  T4      4      hi ; i)z�
C{del dirdbm[foo]}
Delete a file in this directory.

@type k: bytes
@param k: key to delete

@raise KeyError: Raised when there is no such key
r[   N)
r\   r   r]   r9   r   r#   r$   rf   rg   r>   r8   s   &&r   Ú__delitem__ÚDirDBM.__delitem__ž   sk   € ô �A‹wœ%ÔÜÐ6Ó7Ð7Ø�L‰L˜‹Oˆð	,Ø�O‰O×!Ñ! !Ó$×+Ñ+Ö-øÜô 	,Ü˜4Ÿ<™<¨›?Ó+Ð+ð	,ús   ²)A Á&Bc               ó   € V ^8„  d   QhRR/# ©r   r   zIterable[bytes]r   )r   s   "r   r   r   °   s   € ÷ Pñ P�oñ Pr   c                óŒ   € \        \        V P                  V P                  P	                  4       P                  4       4      4      # )z)
@return: a L{list} of filenames (keys).
)ÚlistÚmapr>   r   ÚasBytesModerT   rU   s   &r   ÚkeysÚDirDBM.keys°   s0   € ô ”C˜Ÿ™ d§o¡o×&AÑ&AÓ&C×&KÑ&KÓ&MÓNÓOÐOr   c               ó   € V ^8„  d   QhRR/# ro   r   )r   s   "r   r   r   ¶   s   € ÷ ñ ˜ñ r   c                ój   € . pV P                  4       pV F  pVP                  W,          4       K  	  V# )z/
@return: a L{list} of file-contents (values).
©rt   Úappend)r'   Úvalsrt   Úkeys   &   r   ÚvaluesÚDirDBM.values¶   s1   € ð ˆØ�y‰y‹{ˆÛˆCØ�K‰K˜�	Ö"ñ àˆr   c               ó   € V ^8„  d   QhRR/# )r   r   zIterable[tuple[bytes, bytes]]r   )r   s   "r   r   r   À   s   € ÷ ñ Ð4ñ r   c                ón   € . pV P                  4       pV F  pVP                  W0V,          34       K  	  V# )z<
@return: a L{list} of 2-tuples containing key/value pairs.
rx   )r'   Úitemsrt   r{   s   &   r   r€   ÚDirDBM.itemsÀ   s6   € ð ˆØ�y‰y‹{ˆÛˆCØ�L‰L˜# C�yÐ)Ö*ñ àˆr   c               ó    € V ^8„  d   QhRRRR/# ©r   r{   r   r   Úboolr   )r   s   "r   r   r   Ê   s   € ÷ 3ñ 3˜5ð 3 Tñ 3r   c                ó´   € \        V4      \        8X  g   \        R4      hV P                  V4      pV P                  P                  V4      P                  4       # )z„
@type key: bytes
@param key: The key to test

@return: A true value if this dirdbm has the specified key, a false
value otherwise.
r[   )r\   r   r]   r9   r   r#   Úisfile©r'   r{   s   &&r   Úhas_keyÚDirDBM.has_keyÊ   sH   € ô �C‹yœEÔ!ÜÐ6Ó7Ð7Ø�l‰l˜3ÓˆØ�‰×$Ñ$ SÓ)×0Ñ0Ó2Ð2r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r{   r   Úvaluer   r   )r   s   "r   r   r   ×   s!   € ÷ ñ ˜eð ¨Eð °eñ r   c                ó*   € W9  d   W V&   V# W,          # )zŽ
@type key: bytes
@param key: The key to lookup

@param value: The value to associate with key if key is not already
associated with a value.
r   )r'   r{   r‹   s   &&&r   Ú
setdefaultÚDirDBM.setdefault×   s   € ð Œ?Ø�‰IØˆLØ�yÐr   c               ó    € V ^8„  d   QhRRRR/# )r   r{   r   r   r   )r   s   "r   r   r   å   s   € ÷ ñ �uð  ñ r   c                	ó   € R # ©Nr   r‡   s   &&r   ÚgetÚ
DirDBM.getä   ó   € ár   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r{   r   Údefaultr	   r   z
bytes | _Tr   )r   s   "r   r   r   é   s!   € ÷ ñ �uð  rð ¨jñ r   c                	ó   € R # r‘   r   ©r'   r{   r–   s   &&&r   r’   r“   è   r”   r   Nc               ó$   € V ^8„  d   QhRRRRRR/# )r   r{   r   r–   z	_T | Noner   zbytes | _T | Noner   )r   s   "r   r   r   ì   s"   € ÷ ñ �uð  yð Ð<Mñ r   c                ó"   € W9   d	   W,          # V# )z¿
@param key: The key to lookup

@param default: The value to return if the given key does not exist

@return: The value associated with C{key} or C{default} if not
    L{DirDBM.has_key(key)}
r   r˜   s   &&&r   r’   r“   ì   s   € ð Œ;Ø•9ÐàˆNr   c               ó    € V ^8„  d   QhRRRR/# rƒ   r   )r   s   "r   r   r   ú   s   € ÷ !ñ ! ð !¨$ñ !r   c                ó$   € V P                  V4      # )z
@see: L{DirDBM.has_key}
)rˆ   r‡   s   &&r   Ú__contains__ÚDirDBM.__contains__ú   s   € ð �|‰|˜CÓ Ð r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚotherzMapping[bytes, bytes]r   r   r   )r   s   "r   r   r      s   € ÷ ñ Ð1ð °dñ r   c                ó@   € VP                  4        F	  w  r#W0V&   K  	  R# )zÂ
Add all the key/value pairs in L{dict} to this dirdbm.  Any conflicting
keys will be overwritten with the values from L{dict}.

@param dict: A mapping of key/value pairs to add to this dirdbm.
N)r€   )r'   r    r{   Úvals   &&  r   ÚupdateÚDirDBM.update   s   € ð Ÿ™ž‰HˆCØ�‹Ió &r   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r   r   )r   s   "r   r   r   
  s   € ÷ ñ ˜5ð  Vñ r   c                óØ   € \        V4      pW P                  8w  g   Q hV P                  VP                  4      pVP	                  4        V P                  4        F  pW,          W4&   K  	  V# )zñ
Copy the contents of this dirdbm to the dirdbm at C{path}.

@param path: The path of the dirdbm to copy to.  If a dirdbm
exists at the destination path, it is cleared first.

@rtype: C{DirDBM}
@return: The dirdbm this dirdbm was copied to.
)r   r   Ú	__class__r   Úclearrt   )r'   r   ÚfpathÚdr/   s   &&   r   ÚcopyToÚDirDBM.copyTo
  sV   € ô ˜“ˆØŸ™Ô'Ð'Ð'à�N‰N˜5Ÿ:™:Ó&ˆØ	�‰Œ	Ø—‘–ˆAØ•7ˆA‹Dñ àˆr   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r   s   "r   r   r     s   € ÷ ñ �tñ r   c                ó8   € V P                  4        F  pW K  	  R# )z,
Delete all key/value pairs in this dirdbm.
N)rt   r8   s   & r   r¨   ÚDirDBM.clear  s   € ð —‘–ˆAØ’ó r   c               ó   € V ^8„  d   QhRR/# r®   r   )r   s   "r   r   r   $  s   € ÷ ñ �tñ r   c                ó   € R# )z<
Close this dbm: no-op, for dbm-style interface compliance.
Nr   rU   s   &r   ÚcloseÚDirDBM.close$  s   ‚ r   c               ó    € V ^8„  d   QhRRRR/# )r   r{   r   r   Úfloatr   )r   s   "r   r   r   )  s   € ÷  ñ   uð  °ñ  r   c                óö   € \        V4      \        8X  g   \        R4      hV P                  P	                  V P                  V4      4      pVP                  4       '       d   VP                  4       # \        V4      h)z¡
Returns modification time of an entry.

@return: Last modification date (seconds since epoch) of entry C{key}
@raise KeyError: Raised when there is no such key
r[   )	r\   r   r]   r   r#   r9   r†   ÚgetModificationTimerg   )r'   r{   r   s   && r   r¸   ÚDirDBM.getModificationTime)  s]   € ô �C‹yœEÔ!ÜÐ6Ó7Ð7Ø�‰×$Ñ$ T§\¡\°#Ó%6Ó7ˆØ�;‰;�=Š=Ø×+Ñ+Ó-Ð-ä˜3“-Ðr   )r   r   r‘   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r+   r9   r>   rF   rN   rV   rb   rh   rl   rt   r|   r€   rˆ   r�   r   r’   r�   r£   r«   r¨   r³   r¸   Ú__static_attributes__r   r   r   r   r       s¡   † ñõ&õ6NõNõõõ.õ õDõ$,õ$Põõõ3õð ôó ðð ôó ð÷õ!õõõ&õ÷
 ñ  r   r   c                  ó&   € ] tR tRtRtR tR tRtR# )ÚShelfi9  z³
A directory with a DBM shelf interface.

This class presents a hash-like interface to a directory of small,
flat files. Keys must be strings, but values can be any given object.
c                ó^   € \         P                  ! V4      p\        P                  WV4       R# )z™
C{shelf[foo] = bar}
Create or modify a textfile in this directory.

@type k: str
@param k: The key to set

@param v: The value to associate with C{key}
N)ÚpickleÚdumpsr   rb   )r'   r/   rY   s   &&&r   rb   ÚShelf.__setitem__A  s!   € ô �LŠL˜‹OˆÜ×Ñ˜4 AÖ&r   c                óT   € \         P                  ! \        P                  W4      4      # )zá
C{dirdbm[foo]}
Get and unpickle the contents of a file in this directory.

@type k: bytes
@param k: The key to lookup

@return: The value associated with the given key
@raise KeyError: Raised if the given key does not exist
)rÃ   Úloadsr   rh   r8   s   &&r   rh   ÚShelf.__getitem__N  s   € ô �|Š|œF×.Ñ.¨tÓ7Ó8Ð8r   r   N)rº   r»   r¼   r½   r¾   rb   rh   r¿   r   r   r   rÁ   rÁ   9  s   † ñò'ö9r   rÁ   c                ó   € \        V 4      # )z�
This is for 'anydbm' compatibility.

@param file: The parameter to pass to the DirDBM constructor.

@param flag: ignored
@param mode: ignored
)r   )ÚfileÚflagÚmodes   &&&r   rC   rC   \  s   € ô �$‹<Ðr   )NN)rC   r   rÁ   )r¾   Ú
__future__r   r5   r"   r   rÃ   Útypingr   r   r   r   r   Útwisted.python.filepathr   r	   r   rÁ   rC   Ú__all__r   r   r   Ú<module>rÑ      sV   ðñõ #ã Û Û 	Û ß ?Õ ?å ,áˆT˜Ô€÷V ñ V ôr 9ˆFô  9ôF	ò &‚r   