Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
generic.cpython-313.pyc168 linesDownload Raw Back to __pycache__
1�

2�j�4����SSKJr SSKrSSKrSSKrSSKrSSKrSSKJrJ	r	J3r4 SSKJr SSK
JrJrJrJr 0r\R&"S5rSrSS	jrSS5jr"SS\5rSS
jrSSjrSrg)�)�annotationsN�)�AsyncFileSystem�_run_coros_in_chunks�sync_wrapper)�DEFAULT_CALLBACK)�6filesystem�get_filesystem_class�split_protocol�	url_to_fszfsspec.genericc�*�[U40UD6[U'g)z4Populate the dict used for method=="generic" lookupsN)r	�_generic_fs)�protocol�storage_optionss  �TD:\code\apps\devtools\python\user_packages\Python313\site-packages\fsspec/generic.py�set_generic_fsrs��&�x�C�?�C�K���c�t�[U[[45(aUSOUnU=(d [U5SnU=(d 0nUS:Xa[	U5$US:Xa	[7U$US:Xa[
U5nUR5$US:Xa [U40URU05D6upVU$[SU35e)zPick instance of backend FSr�default�generic�current�optionszUnknown FS resolution method: )�8isinstance�list�tuplerr	rr9rr�get�10ValueError)�url�methodrr�cls�fs�_s       r�_resolve_fsr#s����s�T�5�M�2�2�#�a�&��C��1�>�#�.�q�1�H�%�+��O�
����(�#�#�
����8�$�$�
���"�8�,���{�{�}��
����#�C��!4�!4�X�r�!B�C����	�11�5�f�X�>�12?�?rc	�h�U=(d [S0U=(d 0D6nURU5nURU5nURUSSS9n	URU5(d[	S5eURUSSS9n13U	R5VVs/sH)up�USS:XdMUR
X5U14;dM'UPM+ n
nn[R[U
5S35 U
(a/URU
Vs/sHo�R
X5PM snSS9 U	R5VVs0sHup�USS:XdMX�_M n	nn[R[U	5S	35 U15R5VVs/sH)up�UR
X5U	;dMUSS:XdM'UPM+ nnnU	R5R5H�unnUR
X5nUU16;a�US17:XaUU	U'M*US:XaU	RU5 MCUS:Xa^[U5(aU"U5OX�nU18Un[U5(aU"U5OUUnUU:waUU	U'M�U	RU5 M�M�UU	U'M� [R[U	5S
35 U	(a-[U	R56unnUR"UU40UD6 [R[U5S35 U(aU(aUR!U5 U	$s snnfs snfs snnfs snnf)a�Sync files between two directory trees19 20(experimental)21 22Parameters23----------24source: str25    Root of the directory tree to take files from. This must be a directory, but26    do not include any terminating "/" character27destination: str28    Root path to copy into. The contents of this location should be29    identical to the contents of ``source`` when done. This will be made a30    directory, and the terminal "/" should not be included.31delete_missing: bool32    If there are paths in the destination that don't exist in the33    source and this is True, delete them. Otherwise, leave them alone.34source_field: str | callable35    If ``update_field`` is "different", this is the key in the info36    of source files to consider for difference. Maybe a function of the37    info dict.38dest_field: str | callable39    If ``update_field`` is "different", this is the key in the info40    of destination files to consider for difference. May be a function of41    the info dict.42update_cond: "different"|"always"|"never"43    If "always", every file is copied, regardless of whether it exists in44    the destination. If "never", files that exist in the destination are45    not copied again. If "different" (default), only copy if the info46    fields given by ``source_field`` and ``dest_field`` (usually "size")47    are different. Other comparisons may be added in the future.48inst_kwargs: dict|None49    If ``fs`` is None, use this set of keyword arguments to make a50    GenericFileSystem instance51fs: GenericFileSystem|None52    Instance to use if explicitly given. The instance defines how to53    to make downstream file system instances from paths.54 55Returns56-------57dict of the copy operations that were performed, {source: destination}58T)�withdirs�detailzCan only rsync on a directory�type�	directoryz directories to create��exist_ok�filez files to consider for copy�always�never�	differentz files to copyz files to delete�)�GenericFileSystem�_strip_protocol�find�isdirr�items�replace�logger�debug�len�make_many_dirs�copy�pop�callable�zip�cp�rm)�source�destination�delete_missing�source_field�59dest_field�update_cond�inst_kwargsr!�kwargs�allfiles�60otherfiles�a�v�dirs�dirn�o�	to_delete�k�	otherfile�inf1�v2�inf2�source_files�target_filess                        r�rsyncrW(s���h61�	7� �7�K�$5�2�7�B�
�
�
��
'�F��$�$�[�1�K��w�w�v��T�w�:�H�
�8�8�F����8�9�9�����t�D��A�J��N�N�$��$�D�A��V�9��#�	62�()�	�	�&�(F�j�(X�	63�$�	��64�L�L�C��I�;�4�5�6��65���;?�@�4�4�\�\�&�
.�4�@�4�	�	66�"*���!1�I�!1���Q�v�Y�&�5H����!1�H�I�67�L�L�C��M�?�"=�>�?��$�$�&��&�D�A��9�9�[�)��9�	68�>?��i�6�>Q�	69�&���70�
�
��%�%�'���1��I�I�f�2�	��71�"��h�&�'������'����Q����+�*2�<�*@�*@�|�A��a�o���	�*��)1�*�)=�)=�z�"�~�2�j�>���4�<�"+�H�Q�K��L�L��O�,�$�H�Q�K�'(�(�L�L�C��M�?�.�1�2��%(�(�.�.�*:�%;�"��l�72���l�L�3�F�3�73�L�L�C�	�N�#�#3�4�5��)�74���i���O��Y��
A��I��s6�L�)L�L�L#�3L(�L(�L.�"L.�-L.c��^�\rSrSrSrSrSU4SjjrSrSrSSjr	S	r75SS76jrSrSr
S
rSSjrSrS\S4SSjjrSSjr\"\5rSSSjjrSrU=r$)r0�aBWrapper over all other FS types77 78<experimental!>79 80This implementation is a single unified interface to be able to run FS operations81over generic URLs, and dispatch to the specific implementations using the URL82protocol prefix.83 84Note: instances of this FS are always async, even if you never use it with any async85backend.86rNc�>>�XlX l[TU]"S0UD6 g)am87 88Parameters89----------90default_method: str (optional)91    Defines how to configure backend FS instances. Options are:92    - "default": instantiate like FSClass(), with no93      extra arguments; this is the default instance of that FS, and can be94      configured via the config system95    - "generic": takes instances from the `_generic_fs` dict in this module,96      which you must populate before use. Keys are by protocol97    - "options": expects storage_options, a dict mapping protocol to98      kwargs to use when constructing the filesystem99    - "current": takes the most recently instantiated version of each FS100Nr/)r�st_opts�super�__init__)�self�default_methodrrG�	__class__s    �rr]�GenericFileSystem.__init__�s��� %��&��
���"�6�"rc�~�[XRURS9nURUR	U55$�N�r)r#rr[�unstrip_protocol�_parent�r^�pathr!s   rrf�GenericFileSystem._parent�s0��
��{�{�D�L�L�
I���"�"�2�:�:�d�#3�4�4rc�~�[XRURS9nURUR	U55$rc)r#rr[rer1rgs   rr1�!GenericFileSystem._strip_protocol�s2��
��{�{�D�L�L�
I���"�"�2�#5�#5�d�#;�<�<rc��# �[XRURS9nUR(aUR"U4X#SS.UD6IShv�NnOUR101"U4X#SS.UD6n0nUR
5H.up�U102R5n103URU	5nX�S'X�U'M0 U(aU$[U5$Ns7f)NrdT)�maxdepthr%r&�name)104r#rr[�105async_impl�_findr2r4r:rer)r^rhrmr%r&rGr!�out�resultrPrKrns            rrp�GenericFileSystem._find�s����
��{�{�D�L�L�
I��
�=�=������'�4��KQ���C��'�'���'�4��KQ��C����I�I�K�D�A�����A��&�&�q�)�D��f�I��4�L�	 �106��M��F�|���s�A	C�B?�A4Cc��107# �[XR5nUR(aUR"U40UD6IShv�NnOUR"U40UD6nUR5nUR
US5US'U$NA7f)Nrn)r#rro�_info�infor:re)r^rrGr!rqs     rru�GenericFileSystem._info�sp���
��k�k�
*��
�=�=�����/��/�/�C��'�'�#�(��(�C��h�h�j���)�)�#�f�+�6��F���108�0�s�=B�B�ABc��# �[XR5nUR(aUR"U4SS0UD6IShv�NnOUR"U4SS0UD6nUVs/sHofR5PM nnUHnUR
US5US'M U(aU$UVs/sHofSPM	 sn$Nws snfs snf7f)Nr&Trn)r#rro�_ls�lsr:re)r^rr&rGr!rqrNs       rry�GenericFileSystem._ls�s������k�k�
*��
�=�=����s�:�4�:�6�:�:�C��%�%��3�D�3�F�3�C�!$�%��A�v�v�x���%��A��+�+�A�f�I�6�A�f�I����J�'*�+�s�!�f�I�s�+�+�;��&��,�s/�?C�B9�C� B;�9/C�(C�6C�;109Cc��# �[XR5nUR(aUR"U40UD6IShv�N$UR"U40UD6$N7f�N)r#rro�	_cat_file�cat_file)r^rrGr!s    rr~�GenericFileSystem._cat_file�sL���110��k�k�
*��
�=�=����c�4�V�4�4�4��;�;�s�-�f�-�-�5�s�=A�A�Ac���# �[XRURS9nUR(aUR"X40UD6IShv�N$UR111"X40UD6$N7frc)r#rr[ro�112_pipe_file�	pipe_file)r^rh�valuerGr!s     rr��GenericFileSystem._pipe_file�sR�����{�{�D�L�L�
I��
�=�=����t�=�f�=�=�=��<�<��6�v�6�6�>�s�AA"�A �	A"c���# �Un[U[5(aU/n[USUR5nUR(aUR113"U40UD6IShv�N gUR"U40UD6 gN7f)Nr)r�strr#rro�_rmr?)r^rrG�urlsr!s     rr��GenericFileSystem._rmsf������d�C� � ��6�D�
��a��$�+�+�
.��
�=�=��&�&��(��(�(�(��E�E�#� �� �
)�s�AA9�A7�A9c���# �[RSU5 [XRURS9nUR114(aUR
XS9IShv�N gURXS9 gN7f)NzMake dir %srdr))r6r7r#rr[ro�	_makedirs�makedirs)r^rhr*r!s    rr��GenericFileSystem._makedirssU������]�D�)�
��{�{�D�L�L�
I��
�=�=��,�,�t�,�7�7�7��K�K��K�0�
8�s�AA2�A0�A2c� �[X4SU0UD6 g)zKSync files between two directory trees115 116See `func:rsync` for more details.117r!N)rW)r^r@rArGs    rrW�GenericFileSystem.rsyncs��118	�f�5�d�5�f�5ric119��# �[XR5n[X R5nXxLa?UR(aUR"X40UD6IShv�N$UR"X40UD6$[Xq/X�/USSS9IShv�N gN/N7f)Nr�raise��on_error)r#rro�_copyr:�copy_file_op)	r^r�url2�	blocksize�callback�tempdirrGr!�fs2s	         r�_cp_file�GenericFileSystem._cp_files�����k�k�
*���$���,��
�9��}�}��X�X�c�:�6�:�:�:��w�w�s�3�F�3�3��2�u�c�6�7�A��P�P�P�;�	Q�s$�AB�B�)B�B120�B�121Bc��# �[USUR5nUR(a2UVs/sHoCRXBS9PM nn[	U5IShv�N gUHnURXBS9 M gs snfN#7f)Nrr))r#rror�rr�)r^r�r*r!�u�coross      r�_make_many_dirs�!GenericFileSystem._make_many_dirs2sl���
��a��$�+�+�
.��
�=�=�AE�F��A�\�\�!�\�7��E�F�&�u�-�-�-������A��1���G�-�s�/A?�A8�	A?�A=�$A?c122��# �U(a[S5e[U[5(aU/OUn[U[5(aU/OUn[XR5n	[X R5n123X�La?U	R124(aU	R"X40UD6IShv�N$U	R"X40UD6$[X�X�XvUS9IShv�N gN,N7f)NzPlease use fsspec.generic.rsyncr�)	�NotImplementedErrorrr�r#rror�r:r�)r^�path1�path2�	recursiver�rm�125batch_sizer�rGr!r�s           rr��GenericFileSystem._copy=s�����%�&G�H�H�%�e�S�1�1���u��%�e�S�1�1���u��
����
,���%���-��
�9��}�}��X�X�e�=�f�=�=�=��w�w�u�6�v�6�6���s�7��126�	127�	128�	>�	129�s$�BC�C�&C�C
�C�
C)rr[)rN)NFF)T)F)r��130str | None)F�ignoreNNN)r��	list[str]r�r�r��boolr�r�rm�131int | Noner�r�r�r�)�__name__�132__module__�__qualname__�__firstlineno__�__doc__rr]rfr1rpruryr~r�r�r�rWrr�r�rr9r��__static_attributes__�
__classcell__)r`s@rr0r0�s����133��H�#�(5�=�134�(��,�&	.�1357�!�1�6��!�"�
Q��
Q�&2�"�/�2�N� � �#�!%�"�136��137��138��	139�140�141��
142��143��144�145rr0c��146# �SSKnU=(d UR5n[X5VV	s/sHOup�[UUUU	[R147R
U[R"5R55PMQ n148nn	[X�SS9IShv�Nn[R"U5 US:XaU$US:Xa!UHn[U[5(dMUe ggs sn	nfNP![R"U5 f=f7f)NrT)r��return_exceptions�returnr�)�tempfile�mkdtempr=�
_copy_file_op�osrh�join�uuid�uuid4�hexr�shutil�rmtreer�	Exception)
�fs1�url1r�r�r�r�r�r��u1�u2r�rqrNs
             rr�r�]s������+��)�)�+�G���d�/�	149�*���
����������W�d�j�j�l�&6�&6�7�
�*�	�	150�)��D�151�152��	�
�
�g���8���153�	�W�	��A��!�Y�'�'����154��#	155�156��	�
�
�g��s@�D�C(�AC �C(�C&�C(�<D�D� C(�(D�Dc��\# �UR(aURX5IShv�N OURX5 UR(aURXC5IShv�N OUR	XC5 [157R"U5 [RSX5 gNNE7f)NzCopy %s -> %s; done)	ro�	_get_file�get_file�	_put_file�put_filer��unlinkr6r7)r�r�r�r��localr�s      rr�r�{st���158�~�~��m�m�D�(�(�(����T�!�159�~�~��m�m�E�(�(�(����U�!��I�I�e��160�L�L�&��3�	)�	)�s"�&B,�B(�;B,�$B*�%AB,�*B,c��\# �[R"U5(a161UIShv�N$U$N7fr})�inspect�iscoroutine)�cors r�maybe_awaitr��s(������3����y���162��s�!,�*�,)NN)F�sizer�r.NN)N�r�)r�)�163__future__rr��loggingr�r�r��asynrrr�	callbacksr�corer	r164rrr�	getLoggerr6rr#rWr0r�r�r�r/rr�<module>r�s���"���	�
��E�E�'�M�M���	�	�	�+�	,��D�165@�*������g�TH166��H167�XAI��<1684�r
codekingpro/portable-devtools · Team Ai