
    ch                     |    S r SSKJr  SSKJrJr  SSKJrJr  SSK	J
r
Jr  SSKJrJr  SSKJr  Sr " S	 S
\\5      rg)z*Contains the MemoryDatabase implementation    )LooseObjectDB)	ObjectDBR	ObjectDBW)OStreamIStream)	BadObjectUnsupportedOperation)ZippedStoreShaWriterDecompressMemMapReader)BytesIO)MemoryDBc                   \   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	 rS
 rS rSrU =r$ )r       a#  A memory database stores everything to memory, providing fast IO and object
retrieval. It should be used to buffer results and obtain SHAs before writing
it to the actual physical storage, as it allows to query whether object already
exists in the target storage before introducing actual IOc                 `   > [         TU ]  5         [        S5      U l        [	        5       U l        g )Nzpath/doesnt/matter)super__init__r   _dbdict_cache)self	__class__s    _C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\gitdb/db/mem.pyr   MemoryDB.__init__'   s&     !56 f    c                     [        S5      e)Nz$MemoryDB's always stream into memory)r	   )r   streams     r   set_ostreamMemoryDB.set_ostream.   s    "#IJJr   c                 ~   [        5       nU R                  R                  U5        U R                  R                  U5      nUR	                  5         UR                  S5        [        UR                  5       SS9n[        UR                  UR                  UR                  U5      U R                  UR                  '   U$ )Nr   F)close_on_deletion)r
   r   r   storecloseseekr   getvaluer   binshatypesizer   )r   istreamzstreamdecomp_streams       r   r!   MemoryDB.store1   s    &(W%((..)Q /w/?/?/AUZ[&-gnngllGLLZg&hGNN#r   c                     XR                   ;   $ N)r   r   shas     r   
has_objectMemoryDB.has_object@   s    kk!!r   c                 $    U R                  U5      $ r-   )r   r.   s     r   infoMemoryDB.infoC   s    {{3r   c                      U R                   U   nUR                  R                  S5        U$ ! [         a  n[	        U5      UeS nAff = f)Nr   )r   r   r#   KeyErrorr   )r   r/   ostreames       r   r   MemoryDB.streamG   sH    	(kk#&GNN"N 	(C.a'	(s   +. 
A	AA	c                 ,    [        U R                  5      $ r-   )lenr   r   s    r   r'   MemoryDB.sizeQ   s    4;;r   c                 6    U R                   R                  5       $ r-   )r   keysr<   s    r   sha_iterMemoryDB.sha_iterT   s    {{!!r   c                 "   SnU H  nUR                  U5      (       a  M  U R                  U5      n[        UR                  R                  5       5      n[	        UR
                  UR                  Xd5      nUR                  U5        US-  nM     U$ )aR  Copy the streams as identified by sha's yielded by sha_iter into the given odb
The streams will be copied directly
**Note:** the object will only be written if it did not exist in the target db

:return: amount of streams actually copied into odb. If smaller than the amount
    of input shas, one or more objects did already exist in odbr      )r0   r   r   datar   r&   r'   r!   )r   r@   odbcountr/   r7   sior(   s           r   stream_copyMemoryDB.stream_copyX   s~     C~~c"" kk#&G'..--/0CgllGLL#CGIIgQJE  r   )r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r!   r0   r3   r   r'   r@   rH   __static_attributes____classcell__)r   s   @r   r   r       s<    A
K" ( " r   r   N)rN   gitdb.db.looser   gitdb.db.baser   r   
gitdb.baser   r   	gitdb.excr   r	   gitdb.streamr
   r   ior   __all__r    r   r   <module>rY      s;   
 1 (



 
My) Mr   