
    2 f                     b    d Z ddlZddlmZ ddlmZmZ ddlmZ dgZ	d Z
 G d de          ZdS )	zEditorConfig file handler

Provides ``EditorConfigHandler`` class for locating and parsing
EditorConfig files relevant to a given filepath.

Licensed under Simplified BSD License (see LICENSE.BSD file).

    N)VERSION)	PathErrorVersionError)EditorConfigParserEditorConfigHandlerc                     g }	 |                     t          j                            | |                     t          j                            |           }| |k    rn|} \|S )zDYield full filepath for filename in each directory in and above path)appendospathjoindirname)r   filename	path_listnewpaths       J/var/www/equiseq/venv/lib/python3.11/site-packages/editorconfig/handler.pyget_filenamesr      sa    IdH55666'//$''7??     c                   0    e Zd ZdZdefdZd Zd Zd ZdS )r   a  
    Allows locating and parsing of EditorConfig files for given filename

    In addition to the constructor a single public method is provided,
    ``get_configurations`` which returns the EditorConfig options for
    the ``filepath`` specified to the constructor.

    z.editorconfigc                 >    || _         || _        || _        d| _        dS )z6Create EditorConfigHandler for matching given filepathN)filepathconf_filenameversionoptions)selfr   r   r   s       r   __init__zEditorConfigHandler.__init__+   s%     !*r   c                    |                                   t          j                            | j                  \  }}t          || j                  }|D ]c}t          | j                  }|                    |           | j	        }|j	        | _	        |r| j	        
                    |           |j        r nd|                                  | j	        S )aw  
        Find EditorConfig files and return all options matching filepath

        Special exceptions that may be raised by this function include:

        - ``VersionError``: self.version is invalid EditorConfig version
        - ``PathError``: self.filepath is not a valid absolute filepath
        - ``ParsingError``: improperly formatted EditorConfig file found

        )check_assertionsr
   r   splitr   r   r   r   readr   update	root_filepreprocess_values)r   r   r   
conf_filesparserold_optionss         r   get_configurationsz&EditorConfigHandler.get_configurations3   s     	t}55h"4);<<
 # 	 	H'66FKK!!! ,K!>DL 1##K000   	   |r   c                     t           j                            | j                  st	          d          | j        /| j        dd         t          dd         k    rt          d          dS dS )z6Raise error if filepath or version have invalid valuesz$Input file must be a full path name.N   z5Required version is greater than the current version.)r
   r   isabsr   r   r   r   r   )r   s    r   r   z$EditorConfigHandler.check_assertionsV   sy    
 w}}T]++ 	DBCCC <#RaR(872A2;(F(FGI I I $#(F(Fr   c                 B   | j         }dD ]#}||v r||                                         ||<   $|                    d          dk    rd|vr| j        dk    rd|d<   d|v rd|vr|d         dk    r|d         |d<   d|v rd|v r|d         dk    r|d         |d<   dS dS dS dS )z3Preprocess option values for consumption by plugins)end_of_lineindent_styleindent_sizeinsert_final_newlinetrim_trailing_whitespacecharsetr,   tabr-   )r   
   r   	tab_widthN)r   lowergetr   )r   optsnames      r   r"   z%EditorConfigHandler.preprocess_valuesc   s    |  	0 	0D t||!$Z--//T
 HH^$$--!T))dlj.H.H"'D T!!k&=&=]#u,, $] 3D T!!kT&9&9]#u,,"&{"3D "!&9&9,,r   N)	__name__
__module____qualname____doc__r   r   r&   r   r"    r   r   r   r       sk          0?    ! ! !FI I I4 4 4 4 4r   )r;   r
   editorconfigr   editorconfig.exceptionsr   r   editorconfig.inir   __all__r   objectr   r<   r   r   <module>rB      s     
			             ; ; ; ; ; ; ; ; / / / / / / !
!	 	 	_4 _4 _4 _4 _4& _4 _4 _4 _4 _4r   