
    giv                     &   d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm	Z	 d dl
Z
d dlZ e
j                    d             Z G d d          Z e
j        dd	          d
eeddf         fd            Z e
j        d          d             ZdS )    N)deque)	GeneratorSequencec               #     K   t          j        d          } | j                                         | j                                         | j                            d           	 | V  | j                                         | j                                         | j                            d           dS # | j                                         | j                                         | j                            d           w xY w)z0
    Fixture providing a memory filesystem.
    memory N)fsspec
filesystemstoreclearpseudo_dirsappend)ms    g/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/fsspec/conftest.pyr   r      s      
 	(##AGMMOOOMM!			R      	
		R    s   $B6 6ADc                   @    e Zd ZdZd	dZdddedeeef         fdZ	dS )
InstanceCacheInspectorzQ
    Helper class to inspect instance caches of filesystem classes in tests.
    returnNc                     t          t          j        j        g          }|rS|                                }|                                 |                    |                                           |QdS dS )zU
        Clear instance caches of all currently imported filesystem classes.
        N)r   r	   specAbstractFileSystempopleftclear_instance_cacheextend__subclasses__)selfclassesclss      r   r   zInstanceCacheInspector.clear$   s~     7899 	1//##C$$&&&NN3--//000  	1 	1 	1 	1 	1    T)	omit_zeror   c                   i }t          t          j        j        g          }|r|                                }t          |j                  }t          |j        t          t          f          r7t          |j        t                    r|j        n|j        d         }|s|s|||<   |                    |                                           ||S )a  
        Gather counts of filesystem instances in the instance caches
        of all currently imported filesystem classes.

        Parameters
        ----------
        omit_zero:
            Whether to omit instance types with no cached instances.
        r   )r   r	   r   r   r   len_cache
isinstanceprotocolr   strr   r   )r   r   outr   r   countkeys          r   gather_countsz$InstanceCacheInspector.gather_counts.   s     !7899 		1//##C
OOE #,388 %&0s&C&CXcllVW %	 %$CHNN3--//000  		1 
r   )r   N)
__name__
__module____qualname____doc__r   booldictr%   intr)    r   r   r   r      sk         1 1 1 1 26   $ $sCx.      r   r   functionT)scopeautouser   c               #      K   t                      } |                                  	 | V  |                                  dS # |                                  w xY w)as  
    Fixture to ensure empty filesystem instance caches before and after a test.

    Used by default for all tests.
    Clears caches of all imported filesystem classes.
    Can be used to write test assertions about instance caches.

    Usage:

        def test_something(instance_caches):
            # Test code here
            fsspec.open("file://abc")
            fsspec.open("memory://foo/bar")

            # Test assertion
            assert instance_caches.gather_counts() == {"file": 1, "memory": 1}

    Returns
    -------
    instance_caches: An instance cache inspector for clearing and inspecting caches.
    N)r   r   )ics    r   instance_cachesr7   G   sQ      . 
 	!	!BHHJJJ









s   A   A)r3   c              #     K   t          j        d           t          |           }t          t          j                            |d          d          5 }|                    ddz             ddd           n# 1 swxY w Y   t          j	        t          j        ddd|d	d
dddg
          }	 t          j        d           dV  |                                 |                                 	 t!          j        |            dS # t$          $ r Y dS w xY w# |                                 |                                 	 t!          j        |            w # t$          $ r Y w w xY wxY w)z6
    Fixture providing a writable FTP filesystem.
    	pyftpdlibr&   wbs   helloi'  Nz-mz-dz-uuserz-Ppassz-w   )	localhostiI  r;   r<   )pytestimportorskipr%   openospathjoinwrite
subprocessPopensys
executabletimesleep	terminatewaitshutilrmtree	Exception)tmpdirdfPs       r   ftp_writablerU   g   s     
 $$$FA	bgll1e$$d	+	+ "q	5 !!!" " " " " " " " " " " " " " "	{D!T64QUV	 	A	
1////			M&!!!!! 	 	 	DD		 	
		M&!!!! 	 	 	D	sT   A99A= A=-D .D 
DD)E$?EE$
E!E$ E!!E$)rB   rN   rF   rH   rJ   collectionsr   collections.abcr   r   r?   r	   fixturer   r   r7   rU   r1   r   r   <module>rY      s;   				      



        / / / / / / / /   ! ! ! % % % % % % % %P j$///#94#EF    0/> j!!!  "!  r   