+
    ^|i{"                         R t Rt^ RIHt ^ RIt^ RIt^ RIt ^ RIHt	  ^ RIt^ RIt^ RItR t]! 4       t ! R R]	P&                  4      t ! R R4      tR#   ]
 d    ^ RIt	 LEi ; i  ]
 d    ^ RIt LQi ; i)	a]  
Vendoring of pickleshare, reduced to used functionalities.

---

PickleShare - a small 'shelve' like datastore with concurrency support

Like shelve, a PickleShareDB object acts like a normal dictionary. Unlike
shelve, many processes can access the database simultaneously. Changing a
value in database is immediately visible to other processes accessing the
same database.

Concurrency is possible because the values are stored in separate files. Hence
the "database" is a directory where *all* files are governed by PickleShare.

Example usage::

    from pickleshare import *
    db = PickleShareDB('~/testpickleshare')
    db.clear()
    print "Should be empty:",db.items()
    db['hello'] = 15
    db['aku ankka'] = [1,2,313]
    db['paths/are/ok/key'] = [1,(5,46)]
    print db.keys()
    del db['aku ankka']

This module is certainly not ZODB, but can be used for low-load
(non-mission-critical) situations where tiny code size trumps the
advanced features of a "real" object database.

Installation guide: pip install pickleshare

Author: Ville Vainio <vivainio@gmail.com>
License: MIT open source license.

z0.7.5)PathNc                 L    R \        \        V 4      R,          4      ,          RR # )z%02x   N)abshash)keys   &>/usr/lib/python3/dist-packages/IPython/external/pickleshare.pygethashfiler
   :   s!    ScS))23//    c                      a  ] tR t^At o RtR tR tR tR t]	R3R lt
R tR	 tR
 tR tRR ltR tR tR tRR ltR tR tRtV tR# )PickleShareDBz5The main 'connection' object for PickleShare databasec                   \        V\        4      '       g   \        V4      p\        P                  P	                  \        P                  P                  V4      4      p\        V4      V n        V P                  P                  4       '       g    V P                  P                  RR7       / V n        R#   \         d+   pTP                  \        P                  8w  d   h  Rp?L9Rp?ii ; i)z9Return a db object that will manage the specied directoryTparentsN)
isinstancestrospathabspath
expanduserr   rootis_dirmkdirOSErrorerrnoEEXISTcache)selfr   es   && r	   __init__PickleShareDB.__init__D   s    $$$t9Dwwrww11$78J	yy!!		-
 
	  77ell* +s   B4 4C)? C$$C)c                2   V P                   V,          p VP                  4       \        P                  ,          pY P
                  9   d9   Y0P
                  T,          ^,          8X  d   T P
                  T,          ^ ,          #  TP                  R4      ;_uu_ 4       p\        P                  ! TP                  4       4      pRRR4       XT3T P
                  T&   T#   \         d    \	        T4      hi ; i  + '       g   i     L=; i   \	        T4      h; i)zdb['key'] readingrbN)
r   statST_MTIMEr   KeyErrorr   openpickleloadsread)r   r   filmtimefobjs   &&    r	   __getitem__PickleShareDB.__getitem__U   s    ii#o	 HHJt}}-E ****S/!*<!<::c?1%%	 $1ll1668,  
 ,

3
  	 3-	   	 3-s5   %C D	 %C6D	 C36D	D	 D	 	Dc                   V P                   V,          pVP                  pV'       d)   VP                  4       '       g   VP                  RR7       VP	                  R4      ;_uu_ 4       p\
        P                  ! W%^R7       RRR4        W#P                  4       P                  3V P                  V&   R#   + '       g   i     L;; i  \         d,   pTP                  \        P                  8w  d   h  Rp?R# Rp?ii ; i)zdb['key'] = 5Tr   wb)protocolN)r   parentr   r   r'   r(   dumpr$   st_mtimer   r   r   ENOENT)r   r   valuer+   r4   r-   r   s   &&&    r	   __setitem__PickleShareDB.__setitem__i   s    ii#o&--//LLL& XXd^^qKK1- 	$hhj&9&9:DJJsO ^  	ww%,,& '	s$   )B5(C 5C	C> C99C>c                    V P                   V,          pVP                  4       '       g   VP                  4        V\        V4      ,          pV P	                  V/ 4      pVP                  W#/4       W`V&   R# )z
hashed setN)r   r   r   r
   getupdate)r   hashrootr   r8   hroothfileds   &&&&   r	   hsetPickleShareDB.hsety   sX    		H$||~~KKMC((HHUB	#Ur   Tc                   V P                   V,          pV\        V4      ,          pV P                  V\        4      pV\        J d1   V'       d   V\        J d   \	        V4      hV# V P                  V4      pVP                  W#4      # )z
hashed get)r   r
   r<   	_sentinelr&   hdict)r   r>   r   default	fast_onlyr?   r@   rA   s   &&&&&   r	   hgetPickleShareDB.hget   so    		H$C((HHUI&	>i'"3-' 

8$AuuS""r   c                   V P                  VR,           4      pVP                  4        \        V4      ;'       d    VR,          ;'       g    RpVP                  R4      '       d   V.VRR ,           p/ pV F,  p VP	                  W,          4       V P                  V4       K.  	  V#   \
         d    \        RTR4       Y  L3i ; i)z<Get all data contained in hashed category 'hashroot' as dict/* xxNCorruptz!deleted - hset is not threadsafe!)keyssortlenendswithr=   r&   printuncache)r   r>   hfileslastallr-   s   &&    r	   rF   PickleShareDB.hdict   s    8d?+6{))vbz//R==VfSbk)FA

47#
 LLO  
  i$GHGs   ;B))CCc                0   V P                  VR,           4      p/ pV F+  pVP                  W,          4       V P                  V4       K-  	  W0VR,           &   V F9  pV P                  V,          pVP                  R8X  d   K)  VP                  4        K;  	  R# )zCompress category 'hashroot', so hset is fast again

hget will fail if fast_only is True for compressed items (that were
hset before hcompress).

rL   z/xxrN   N)rQ   r=   rV   r   nameunlink)r   r>   rW   rY   r-   ps   &&    r	   	hcompressPickleShareDB.hcompress   s{     8d?+AJJtwLLO 
 "%XA		AAvv~HHJ	 r   c                    V P                   V,          pV P                  P                  VR4        VP                  4        R#   \         d     R# i ; i)zdel db["key"]N)r   r   popr]   r   )r   r   r+   s   && r	   __delitem__PickleShareDB.__delitem__   sC    ii#o

sD!	JJL 	 	s   A AAc                j    \        VP                  V P                  4      4      P                  RR4      # )z#Make a key suitable for user's eyes\/)r   relative_tor   replace)r   r^   s   &&r	   _normalizedPickleShareDB._normalized   s'    1==+,44T3??r   Nc                    Vf   V P                   P                  R4      pMV P                   P                  V4      pV Uu. uF+  q3P                  4       '       g   K  V P	                  V4      NK-  	  up# u upi )z+All keys in DB, or all keys matching a glob*)r   rglobglobis_filerj   )r   globpatfilesr^   s   &&  r	   rQ   PickleShareDB.keys   sY     ?IIOOC(EIINN7+E-2BUiik#  #UBBBs    A4A4c                4    \        V P                  4       4      # N)iterrQ   r   s   &r	   __iter__PickleShareDB.__iter__   s    DIIK  r   c                4    \        V P                  4       4      # ru   )rS   rQ   rw   s   &r	   __len__PickleShareDB.__len__   s    499;r   c                n    V'       g   / V n         V F  pV P                   P                  VR4       K!  	  R# )zRemoves all, or specified items from cache

Use this after reading a large amount of large objects
to free up memory, when you won't be needing the objects
for a while.

N)r   rb   )r   itemsits   &* r	   rV   PickleShareDB.uncache   s*     DJBJJNN2t$ r   c                F   R.^,          R.^,          ,           ^.,           p^ p^ p  W,          pV#   \          d     Mi ; iYR8  d   \        T4      h\        P                  ! Y4,          4       YST,          ,          pT\        T4      ^,
          8  g   Kr  T^,          pK}  )a  Wait (poll) for a key to get a value

Will wait for `maxwaittime` seconds before raising a KeyError.
The call exits normally if the `key` field in db gets a value
within the timeout period.

Use this for synchronizing different processes or for ensuring
that an unfortunately timed "db['key'] = newvalue" operation
in another process (which causes all 'get' operation to cause a
KeyError for the duration of pickling) won't screw up your program
logic.
g?g      ?)r&   timesleeprS   )r   r   maxwaittimewtimestrieswaitedvals   &&&    r	   waitgetPickleShareDB.waitget   s     cUQY&!,i
  #sm#JJv}%Um#Fs6{Q&
s   	2 A A c                    \        W4      # )z)Get a convenient link for accessing items)PickleShareLink)r   folders   &&r	   getlinkPickleShareDB.getlink  s    t,,r   c                (    R V P                   ,          # )zPickleShareDB('%s'))r   rw   s   &r	   __repr__PickleShareDB.__repr__  s    $tyy00r   )r   r   ru   )<   )__name__
__module____qualname____firstlineno____doc__r    r/   r9   rB   rE   rI   rF   r_   rc   rj   rQ   rx   r{   rV   r   r   r   __static_attributes____classdictcell____classdict__s   @r	   r   r   A   sg     ?"(  +4t #&.*	@C! %@-1 1r   r   c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	r   i  zA shortdand for accessing nested PickleShare data conveniently.

Created through PickleShareDB.getlink(), example::

    lnk = db.getlink('myobjects/test')
    lnk.foo = 2
    lnk.bar = lnk.foo + 5

c                L    V P                   P                  \        4       4       R # ru   )__dict__r=   locals)r   dbkeydirs   &&&r	   r    PickleShareLink.__init__   s    VX&r   c                t    V P                   R ,          V P                   R,          R,           V,           ,          # )r   r   rg   )r   )r   r   s   &&r	   __getattr__PickleShareLink.__getattr__#  s)    }}T"4==#:S#@3#FGGr   c                R    W P                   V P                  R ,           V,           &   R# )rg   N)r   r   )r   r   r   s   &&&r	   __setattr__PickleShareLink.__setattr__&  s    +.c!C'(r   c                (   V P                   R ,          pVP                  V P                   R,          R,           4      pRV P                   R,          : RRP                  V Uu. uF  p\        V4      P	                  4       NK  	  up4      : R2# u upi )r   r   rL   z<PickleShareLink 'z': ;>)r   rQ   joinr   basename)r   r   rQ   ks   &   r	   r   PickleShareLink.__repr__)  sp    ]]4 wwt}}X.56MM(##HH$7$Qd1g&&($78
 	
7s   ""B N)r   r   r   r   r   r    r   r   r   r   r   r   s   @r	   r   r     s$     'H/
 
r   r   )r   __version__pathlibr   r   r$   r   collections.abcabccollections_abcImportErrorcollectionscPickler(   r   sysr
   objectrE   MutableMappingr   r   r   r   r	   <module>r      s   $L    *-  
0 H	Q1O22 Q1h
 
K  *)*  s"   A A' A$#A$'A54A5