f5ddlmZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z ddl mZddlmZmZmZmZiZej*dZd Zd Zdd Z dd ZGd de Z ddZddZdZy)) annotationsN)Optional)AsyncFileSystem_run_coros_in_chunks sync_wrapper)DEFAULT_CALLBACK) filesystemget_filesystem_classsplit_protocol url_to_fszfsspec.genericc *t|fi|t|<yN)r _generic_fs)protocolstorage_optionss W/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/fsspec/generic.pyset_generic_fsrs&xC?CKdefaultc*|xst}|xst|d}|xsi}|dk(r t|S|dk(r t|S|dk(rt |}|j S|dk(r!t |fi|j|i\}}|Std|)zPick instance of backend FSrrgenericcurrentoptionszUnknown FS resolution method: ) default_methodr r rr rr get ValueError)urlmethodrrclsfs_s r _resolve_fsr#s  %~F1>#.q1H%+O (## 8$$ "8,{{} #C!4!4Xr!BCA 5fX> ??rc |xstdi|xsi}|j|}|j|}|j|dd} |j|s t d|j|dd} | j D cgc]#\} } | ddk(r| j ||| vr| %} } } tjt| d| r1|j| Dcgc]}|j ||c}d| j D cic]\} } | ddk(s| | } } } tjt| d | j D cgc]#\}} |j ||| vr | ddk(r|%}}} | jj D]\}} |j ||}|| vrc|d k(r|| |<'|d k(s-t|r|| n| |}| |}t|r||n||}||k7r|| |<m| j||| |<tjt| d | r-t| j \}}|j||fi|tjt|d |r|r|j!|| Scc} } wcc}wcc} } wcc} }w)aUSync files between two directory trees (experimental) Parameters ---------- source: str Root of the directory tree to take files from. This must be a directory, but do not include any terminating "/" character destination: str Root path to copy into. The contents of this location should be identical to the contents of ``source`` when done. This will be made a directory, and the terminal "/" should not be included. delete_missing: bool If there are paths in the destination that don't exist in the source and this is True, delete them. Otherwise, leave them alone. source_field: str | callable If ``update_field`` is "different", this is the key in the info of source files to consider for difference. Maybe a function of the info dict. dest_field: str | callable If ``update_field`` is "different", this is the key in the info of destination files to consider for difference. May be a function of the info dict. update_cond: "different"|"always"|"never" If "always", every file is copied, regardless of whether it exists in the destination. If "never", files that exist in the destination are not copied again. If "different" (default), only copy if the info fields given by ``source_field`` and ``dest_field`` (usually "size") are different. Other comparisons may be added in the future. inst_kwargs: dict|None If ``fs`` is None, use this set of keyword arguments to make a GenericFileSystem instance fs: GenericFileSystem|None Instance to use if explicitly given. The instance defines how to to make downstream file system instances from paths. Returns ------- dict of the copy operations that were performed, {source: destination} T)withdirsdetailzCan only rsync on a directorytype directoryz directories to createexist_okfilez files to consider for copyalways differentz files to copyz files to delete)GenericFileSystem_strip_protocolfindisdirritemsreplaceloggerdebuglenmake_many_dirscopycallablepopzipcprm)source destinationdelete_missing source_field dest_field update_cond inst_kwargsr!kwargsallfiles otherfilesavdirsdirno to_deletek otherfileinf1v2inf2 source_files target_filess rrsyncrV+sh 7 7K$527B    'F$$[1KwwvTw:H 88F 899tDAJNN$  Aq V9 # &+(Fj(X  D   LLCI;456  ;? @4T\\&+ . @4  "*!1IAQvY&5H1IHI LLCM?"=>?$$& Aq 99[& ) 9ai6>Q I  %%'1IIfk2  "h&'  +*2<*@|Aa o *)1*)=z"~2j>4<"+HQKLLO$HQK#($ LLCM?.12%((..*:%;" l lL3F3 LLC N##345) i OU  AIs (K*K K0K,(KceZdZdZdZdfd ZdZdZddZdZ ddZ d Z d Z d Z dd Zd ZdefdZddZeeZ d ddZxZS)r/a^Wrapper over all other FS types This implementation is a single unified interface to be able to run FS operations over generic URLs, and dispatch to the specific implementations using the URL protocol prefix. Note: instances of this FS are always async, even if you never use it with any async backend. rc 2||_t|di|y)aK Parameters ---------- default_method: str (optional) Defines how to configure backend FS instances. Options are: - "default": instantiate like FSClass(), with no extra arguments; this is the default instance of that FS, and can be configured via the config system - "generic": takes instances from the `_generic_fs` dict in this module, which you must populate before use. Keys are by protocol - "current": takes the most recently instantiated version of each FS Nr.)rsuper__init__)selfrrF __class__s rrZzGenericFileSystem.__init__s%  "6"rcnt||j}|j|j|Sr)r#runstrip_protocol_parentr[pathr!s rr_zGenericFileSystem._parents, t{{ +""2::d#344rcnt||j}|j|j|Sr)r#rr^r0r`s rr0z!GenericFileSystem._strip_protocols. t{{ +""2#5#5d#;<s:AAAcK|}t|tr|g}t|d|j}|jr|j |fi|d{y|j |fi|y7w)Nr) isinstancestrr#rrf_rmr>)r[rrFurlsr!s rr{zGenericFileSystem._rmsh dC 6D a$++ . =="&&(( ( ( BEE#   )sAA/A-A/cKtjd|t||j}|jr|j ||d{y|j ||y7w)Nz Make dir %sr))r5r6r#rrf _makedirsmakedirs)r[rar*r!s rr~zGenericFileSystem._makedirssV ]D) t{{ + ==,,th,7 7 7 KKxK 0 8sAA-A+A-c "t||fd|i|y)z[Sync files between two directory trees See `func:rsync` for more details. r!N)rV)r[r?r@rFs rrVzGenericFileSystem.rsyncs fk5d5f5ric:Kt||j}t||j}||ur<|jr|j||fi|d{S|j||fi|Sddd} t |dr|j |dd{n|j|dfi|} |jt| jd{t |dr|j |dd{n|j|dfi|} | j| j| jkrt| j|d{} | j| snlt| j| d{|j| j| j| j| jkr t| jd{t| jd{y777S7,77767#t $rYywxYw# t jd{7t jd{7w#t $rYwwxYwxYww)Nrnone) blocksize cache_type open_asyncrbwb)r#rrf_cp_filecp_filehasattrropenset_size maybe_awaitsizetellreadwriteabsolute_updateclose NameError) r[rurl2rcallbackrFr!fs2kwf1f2datas rrzGenericFileSystem._cp_files:dkk *$ , 9}}(R[[d=f===!rzz#t6v66F 3 2|,mmC...RWWS$-"-    K$88 93 -nnT4000SXXdD/B/  ''/RWWY%8();<<77?4!"((4.111((3 ''/RWWY%8 !"((*---!"((*---3> /90 =2.-   !"((*---!"((*---  s AJHJ5!IH";IH%)I<H(=AIH+0I H- /I=IH38H/9 H3H1H3J"I%I(I+I-I/H31H33 H?<J>H??JJJ  I#!!J JJ J JJJJJcKt|d|j}|jr4|Dcgc]}|j||}}t |d{y|D]}|j ||ycc}w7%w)Nrr))r#rrfr~rr)r[r|r*r!ucoross r_make_many_dirsz!GenericFileSystem._make_many_dirsHsr a$++ . ==AEFAR\\!h\7FEF&u- - - A 1G -s*A>A7A>A<&A>c <K|rtt|d|j} t|d|j} | | ur<| jr| j||fi|d{S| j ||fi|St | || ||||d{y737w)Nron_error)NotImplementedErrorr#rrf_copyr9 copy_file_op) r[path1path2 recursiverrd batch_sizetempdirrFr!rs rrzGenericFileSystem._copySs % % q4;; /%(DKK0 9}}%RXXeU=f===rwwue6v66 sE7J   > s$A"B$B%-BBBB)r)NFF)T)F)FignoreNNN)r list[str]rrrboolrrzrd Optional[int]rrrz Optional[str])__name__ __module__ __qualname____doc__rrZr_r0rgrlrorrrur{r~rVr rrrr8r __classcell__)r\s@rr/r/s H#"5= (,& . 7!16! )V2"/2N   "&$(!%         "  rr/cKddl}|xs|j} t||D cgc]P\}} t|||| tj j |tjj|R} }} t| |d{tj|ycc} }w7 #tj|wxYww)Nrr)r) tempfilemkdtempr< _copy_file_oposrajoinuuiduuid4hexrshutilrmtree) fs1url1rrrrrru1u2rs rrrns+))+GdD/  B  Wdjjl&6&67!      #5Z@@@ g   A gs:CB6AB.B6B4B6C.B66C  CcK|dk(rdnt}tjd|| |jr|j ||d{n|j |||jr|j ||d{n|j||tj|tjd||y7}7F#|$r!}tjd||Yd}~yd}~wwxYww)Nraiser.z Copy %s -> %szCopy %s -> %s; donez ignoring cp exception for %s: %s) Exceptionr5r6rf _get_fileget_file _put_fileput_filerunlink)rrrrlocalrexes rrrs7" B LL$- B >>--e, , , LLu % >>--t, , , LL % % *D$7 - - B 7qAABsS%C4!C C 8C C AC C4C C C1C,'C4,C11C4cPKtj|r |d{S|S7wr)inspect iscoroutine)cors rrrs&3y s &$&)NNN)Frrr-NN)Nr)r) __future__rrloggingrrrtypingrasynrrr callbacksr corer r r r r getLoggerr5rrr#rVr/rrrr.rrrs" EE'MM   + ,D@* ePX X xAI.B$r