o
    Ưh3                     @   s  d 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m	Z	m
Z
mZ ddlmZ ddlmZmZ dd	lmZ d
ZefdededefddZeddefdededeeef fddZdedede
eeef  fddZdedede
eeef  fddZdedede
eeef  fddZ		d,dedede
e	e  deedf de
eeef  f
ddZd edefd!d"Zd edefd#d$Zd ed%ee defd&d'Zd(ed)edefd*d+ZdS )-zIContains all logic related to placing an import within a certain section.    N)fnmatch)	lru_cache)Path)	FrozenSetIterableOptionalTuple)sections)DEFAULT_CONFIGConfig)exists_case_sensitiveLOCALFOLDERnameconfigreturnc                 C   s   t | |d S )z8Returns the section placement for the given module name.r   )module_with_reasonr   r    r   H/var/www/Befach/backend/venv/lib/python3.10/site-packages/isort/place.pymodule   s   r   i  )maxsizec                 C   s2   t | |pt| |pt| |pt| |p|jdfS )zPReturns the section placement for the given module name alongside the reasoning.z.Default option in Config or universal default.)_forced_separate_local_known_pattern	_src_pathdefault_sectionr   r   r   r   r      s   
r   c                 C   sT   |j D ]$}|}|ds| d}t| |st| d| r'|d| df  S qd S )N*.zMatched forced_separate (z) config value.)forced_separateendswithr   )r   r   r   	path_globr   r   r   r   !   s   


r   c                 C   s   |  dr	tdfS d S )Nr   zModule name started with a dot.)
startswithLOCALr   r   r   r   r   .   s   
r   c                    sp   |  d  fddtt ddD }|D ]}|jD ]\}}||jv r4||r4|d| f    S qqd S )Nr   c                 3   s"    | ]}d   d| V  qdS )r   N)join).0first_kpartsr   r   	<genexpr>7   s     z!_known_pattern.<locals>.<genexpr>r   z!Matched configured known pattern )splitrangelenknown_patternsr	   match)r   r   module_names_to_checkmodule_name_to_checkpattern	placementr   r&   r   r   5   s   
r   r   	src_pathsprefix.c           
      C   s   |d u r|j }| dd^}}g ||R }d|}|D ]K}||  }	|s4|	 s4|j|kr4| }	|rP||jv sD|jrPt|	|j	rPt
|d ||	f|  S t|	s]t|	s]t||rhtjd| df  S qd S )Nr      r   z*Found in one of the configured src_paths: )r3   r*   r#   resolveis_dirr   namespace_packages auto_identify_namespace_packages_is_namespace_packagesupported_extensionsr   
_is_module_is_package_src_path_is_moduler	   
FIRSTPARTY)
r   r   r3   r4   root_module_namenested_module
new_prefix	namespacesrc_pathmodule_pathr   r   r   r   @   s2   


r   pathc                    s<   t t dpt fddtjjD pt t d S )Nz.pyc                 3   s"    | ]}t t |V  qd S N)r   strwith_suffix)r$   
ext_suffixrF   r   r   r(   f   s
    
z_is_module.<locals>.<genexpr>__init__.py)r   rH   rI   any	importlib	machineryEXTENSION_SUFFIXESrK   r   rK   r   r<   c   s   r<   c                 C   s   t t| o	|  S rG   )r   rH   r7   rK   r   r   r   r=   n   s   r=   src_extensionsc                    s   t | sdS | d }| s fdd|  D }|rdS dS |d?}|d}d|vrCd|vrKd	|vrSd
|vr[	 W d    dS W d    dS W d    dS W d    dS W d    dS 1 sfw   Y  dS )NFrL   c                    s.   g | ]}|j d  v s|j dv r|qS )r   )z	setup.cfgzpyproject.toml)suffixlstripr   lower)r$   filepathrQ   r   r   
<listcomp>x   s    z)_is_namespace_package.<locals>.<listcomp>rbi   s7   __import__('pkg_resources').declare_namespace(__name__)s7   __import__("pkg_resources").declare_namespace(__name__)s@   __path__ = __import__('pkgutil').extend_path(__path__, __name__)s@   __path__ = __import__("pkgutil").extend_path(__path__, __name__)T)r=   existsiterdiropenread)rF   rQ   	init_file	filenamesopen_init_file
file_startr   rV   r   r:   r   sH   





r:   rD   module_namec                 C   s   || j ko|  ott| S rG   )r   r7   r   rH   )rD   ra   r   r   r   r>      s   r>   )Nr   ) __doc__rN   r   	functoolsr   pathlibr   typingr   r   r   r   isortr	   isort.settingsr
   r   isort.utilsr   r"   rH   r   r   r   r   r   r   boolr<   r=   r:   r>   r   r   r   r   <module>   sB    $"""


#