VL i"ddlmZddlmZmZmZddlmZmZddl m Z m Z m Z m Z ddlmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZddlmZm Z m!Z!m"Z"ddl#m$Z$dd l%Z%dd l&Z&dd l'Z'dd l(Z(d Z)Gd d eeeZ*y ) )suppress) FileDBBase ObjectDBR ObjectDBW) BadObjectAmbiguousObjectName)DecompressMemMapReaderFDCompressedSha1WriterFDStream Sha1Writer)OStreamOInfo) file_contents_ro_filepathENOENT hex_to_bin bin_to_hexexistschmodisfileremoverenamedirnamebasenamejoin) chunk_sizeloose_object_header_info write_object stream_copy) force_bytesN) LooseObjectDBceZdZdZeZeddZejdk(r eddZfdZ dZ dZ d Z d Zfd Zd Zd ZdZdZdZdZxZS)r z/A database which operates on loose object files444nt644cnt||t|_t t dd|_y)N O_NOATIMEr)super__init__dict_hexsha_to_filegetattros_fd_open_flags)self root_path __class__s T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/gitdb/db/loose.pyr)zLooseObjectDB.__init__Ms- ##v&b+q9c&t|dd|ddS)z{ :return: path at which the object with the given hexsha would be stored, relative to the database rootN)r)r/hexshas r2 object_pathzLooseObjectDB.object_pathVsF2AJqr ++r3ctt5|j|cdddS#1swYnxYw|j|j |}t |r||j|<|St |)z :return: readable object path to the object identified by hexsha :raise BadObject: If the object file does not existN)rKeyErrorr+db_pathr7rr)r/r6paths r2readable_db_object_pathz%LooseObjectDB.readable_db_object_path\sqh  0''/ 0 0 0 ||D,,V45 $<+/D  (Ks)2cd}|jD]5}t|jt|s'| t ||}7| t ||S)z:return: 20 byte binary sha1 string which matches the given name uniquely :param name: hexadecimal partial name (bytes or ascii string) :raise AmbiguousObjectName: :raise BadObject: N)sha_iterr startswithrrr)r/partial_hexsha candidatebinshas r2partial_to_complete_sha_hexz)LooseObjectDB.partial_to_complete_sha_hexlse  mmo #F&!,,[-HI(-n=="  #  N+ +r3c@|j|jt|} t||jS#t $rR}|j tk7r. t|cYd}~S#t $r}t||d}~wwxYwt||d}~wwxYw)z~ :return: memory map of that file to allow random read access :raise BadObject: if object could not be located)flagsN) r:r7rrr.OSErrorerrnorr)r/shar:enew_es r2_map_loose_objectzLooseObjectDB._map_loose_objects,,t// 3@A ,,WD#++5dooNLB~~%/3!"  #>>-  fllCKKI_I_`!w||W\\6<<,0,B,BDLLN >>^^FZZtZ,F ||D$4$4V$<=Hh'G KK$ /hx x*#] o.(D$9$9:  &<CCHM $F+_LLN x 6  >F23s+B G1'H "H1HH HH% c#Ktj|jD]F\}}}t|}t |dk7r!|D]!}t |dk7rt ||z#Hyw)Nr5&)r-walkr0rlenr)r/rootdirsfiles root_basefs r2r>zLooseObjectDB.sha_itersp!#)9!: 0 D$ I9~" 0q6R< Q// 0  0sA.A0cFtt|jS)N)rtupler>)r/s r2rWzLooseObjectDB.size s5)**r3)rO __module__ __qualname____doc__rr{intr~r-namer)r7r<rCrKrPrXrQr^rr>rW __classcell__)r1s@r2r r ?sq9#5!} ww$ua=:,  &,*+ 0 JX 0+r3r )+ contextlibr gitdb.db.baserrr gitdb.excrr gitdb.streamr r r r gitdb.baser r gitdb.utilrrrrrrrrrrrr gitdb.funrrrrgitdb.utils.encodingrrtr-ryr__all__r r3r2rsp        -  M+J 9M+r3