""!dZddlZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZmZmZe eefZe eejfZejdkZejdkZejdZd Zd Zd Zd Zd Z dZ!ejdkrda"da#nej$a"ej%a#de&fdZ'de&ddfdZ(de&fdZ)de&ddfdZ*d6dZ+de,fdZ-de de,fdZ.de de,fdZ/de de,fdZ0ededefdZ1edejdefdZ1dedefd Z1d!e ee eeffdefd"Z2d!e ee eeffdefd#Z3d$ed%edefd&Z4d'e ede efd(Z5d)Z6ed*ed+edefd,Z7ed*ed+edefd-Z7ed*ed+dddfd.Z7d*ed+e ede efd/Z7Gd0d1Z8Gd2d3ej9Z:Gd4d5ej;ZpCrcdSr<rr=s rr>r>ur?rcPtttj|Sr<)r r r'fspathr=s rr>r>zs  (++ , ,,rpathc~t|tr'|tjdS|S)zzReturn the string representation of a byte string using the preferred encoding, or the string itself if path is a str.F)r/bytesdecodelocalegetpreferredencodingrCs r to_stringrJ~s8$?{{66u==>>> Krctt|tr"t|tjdS|S)zReturn the bytes representation of a string using the preferred encoding, or the byte string itself if path is a byte string.F)r/strrErGrHrIs rto_bytesrMs6$?T66u==>>> Krs1s2c ||zS)z!?!?!%!2!%!2rotherrclt|to|j|jko|j|jko|j|jkoo|j|jko_|j|jkoO|j|jko?|j|jko/|j |j ko|j |j ko|j |j kSr<) r/rdrrrtrsst_sizerprornrmrlrkrurws r__eq__zFakeStatResult.__eq__s un - - .!U%77 .!U%77 .!U%77 .  - .  u|+ .  u|+ . / . u|+ . u|+ .  - rc||k Sr<rrzs r__ne__zFakeStatResult.__ne__s5=  rc$t|}|S)ztReturn a copy where the float usage is hard-coded to mimic the behavior of the real os.stat_result. rru stat_results rrzFakeStatResult.copys4jj rrc|j|_|j|_|j|_|j|_|j|_|j|_|j |_ dS)zSet values from a real os.stat_result. Note: values that are controlled by the fake filesystem are not set. This includes st_ino, st_dev and st_nlink. N) rkrorpryrq st_atime_nsrr st_mtime_nsrs st_ctime_nsrtrs rset_from_stat_resultz#FakeStatResult.set_from_stat_resultsS #* !( !( #+ '3'3'3rc|jdz S)z$Return the creation time in seconds.rjrtrus rst_ctimezFakeStatResult.st_ctime 3&&rr-c4t|dz|_dS)z!Set the creation time in seconds.rjN)r0rtrur-s rrzFakeStatResult.st_ctime c NNrc|jdz S)z"Return the access time in seconds.rjrrrs rst_atimezFakeStatResult.st_atimerrc4t|dz|_dS)zSet the access time in seconds.rjN)r0rrrs rrzFakeStatResult.st_atime rrc|jdz S)z(Return the modification time in seconds.rjrsrs rst_mtimezFakeStatResult.st_mtimerrc4t|dz|_dS)z%Set the modification time in seconds.rjN)r0rsrs rrzFakeStatResult.st_mtimerrcR|jtztkr |jrdS|jS)Nr)rkrrerqrs rryzFakeStatResult.st_sizes( <' !W , , ,1}rc||_dSr<)rqrs rryzFakeStatResult.st_sizes  rcx|jrtdd}|dz}|j|z}|j|zr|dz }||zS)aReturn the number of 512-byte blocks allocated for the file. Assumes a page size of 4096 (matches most systems). Ignores that this may not be available under some systems, and that the result may differ if the file has holes. z4'os.stat_result' object has no attribute 'st_blocks'iir)reAttributeErrorrq)ru page_sizeblocks_in_pagepagess r st_blockszFakeStatResult.st_blocks#s\ ? Y !WXX X "c) * =9 $  QJE~%%rcN|jstdd}|j}|tjzr|tjz}|tjzr|tjz}|tjtj zzr|tj z}|tj zr|tj z}|S)Nz=module 'os.stat_result' has no attribute 'st_file_attributes'r) rerrkstatS_IFDIRFILE_ATTRIBUTE_DIRECTORYS_IFREGFILE_ATTRIBUTE_NORMALS_IFCHRS_IFBLKFILE_ATTRIBUTE_DEVICErFILE_ATTRIBUTE_REPARSE_POINT)rumoderks rst_file_attributesz!FakeStatResult.st_file_attributes3s  R , T\ ! 2 D1 1D T\ ! / D. .D dlT\1 2 / D. .D T\ ! 6 D5 5D rc|jrtjdkrtd|jt jzr t jSdS)N)rTz9module 'os.stat_result' has no attribute 'st_reparse_tag'r)rer%rVrrkrrIO_REPARSE_TAG_SYMLINKrs rst_reparse_tagzFakeStatResult.st_reparse_tagEsO #"2V";"; N  <$, & /. .qritemcddl}||jkr|jS||jkr|jS||jkr|jS||jkr|jS||j kr|j S||j kr|j S||j kr|jS||jkrt!|jS||jkrt!|jS||jkrt!|jSt-d)z9Implement item access to mimic `os.stat_result` behavior.rNz Invalid item)rST_MODErkST_INOrlST_DEVrmST_NLINKrnST_UIDroST_GIDrpST_SIZEryST_ATIMEr0rST_MTIMErST_CTIMEr ValueError)rurrs r __getitem__zFakeStatResult.__getitem__Os 4<  <  4;  ;  4;  ;  4= = 4;  ;  4;  ;  4<  <  4= t}%% % 4= t}%% % 4= t}%% %(((rc|jS)z&Return the access time in nanoseconds.rrs rrzFakeStatResult.st_atime_nsj   rc||_dS)z#Set the access time in nanoseconds.Nrrs rrzFakeStatResult.st_atime_nso rc|jS)z,Return the modification time in nanoseconds.rrs rrzFakeStatResult.st_mtime_nstrrc||_dS)z:Set the modification time of the fake file in nanoseconds.Nrrs rrzFakeStatResult.st_mtime_nsyrrc|jS)z(Return the creation time in nanoseconds.rrs rrzFakeStatResult.st_ctime_ns~rrc||_dS)z6Set the creation time of the fake file in nanoseconds.Nrrs rrzFakeStatResult.st_ctime_nsrrr<)rrd)__name__ __module__ __qualname____doc__boolr0rfloatrvrr{r}rr'rrpropertyrrsetterrrryrrrrrrrrrrrdrds)- 3333 3 uo 3333&  C  D     !C!D!!!! 4 44 4 4 4 4'%U +'''X'_+E#u*-+$+++_+'%U +'''X'_+E#u*-+$+++_+'%U +'''X'_+E#u*-+$+++_+X  ^34^ &3 & & &X &CX"X)) ))))6!S!!!X! s t    !S!!!X! s t    !S!!!X! s t      rrdcDeZdZdZdeeffd ZdeddfdZxZS)BinaryBufferIOz2Stream class that handles byte contents for files.contentscNt|pddSNr)superrv)rur __class__s rrvzBinaryBufferIO.__init__s% S)))))rvaluerNc0||dSr<)writerurs rputvaluezBinaryBufferIO.putvalues 5r) rrrrrrErvr __classcell__rs@rrrsp<<*%******errc ~eZdZdZ d deedeedeedeffd Zd efd Zd ed dfd Z xZ S) TextBufferIOz;Stream class that handles Python string contents for files.NstrictrnewlinerRerrorsctj|pd|_t|j|||dSr)ioBytesIO _bytestreamrrv)rurrrRrrs rrvzTextBufferIO.__init__sB:ho#66 )8VWEEEEErrc4|jSr<)rgetvaluers rrzTextBufferIO.getvalues((***rrc:|j|dSr<)rrrs rrzTextBufferIO.putvalues u%%%%%r)NNNr) rrrrrrErLrvrrrrs@rrrsEE%)!%"& FF5/F#F3- F  FFFFFF+%++++&e&&&&&&&&&rr)rN)=rrrGr'r&rr%rYrrtypingrrrr r r rLrE AnyStringPathLikeAnyPathpython_implementationIS_PYPYIS_WINrCexists IN_DOCKER PERM_READ PERM_WRITEPERM_EXEPERM_DEF PERM_DEF_FILEPERM_ALLrrr(r)r0rrr r#r*rr,r2r7r9r>rJrMrQrWrZr_rdrr TextIOWrapperrrrrrs>=  ???????????????? #u*   # $ (( ( * *f 4   GNN= ) )     <7GHHbikkGry{{H         S T    &&&&&& "3"4""""  v&  r{s -w-6----E&%U "3345sEz!223VF HSMhsm UFu  S&S  VTd    %f-  i    J J J J J J J J ZRZ&&&&&2#&&&&&r