o
    voi                     @  s`  d dl mZ d dlmZ d dlmZ d dlmZ d dlZd dl	Z	d dl
mZ d dlZd dlZd dlmZ d dlmZ d d	lmZ 	 d dlmZ d dlmZ e	jdkZejdkZejdkZejdkZejdkZG dd dejZervd dlZnd dlZerd
dd7ddZ ddd8d!d"Z!nd
dd7d#dZ ddd8d$d"Z!d9d(d)Z"	d:d;d.d/Z#d<d5d6Z$dS )=    )annotations)ConfigParser)metadata)
EntryPointN)Path)Any)Iterator)SequenceT)inspect_getfullargspec)inspect_formatargspecposix)      )r      )r      )r      c                   @  s   e Zd ZdddZdS )	EncodedIOreturnNonec                 C  s   d S N )selfr   r   G/home/ubuntu/.local/lib/python3.10/site-packages/alembic/util/compat.pyclose&   s   zEncodedIO.closeN)r   r   )__name__
__module____qualname__r   r   r   r   r   r   %   s    r   )top_downpathr   r   boolr   +Iterator[tuple[Path, list[str], list[str]]]c                C  s
   t | S r   )r   walk)r   r   r   r   r   	path_walk2   s   
r"   Fwalk_upotherr$   c                C  s   | j ||dS )Nr#   )relative_to)r   r%   r$   r   r   r   path_relative_to7   s   r'   c                c  s0    t j| |dD ]\}}}t|||fV  qd S )N)topdown)osr!   r   )r   r   rootdirsfilesr   r   r   r"   >   s   c                C  st   z|  |W S  ty9   |r8t|j|g }|D ]}z
|  |W    Y S  ty.   Y qw t|  d|  w )z
        Calculate the relative path of 'path' with respect to 'other',
        optionally allowing 'path' to be outside the subtree of 'other'.

        OK I used AI for this, sorry

        z is not in the same subtree as )r&   
ValueErrorlistparents)r   r%   r$   other_ancestorsancestorr   r   r   r'   D   s    
groupstrSequence[EntryPoint]c                 C  s   t  j| dS )zprovide a facade for metadata.entry_points().

    This is no longer a "compat" function as of Python 3.10, however
    the function is widely referenced in the test suite and elsewhere so is
    still in this module for compatibility reasons.

    r2   )r   entry_pointsselectr5   r   r   r   importlib_metadata_get_   s   r8   
annotationr   base_module
Any | Nonec                 C  s   t | tr| S t| dddkrt| ddddS t | tr4| jd|fv r,t| jS | jd | j S t | tj	rBt| ddS t| ddS )	zvendored from python 3.7r   Ntypingztyping. ~builtins.)

isinstancer3   getattrreprreplacetyper   r   r<   TypeVar)r9   r:   r   r   r   formatannotation_fwdrefj   s   


rG   file_configr   file_argumentlist[str | os.PathLike[str]]	list[str]c                 C  s   | j |ddS )Nlocale)encoding)read)rH   rI   r   r   r   read_config_parser~   s   rO   )r   r   r   r   r   r    )r   r   r%   r   r$   r   r   r   )r2   r3   r   r4   r   )r9   r   r:   r;   r   r3   )rH   r   rI   rJ   r   rK   )%
__future__r   configparserr   	importlibr   importlib.metadatar   ior)   pathlibr   sysr<   r   r   r	   sqlalchemy.utilr
   sqlalchemy.util.compatr   nameis_posixversion_infopy314py313py312py311TextIOWrapperr   tomllibtomlir"   r'   r8   rG   rO   r   r   r   r   <module>   sJ   






